youjunhyeok commited on
Commit
2a1bebd
1 Parent(s): 8c52aca

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +149 -186
README.md CHANGED
@@ -1,199 +1,162 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
 
4
  ---
5
 
6
- # Model Card for Model ID
 
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
 
9
 
 
10
 
 
11
 
12
- ## Model Details
 
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
 
 
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
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
+ ```