Siddharth63 commited on
Commit
faba1c8
·
verified ·
1 Parent(s): a181f8a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -3
README.md CHANGED
@@ -1,3 +1,23 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ ```
5
+ from transformers import AutoModelForCausalLM, AutoTokenizer
6
+ device = "cuda"
7
+ model_path =
8
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
9
+ # drop device_map if running on CPU
10
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
11
+ model.eval()
12
+ # change input text as desired
13
+ input_text = "Where is the Thomas J. Watson Research Center located?"
14
+ # tokenize the text
15
+ input_tokens = tokenizer(input_text, return_tensors="pt").to(device)
16
+ # generate output tokens
17
+ output = model.generate(**input_tokens,
18
+ max_length=4000)
19
+ # decode output tokens into text
20
+ output = tokenizer.batch_decode(output)
21
+ # print output
22
+ print(output)
23
+ ```