Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ac8d308

Browse files
committed
add 02
1 parent 58498fb commit ac8d308

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

01.GPTChat/README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33

44

5-
## run
5+
6+
7+
## run it
68

79
python >= 3.9
810

911
```pip3 install -r requirements.txt```
1012

13+
1114
```bash
1215
python3 gptchat.py
13-
1416
```
1517

16-
then open url: http://localhost:8888
18+
open http://localhost:8888
1719

1820

02.ChatWithGemma7b /README.md

Whitespace-only changes.

02.ChatWithGemma7b /gemmachat.py

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

02.ChatWithGemma7b /requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
accelerate
2+
transformers

0 commit comments

Comments
 (0)