hyunjae commited on
Commit
658a043
ยท
verified ยท
1 Parent(s): bcacb21

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -0
README.md CHANGED
@@ -9,3 +9,29 @@ pipeline_tag: text-generation
9
  - base_model: polyglot-ko-3.8b1
10
  - train_data: 12 instruction fine-tuned dataset
11
  - train method: SFT
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  - base_model: polyglot-ko-3.8b1
10
  - train_data: 12 instruction fine-tuned dataset
11
  - train method: SFT
12
+
13
+
14
+ ```python
15
+ from transformers import AutoModelForCausalLM, AutoTokenizer
16
+
17
+ device = "cuda" # the device to load the model onto
18
+
19
+ model = AutoModelForCausalLM.from_pretrained("hyunjae/polyglot-ko-3.8b-total")
20
+ tokenizer = AutoTokenizer.from_pretrained("hyunjae/polyglot-ko-3.8b-total")
21
+
22
+ messages = [
23
+ {"role": "system", "content": "๋‹น์‹ ์€ ์‚ฌ๋žŒ๋“ค์ด ์ •๋ณด๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ์ธ๊ณต์ง€๋Šฅ ๋น„์„œ์ž…๋‹ˆ๋‹ค."},
24
+ {"role": "user", "content": "๋Œ€ํ•œ๋ฏผ๊ตญ์˜ ์ˆ˜๋„๋Š” ์–ด๋””์•ผ?"},
25
+ {"role": "assistant", "content": "๋Œ€ํ•œ๋ฏผ๊ตญ์˜ ์ˆ˜๋„๋Š” ์„œ์šธ์ž…๋‹ˆ๋‹ค."},
26
+ {"role": "user", "content": "์„œ์šธ ์ธ๊ตฌ๋Š” ์ด ๋ช‡ ๋ช…์ด์•ผ?"}
27
+ ]
28
+
29
+ encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")
30
+
31
+ model_inputs = encodeds.to(device)
32
+ model.to(device)
33
+
34
+ generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
35
+ decoded = tokenizer.batch_decode(generated_ids)
36
+ print(decoded[0])
37
+ ```