Update README.md
Browse files
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 |
+
```
|