This commit is contained in:
P小二
2024-02-24 01:20:17 +08:00
parent 58498fb7e5
commit ac8d3089e1
4 changed files with 18 additions and 3 deletions

View File

@@ -2,17 +2,19 @@
## run
## run it
python >= 3.9
```pip3 install -r requirements.txt```
```bash
python3 gptchat.py
```
then open url: http://localhost:8888
open http://localhost:8888

View File

View File

@@ -0,0 +1,11 @@
# pip install accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("google/gemma-7b-it")
model = AutoModelForCausalLM.from_pretrained("google/gemma-7b-it", device_map="auto")
input_text = "Write me a poem about Machine Learning."
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
outputs = model.generate(**input_ids)
print(tokenizer.decode(outputs[0]))

View File

@@ -0,0 +1,2 @@
accelerate
transformers