lubocido
commited on
Commit
โข
dc3dfdd
1
Parent(s):
0483c2c
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Model Details
|
2 |
+
|
3 |
+
Saltlux, AI Labs ์์ ๊ฐ๋ฐํ [saltlux/Ko-Llama3-Luxia-8B](https://huggingface.co/saltlux/Ko-Llama3-Luxia-8B) ๋ชจ๋ธ์ Instruction Fine tuningํ ๋ชจ๋ธ์
๋๋ค.
|
4 |
+
์ฌ์ฉ๋ ๋ฐ์ดํฐ์
์ผ๋ก [maywell/ko_wikidata_QA](https://huggingface.co/datasets/maywell/ko_wikidata_QA)๋ฅผ ์ฌ์ฉํ์์ผ๋ฉฐ SFTTrainer๋ฅผ ํตํด 3ep๋ก ํ์ตํ์ต๋๋ค.
|
5 |
+
instruction prompt๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
|
6 |
+
|
7 |
+
```python
|
8 |
+
<|im_start|>user\n{question}<|im_end|>\n<|im_start|>assistant\n{answer}<|im_end|>
|
9 |
+
```
|
10 |
+
|
11 |
+
## HyperParameter
|
12 |
+
- num_train_epochs = 3
|
13 |
+
- warmup_steps=0.03
|
14 |
+
- learning_rate=1e-5
|
15 |
+
- optim="adamw_torch_fused"
|
16 |
+
|
17 |
+
## Evaluation with Langchain
|
18 |
+
apply_chat_tempalte์ด ์ ์ฉ๋์ด์์ง ์์ ๋ญ์ฒด์ธ์์ ํ๋กฌํํธ๋ก ์ง์ ์
๋ ฅํ์ฌ ํ๊ฐํด ๋ณผ ์ ์์ต๋๋ค.
|
19 |
+
|
20 |
+
```python
|
21 |
+
model_id = "lubocido/Ko-Llama3-Luxia-8B-it"
|
22 |
+
device = "cuda:0"
|
23 |
+
|
24 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
25 |
+
model = AutoModelForCausalLM.from_pretrained(model_id,, device_map = device, torch_dtype = torch.bfloat16)
|
26 |
+
|
27 |
+
tokenizer.padding_side = 'right'
|
28 |
+
tokenizer.pad_token = tokenizer.eos_token
|
29 |
+
|
30 |
+
sys_message = """๋น์ ์ ์น์ ํ ์ฑ๋ด์ผ๋ก์ ์๋๋ฐฉ์ ์์ฒญ์ ์ต๋ํ ์์ธํ๊ณ ์น์ ํ๊ฒ ๋ตํด์ผํฉ๋๋ค.
|
31 |
+
์ฌ์ฉ์๊ฐ ์ ๊ณตํ๋ ์ ๋ณด๋ฅผ ์ธ์ฌํ๊ฒ ๋ถ์ํ์ฌ ์ฌ์ฉ์์ ์๋๋ฅผ ์ ์ํ๊ฒ ํ์
ํ๊ณ ๊ทธ์ ๋ฐ๋ผ ๋ต๋ณ์ ์์ฑํด์ผํฉ๋๋ค.
|
32 |
+
ํญ์ ๋งค์ฐ ์์ฐ์ค๋ฌ์ด ํ๊ตญ์ด๋ก ์๋ตํ์ธ์."""
|
33 |
+
|
34 |
+
question = "๋ฆฌ๋
์ค์์ ํ๋ก์ธ์ค๋ฅผ ์ฃฝ์ด๋ ๋ช
๋ น์ด๊ฐ ๋ญ์ง?"
|
35 |
+
|
36 |
+
template = """
|
37 |
+
<|im_start|>system\n{sys_message}<|im_end|>
|
38 |
+
<|im_start|>user\n{question}<|im_end|>
|
39 |
+
<|im_start|>assistant
|
40 |
+
"""
|
41 |
+
|
42 |
+
input_data = {
|
43 |
+
'sys_message' : sys_message,
|
44 |
+
'question' : question,
|
45 |
+
}
|
46 |
+
|
47 |
+
prompt = PromptTemplate(template=template, input_variables=['sys_message', 'question'])
|
48 |
+
|
49 |
+
pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device_map=device, do_sample = True, max_length = 512, temperature = 0.1, repetition_penalty=1.2, num_beams=1,top_k=20,top_p=0.9)
|
50 |
+
|
51 |
+
langchain_pipeline = HuggingFacePipeline(pipeline=pipe)
|
52 |
+
|
53 |
+
chains = LLMChain(llm=langchain_pipeline, prompt=prompt, output_parser=StrOutputParser(), verbose=True)
|
54 |
+
|
55 |
+
print(chains.invoke(input=input_data)['text'])
|
56 |
+
```
|
57 |
+
|
58 |
+
```
|
59 |
+
<|im_start|>user
|
60 |
+
๋ฆฌ๋
์ค์์ ํ๋ก์ธ์ค๋ฅผ ์ฃฝ์ด๋ ๋ช
๋ น์ด๊ฐ ๋ญ์ง?<|im_end|>
|
61 |
+
<|im_start|>assistant
|
62 |
+
ํ๋ก์ธ์ค๋ ์ด์ ์ฒด์ ๊ฐ ์คํ ์ค์ธ ํ๋ก๊ทธ๋จ์ผ๋ก, ํ๋ก์ธ์ค ID(PID)๋ผ๋ ๊ณ ์ ํ ์๋ณ์๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค.
|
63 |
+
ํ๋ก์ธ์ค๊ฐ ์ข
๋ฃ๋๋ฉด ์์คํ
์์์ด ํด์ ๋ฉ๋๋ค. ๋ฆฌ๋
์ค์ ๊ฒฝ์ฐ kill ๋ช
๋ น์ด๋ฅผ ํตํด ํ๋ก์ธ์ค๋ฅผ ์ข
๋ฃํ ์ ์์ผ๋ฉฐ, ์ด ๋ช
๋ น์ด๋ PID ๋๋ ์ด๋ฆ๊ณผ ๊ฐ์ ๋ค์ํ ๋ฐฉ๋ฒ์ผ๋ก ํ๋ก์ธ์ค๋ฅผ ์ฐพ์์ ์ข
๋ฃ์ํฌ ์ ์์ต๋๋ค.
|
64 |
+
๋ํ SIGKILL ์ ํธ๋ฅผ ๋ณด๋ด๊ฑฐ๋ -9 ์ต์
์ ์ฌ์ฉํ๋ฉด ๊ฐ์ ์ ์ผ๋ก ํ๋ก์ธ์ค๋ฅผ ์ข
๋ฃํ ์๋ ์์ต๋๋ค.
|
65 |
+
๊ทธ๋ฌ๋ ์ผ๋ถ ํ๋ก์ธ์ค๋ ๊ฐ์ ์ข
๋ฃ๋ ๋ ๋ฌธ์ ๋ฅผ ์ผ์ผํฌ ์ ์์ผ๋ฏ๋ก ์ฃผ์ํด์ ์ฌ์ฉํด์ผ ํฉ๋๋ค.<|im_end|>
|
66 |
+
```
|