duongna commited on
Commit
57c57f1
1 Parent(s): 42fd7d7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +24 -1
README.md CHANGED
@@ -11,4 +11,27 @@ tags:
11
 
12
  Details will be available soon.
13
 
14
- For more information, please contact anhduongng.1001@gmail.com (Dương) / imthanhlv@gmail.com (Thành) / nguyenvulebinh@gmail.com (Bình).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  Details will be available soon.
13
 
14
+ For more information, please contact anhduongng.1001@gmail.com (Dương) / imthanhlv@gmail.com (Thành) / nguyenvulebinh@gmail.com (Bình).
15
+
16
+ ### How to use
17
+ from transformers import AutoTokenizer, AutoModelForCausalLM
18
+
19
+ tokenizer = AutoTokenizer.from_pretrained("VietAI/gpt-j-6B-vietnamese-news")
20
+ model = AutoModelForCausalLM.from_pretrained("VietAI/gpt-j-6B-vietnamese-news", low_cpu_mem_usage=True)
21
+
22
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
23
+ model.to(device)
24
+
25
+ prompt = "Tiềm năng của trí tuệ nhân tạo" # your input sentence
26
+ input_ids = tokenizer(prompt, return_tensors="pt")['input_ids'].to(device)
27
+
28
+ gen_tokens = model.generate(
29
+ input_ids,
30
+ max_length=max_length,
31
+ do_sample=True,
32
+ temperature=0.9,
33
+ top_k=20,
34
+ )
35
+
36
+ gen_text = tokenizer.batch_decode(gen_tokens)[0]
37
+ print(gen_text)