youjunhyeok
commited on
Commit
•
2a1bebd
1
Parent(s):
8c52aca
Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,162 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
tags:
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
|
|
|
7 |
|
8 |
-
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
|
|
|
|
17 |
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
tags:
|
4 |
+
- llama-factory
|
5 |
+
license: apache-2.0
|
6 |
---
|
7 |
|
8 |
+
## Model
|
9 |
+
- base model: [meta-llama/Meta-Llama-3-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct)
|
10 |
|
11 |
+
## Dataset
|
12 |
+
- [youjunhyeok/llama3_train](https://huggingface.co/datasets/youjunhyeok/llama3_train)
|
13 |
|
14 |
+
## Load Model
|
15 |
|
16 |
+
Use the following Python code to load the model:
|
17 |
|
18 |
+
```python3
|
19 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
20 |
|
21 |
+
path = 'youjunhyeok/llama3-8b-ko-sft-v1'
|
22 |
|
23 |
+
model = AutoModelForCausalLM.from_pretrained(path)
|
24 |
+
tokenizer = AutoTokenizer.from_pretrained(path)
|
25 |
+
```
|
26 |
|
27 |
+
## Chat
|
28 |
|
29 |
+
```python3
|
30 |
+
def chat(message):
|
31 |
+
messages = [
|
32 |
+
{"role": "system", "content": "당신은 인공지능 어시트턴트입니다. 친절하고 정확한 답변을 해주세요."},
|
33 |
+
{"role": "user", "content": message},
|
34 |
+
]
|
|
|
35 |
|
36 |
+
input_ids = tokenizer.apply_chat_template(
|
37 |
+
messages,
|
38 |
+
add_generation_prompt=True,
|
39 |
+
return_tensors="pt"
|
40 |
+
).to(model.device)
|
41 |
+
|
42 |
+
terminators = [
|
43 |
+
tokenizer.eos_token_id,
|
44 |
+
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
45 |
+
]
|
46 |
+
|
47 |
+
outputs = model.generate(
|
48 |
+
input_ids,
|
49 |
+
max_new_tokens=512,
|
50 |
+
eos_token_id=terminators,
|
51 |
+
do_sample=True,
|
52 |
+
temperature=0.6,
|
53 |
+
top_p=0.9,
|
54 |
+
)
|
55 |
+
response = outputs[0][input_ids.shape[-1]:]
|
56 |
+
print(tokenizer.decode(response, skip_special_tokens=True))
|
57 |
+
|
58 |
+
chat('근로자가 부당해고를 당했을 때 구제받기 위한 절차와 요건은 무엇인가?')
|
59 |
+
```
|
60 |
+
|
61 |
+
## Output
|
62 |
+
|
63 |
+
```
|
64 |
+
근로자가 부당해고를 당했을 때 구제받기 위한 절차와 요건은 다음과 같습니다:
|
65 |
+
|
66 |
+
1. 근로자: 근로자는 부당해고를 당한 경우, 근로기준법 등 관련 법률에 따라 구제를 받을 수 있습니다.
|
67 |
+
|
68 |
+
2. 부당해고: 부당해고란, 근로자에게 적법한 절차를 거치지 않고 해고된 경우를 말합니다. 근로기준법 등 관련 법률에 따라 부당해고의 기준과 구제절차가 정해져 있습니다.
|
69 |
+
|
70 |
+
3. 구제절차: 근로자가 부당해고를 당한 경우, 다음과 같은 구제절차를 거칠 수 있습니다:
|
71 |
+
|
72 |
+
- 근로기준법 제28조에 따라 근로자에게 부당해고를 당한 경우, 근로기준법상 부당해고를 받은 근로자는 근로감독관에게 신고할 수 있습니다. 근로감독관은 근로자에게 구제를 제공하고, 근로자에게 부당해고를 당한 경우에 대한 적법한 절차를 수행합니다.
|
73 |
+
|
74 |
+
- 근로기준법 제30조에 따라 근로자는 근로감독관에게 구제를 요청할 수 있습니다. 근로감독관은 근로자의 요청에 따라 구제를 제공하고, 근로자에게 부당해고를 당한 경우에 대한 적법한 절차를 수행합니다.
|
75 |
+
|
76 |
+
4. 요건: 근로자가 구제를 받기 위해서는 다음과 같은 요건을 충족해야 합니다:
|
77 |
+
|
78 |
+
- 근로자: 근로자는 근로기준법 등 관련 법률에 따라 근로자로 정의되는 경우에 구제를 받을 수 있습니다.
|
79 |
+
|
80 |
+
- 부당해고: 근로자는 부당해고를 당한 경우에 구제를 받을 수 있습니다. 부당해고란, 근로기준법 등 관련 법률에 따라 정의된 경우에 해당합니다.
|
81 |
+
|
82 |
+
- 구제절차: 근로자는 구제절차를 거쳐야 합니다. 구제절차는 근로기준법 등 관련 법률에 따라 정의된 경우에 해당합니다.
|
83 |
+
|
84 |
+
요약하면, 근로자가 부당해고를 당했을 때 구제받기 위해서는 근로기준법 등 관련 법률에 따라 구제절차를 거치고, 근로
|
85 |
+
```
|
86 |
+
|
87 |
+
## BenchMark (KOR)
|
88 |
+
|
89 |
+
```
|
90 |
+
# alias
|
91 |
+
A = youjunhyeok/llama3-8b-ko-sft-v1
|
92 |
+
B = DavidAhn/Llama-3-8B-slerp-262k
|
93 |
+
C = meta-llama/Meta-Llama-3-8B
|
94 |
+
D = chihoonlee10/T3Q-ko-solar-dpo-v7.0 (24.05.24 ko 리더보드 1등)
|
95 |
+
```
|
96 |
+
|
97 |
+
| Benchmark (macro_f1) | A | B | C | D |
|
98 |
+
|---------------------------|:----:|:----:|:----:|:----:|
|
99 |
+
| kobest_boolq (0-shot) | 84.7 | 33.5 | 38.2 | 34.1 |
|
100 |
+
| kobest_boolq (5-shot) | 85.4 | 68.8 | 83.8 | 93.1 |
|
101 |
+
| kobest_copa (0-shot) | 60.6 | 58.5 | 63.1 | 81.0 |
|
102 |
+
| kobest_copa (5-shot) | 67.2 | 61.7 | 69.1 | 91.0 |
|
103 |
+
| kobest_hellaswag (0-shot) | 40.0 | 43.2 | 42.1 | 55.1 |
|
104 |
+
| kobest_hellaswag (5-shot) | 42.4 | 45.3 | 44.2 | 55.2 |
|
105 |
+
| kobest_sentineg (0-shot) | 52.1 | 34.8 | 51.5 | 82.7 |
|
106 |
+
| kobest_sentineg (5-shot) | 89.4 | 85.8 | 94.7 | 91.4 |
|
107 |
+
|
108 |
+
## BenchMark (ENG)
|
109 |
+
|
110 |
+
```
|
111 |
+
# alias
|
112 |
+
A = youjunhyeok/llama3-8b-ko-sft-v1
|
113 |
+
B = DavidAhn/Llama-3-8B-slerp-262k
|
114 |
+
C = meta-llama/Meta-Llama-3-8B
|
115 |
+
```
|
116 |
+
|
117 |
+
| | A | B | C |
|
118 |
+
|:--------------|------:|------:|------:|
|
119 |
+
| openbookqa | 0.342 | 0.312 | 0.338 |
|
120 |
+
| hellaswag | 0.555 | 0.587 | 0.576 |
|
121 |
+
| boolq | 0.824 | 0.832 | 0.831 |
|
122 |
+
| arc_easy | 0.758 | 0.808 | 0.815 |
|
123 |
+
| arc_challenge | 0.464 | 0.518 | 0.529 |
|
124 |
+
|
125 |
+
## Llama_factory Train Command
|
126 |
+
{data_dir}, {dataset_name}, {output_dir} is variable
|
127 |
+
```
|
128 |
+
llamafactory-cli train \
|
129 |
+
--stage sft \
|
130 |
+
--do_train True \
|
131 |
+
--model_name_or_path meta-llama/Meta-Llama-3-8B-Instruct \
|
132 |
+
--preprocessing_num_workers 16 \
|
133 |
+
--finetuning_type lora \
|
134 |
+
--template llama3 \
|
135 |
+
--flash_attn auto \
|
136 |
+
--dataset_dir {data_dir} \
|
137 |
+
--dataset {dataset_name} \
|
138 |
+
--cutoff_len 1024 \
|
139 |
+
--learning_rate 5e-05 \
|
140 |
+
--num_train_epochs 2.0 \
|
141 |
+
--max_samples 400000 \
|
142 |
+
--per_device_train_batch_size 8 \
|
143 |
+
--gradient_accumulation_steps 8 \
|
144 |
+
--lr_scheduler_type cosine \
|
145 |
+
--max_grad_norm 1.0 \
|
146 |
+
--logging_steps 50 \
|
147 |
+
--save_steps 1000 \
|
148 |
+
--warmup_steps 1000 \
|
149 |
+
--optim adamw_torch \
|
150 |
+
--resize_vocab True \
|
151 |
+
--packing False \
|
152 |
+
--report_to none \
|
153 |
+
--output_dir {output_dir} \
|
154 |
+
--fp16 True \
|
155 |
+
--plot_loss True \
|
156 |
+
--ddp_timeout 180000000 \
|
157 |
+
--include_num_input_tokens_seen True \
|
158 |
+
--lora_rank 8 \
|
159 |
+
--lora_alpha 16 \
|
160 |
+
--lora_dropout 0.05 \
|
161 |
+
--lora_target all
|
162 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|