File tree 4 files changed +18
-3
lines changed
4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
4
4
5
- ## run
5
+
6
+
7
+ ## run it
6
8
7
9
python >= 3.9
8
10
9
11
``` pip3 install -r requirements.txt ```
10
12
13
+
11
14
``` bash
12
15
python3 gptchat.py
13
-
14
16
```
15
17
16
- then open url: http://localhost:8888
18
+ open http://localhost:8888
17
19
18
20
Original file line number Diff line number Diff line change
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 ]))
Original file line number Diff line number Diff line change
1
+ accelerate
2
+ transformers
You can’t perform that action at this time.
0 commit comments