Update README.md
Browse files
README.md
CHANGED
@@ -2,6 +2,55 @@
|
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
|
5 |
-
Train Config
|
6 |
-
base_model: allganize/Llama-3-Alpha-Ko-8B-Instruct
|
7 |
-
model_type: AutoModelForCausalLM tokenizer_type: AutoTokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
|
5 |
+
- Train Config
|
6 |
+
- base_model: allganize/Llama-3-Alpha-Ko-8B-Instruct
|
7 |
+
- model_type: AutoModelForCausalLM tokenizer_type: AutoTokenizer
|
8 |
+
|
9 |
+
## HOW TO USE
|
10 |
+
```python
|
11 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
12 |
+
|
13 |
+
model_id = "MRAIRR/minillama3_8b_all"
|
14 |
+
|
15 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
16 |
+
model = AutoModelForCausalLM.from_pretrained(
|
17 |
+
model_id,
|
18 |
+
torch_dtype="auto",
|
19 |
+
device_map="auto",
|
20 |
+
)
|
21 |
+
|
22 |
+
PROMPT_TEMPLATE = """
|
23 |
+
# μ§μ:
|
24 |
+
λΉμ μ μΈκ³΅μ§λ₯ μ΄μμ€ν΄νΈμ
λλ€. μ¬μ©μκ° λ¬»λ λ§μ μΉμ νκ³ μ ννκ² λ΅λ³νμΈμ.
|
25 |
+
"""
|
26 |
+
|
27 |
+
messages = [
|
28 |
+
{"role": "system", "content":PROMPT_TEMPLATE},
|
29 |
+
{"role": "user", "content": "μλ
? λ΄ μ΄λ¦μ νμ γ
γ
λ§λμ λ°κ°μ"},
|
30 |
+
]
|
31 |
+
|
32 |
+
input_ids = tokenizer.apply_chat_template(
|
33 |
+
messages,
|
34 |
+
add_generation_prompt=True,
|
35 |
+
return_tensors="pt"
|
36 |
+
).to(model.device)
|
37 |
+
|
38 |
+
terminators = [
|
39 |
+
tokenizer.eos_token_id,
|
40 |
+
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
41 |
+
]
|
42 |
+
|
43 |
+
outputs = model.generate(
|
44 |
+
input_ids,
|
45 |
+
max_new_tokens=256,
|
46 |
+
temperature = 0.3,
|
47 |
+
eos_token_id=terminators,
|
48 |
+
do_sample=True,
|
49 |
+
repetition_penalty=1.05,
|
50 |
+
)
|
51 |
+
response = outputs[0][input_ids.shape[-1]:]
|
52 |
+
response_text = tokenizer.decode(response, skip_special_tokens=True)
|
53 |
+
completion = '\n'.join(response_text.split("."))
|
54 |
+
print(completion)
|
55 |
+
```
|
56 |
+
|