Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,75 @@
|
|
1 |
-
---
|
2 |
-
license: llama3.2
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: llama3.2
|
3 |
+
datasets:
|
4 |
+
- KorQuAD/squad_kor_v1
|
5 |
+
language:
|
6 |
+
- ko
|
7 |
+
base_model:
|
8 |
+
- meta-llama/Llama-3.1-8B-Instruct
|
9 |
+
---
|
10 |
+
|
11 |
+
# Llama-3.2-1B-Instruct-korQuAD-v1
|
12 |
+
|
13 |
+
์ด ๋ชจ๋ธ์ Llama-3.2-1B-Instruct๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ๊ตญ์ด ์ง์์๋ต ํ์คํฌ์ ๋ํด ํ์ธํ๋๋ ๋ชจ๋ธ์
๋๋ค.
|
14 |
+
|
15 |
+
## ๋ชจ๋ธ ์ค๋ช
|
16 |
+
|
17 |
+
- ๊ธฐ๋ณธ ๋ชจ๋ธ: Llama-3.2-1B-Instruct
|
18 |
+
- ํ์ต ๋ฐ์ดํฐ์
: KorQuAD v1.0
|
19 |
+
- ํ์ต ๋ฐฉ๋ฒ: LoRA (Low-Rank Adaptation)
|
20 |
+
- ์ฃผ์ ํ์คํฌ: ํ๊ตญ์ด ์ง์์๋ต
|
21 |
+
|
22 |
+
## ์ฌ์ฉ ๋ฐฉ๋ฒ
|
23 |
+
|
24 |
+
๋ค์๊ณผ ๊ฐ์ด ๋ชจ๋ธ์ ๋ก๋ํ๊ณ ์ฌ์ฉํ ์ ์์ต๋๋ค:
|
25 |
+
```
|
26 |
+
#๋ชจ๋ธ, ํ ํฌ๋์ด์ ๋ก๋
|
27 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
28 |
+
import torch
|
29 |
+
model_path = "NakJun/Llama-3.2-1B-Instruct-ko-QuAD"
|
30 |
+
model = AutoModelForCausalLM.from_pretrained(
|
31 |
+
model_path,
|
32 |
+
torch_dtype=torch.bfloat16,
|
33 |
+
device_map="auto",
|
34 |
+
)
|
35 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
36 |
+
|
37 |
+
#์
๋ ฅ ํ์ ์ค์
|
38 |
+
prompt = f"""
|
39 |
+
### Question:
|
40 |
+
{question}
|
41 |
+
### Context:
|
42 |
+
{context}
|
43 |
+
### Answer:
|
44 |
+
"""
|
45 |
+
|
46 |
+
#ํ ํฐํ ๋ฐ ์ถ๋ก
|
47 |
+
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(model.device)
|
48 |
+
output = model.generate(
|
49 |
+
input_ids,
|
50 |
+
max_new_tokens=100,
|
51 |
+
temperature=0.1,
|
52 |
+
repetition_penalty=1.3,
|
53 |
+
do_sample=True,
|
54 |
+
eos_token_id=tokenizer.eos_token_id
|
55 |
+
)
|
56 |
+
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
57 |
+
answer = generated_text.split("Answer:")[-1].strip().split('\n')[0].strip()
|
58 |
+
print("์์ฑ๋ ๋ต๋ณ:", answer)
|
59 |
+
|
60 |
+
```
|
61 |
+
|
62 |
+
## ํ์ต ์ธ๋ถ ์ ๋ณด
|
63 |
+
- ์ํญ: 5
|
64 |
+
- ๋ฐฐ์น ํฌ๊ธฐ: 1
|
65 |
+
- ํ์ต๋ฅ : 2e-4
|
66 |
+
- ์ตํฐ๋ง์ด์ : AdamW (32-bit)
|
67 |
+
- LoRA ์ค์ :
|
68 |
+
- r: 16
|
69 |
+
- lora_alpha: 16
|
70 |
+
- ๋์ ๋ชจ๋: ["q_proj", "v_proj", "k_proj", "o_proj", "gate_proj", "down_proj", "up_proj"]
|
71 |
+
- lora_dropout: 0.01
|
72 |
+
|
73 |
+
## ์ฐ๋ฝ์ฒ
|
74 |
+
- njsung1217@gmail.com
|
75 |
+
- https://github.com/nakjun
|