RichardErkhov commited on
Commit
e17bef7
·
verified ·
1 Parent(s): 08ccce3

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +369 -0
README.md ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ Llama-3-8B-Magpie-Align-v0.1 - bnb 4bits
11
+ - Model creator: https://huggingface.co/Magpie-Align/
12
+ - Original model: https://huggingface.co/Magpie-Align/Llama-3-8B-Magpie-Align-v0.1/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ license: llama3
20
+ base_model: Magpie-Align/Llama-3-8B-Magpie-Align-SFT-v0.1
21
+ tags:
22
+ - alignment-handbook
23
+ - axolotl
24
+ - trl
25
+ - dpo
26
+ - sft
27
+ - generated_from_trainer
28
+ datasets:
29
+ - princeton-nlp/llama3-ultrafeedback
30
+ - Magpie-Align/Magpie-Pro-MT-300K-v0.1
31
+ model-index:
32
+ - name: Llama-3-8B-Magpie-Align-v0.1
33
+ results: []
34
+ language:
35
+ - en
36
+ ---
37
+
38
+ [![Magpie](magpie_logo.png)](https://huggingface.co/spaces/flydust/Chat-with-Magpie)
39
+ ## 🔥 Chat with Magpie [Here](https://huggingface.co/spaces/flydust/Chat-with-Magpie)!
40
+
41
+ # 🐦 Llama-3-8B-Magpie-Align-v0.1
42
+
43
+ Project Web: [https://magpie-align.github.io/](https://magpie-align.github.io/)
44
+
45
+ Online Model Demo: [https://huggingface.co/spaces/flydust/Chat-with-Magpie](https://huggingface.co/spaces/flydust/Chat-with-Magpie)
46
+
47
+ Arxiv Technical Report: [https://arxiv.org/abs/2406.08464](https://arxiv.org/abs/2406.08464)
48
+
49
+ Codes: [https://github.com/magpie-align/magpie](https://github.com/magpie-align/magpie)
50
+
51
+ ## Model Overview
52
+
53
+ This model is an aligned version of [meta-llama/Meta-Llama-3-8B](https://huggingface.co/meta-llama/Meta-Llama-3-8B). We apply the following pipeline:
54
+ - We first use [Magpie-Align/Magpie-Pro-MT-300K-v0.1](https://huggingface.co/datasets/Magpie-Align/Magpie-Pro-MT-300K-v0.1) dataset and perform SFT -> [Magpie-Align/Llama-3-8B-Magpie-Align-SFT-v0.1](https://huggingface.co/Magpie-Align/Llama-3-8B-Magpie-Align-SFT-v0.1)
55
+ - We then perform DPO on the [princeton-nlp/llama3-ultrafeedback](https://huggingface.co/datasets/princeton-nlp/llama3-ultrafeedback) dataset.
56
+
57
+ The overall performance is even better than the official Llama-3-8B-Instruct Model!
58
+
59
+ - **Alpaca Eval 2 (vs GPT-4-Turbo-1106): 38.52 (LC), 38.47 (WR)**
60
+ - **Alpaca Eval 2 (vs Llama-3-8B-Instruct): 69.37 (LC), 70.05 (WR)**
61
+ - **Arena Hard: 32.4**
62
+ - **WildBench: 39.3 ((was) Best <30B Model! 🏆)**
63
+ - **Zero-Eval GSM: 54.62**
64
+
65
+ ## Model Performance
66
+
67
+ We compare our Llama-3-8B-Magpie-Align with official and other **open-aligned LLMs** that have been fine-tuned from base models and have publicly released their training datasets. The results are as follows:
68
+
69
+ ```
70
+ +---------------------------------------------+--------------------+--------------------+-----------------------+------------+
71
+ | Aligned Model ID | MT-Bench | Alpaca Eval 2 | Alpaca Eval 2 | Arena Hard |
72
+ | | | (GPT-4-Turbo-1106) | (Llama-3-8B-Instruct) | |
73
+ +---------------------------------------------+------+------+------+----------+---------+-----------+-----------+------------+
74
+ | | R1 | R2 | AVG | LC WR | WR | LC WR | WR | Score |
75
+ +---------------------------------------------+------+------+------+----------+---------+-----------+-----------+------------+
76
+ | meta-llama/Meta-Llama-3-8B-Instruct | 8.31 | 7.65 | 7.98 | 22.92 | 22.57 | 50 | 50 | 20.6 |
77
+ +---------------------------------------------+------+------+------+----------+---------+-----------+-----------+------------+
78
+ | princeton-nlp/Llama-3-Base-8B-SFT-DPO | 8.12 | 7.23 | 7.67 | 17.71 | 15.34 | 43.73 | 38.80 | 14.8 |
79
+ +---------------------------------------------+------+------+------+----------+---------+-----------+-----------+------------+
80
+ | NousResearch/Hermes-2-Pro-Llama-3-8B | 8.05 | 7.35 | 7.70 | 15.60 | 12.86 | 36.37 | 30.52 | 11.5 |
81
+ +---------------------------------------------+------+------+------+----------+---------+-----------+-----------+------------+
82
+ | allenai/llama-3-tulu-2-dpo-8b | 7.71 | 7.15 | 7.43 | 14.89 | 14.80 | 35.43 | 35.42 | 11.7 |
83
+ +---------------------------------------------+------+------+------+----------+---------+-----------+-----------+------------+
84
+ | cognitivecomputations/dolphin-2.9-llama3-8b | 7.97 | 6.98 | 7.47 | 12.50 | 8.79 | 32.67 | 22.80 | 8.2 |
85
+ +---------------------------------------------+------+------+------+----------+---------+-----------+-----------+------------+
86
+ | openchat/openchat-3.6-8b-20240522 | 7.83 | 7.23 | 7.53 | 17.70 | 12.53 | 41.30 | 30.79 | 6.7 |
87
+ +---------------------------------------------+------+------+------+----------+---------+-----------+-----------+------------+
88
+ | Magpie-Align/Llama-3-8B-Magpie-Align-v0.1 | 8.01 | 7.63 | 7.82 | 38.52 | 38.47 | 69.37 | 70.05 | 32.4 |
89
+ +---------------------------------------------+------+------+------+----------+---------+-----------+-----------+------------+
90
+ | Magpie-Align/Llama-3-8B-Magpie-Align-v0.2 | 7.81 | 7.64 | 7.73 | 49.86 | 51.98 | 75.17 | 78.20 | 37.5 |
91
+ +---------------------------------------------+------+------+------+----------+---------+-----------+-----------+------------+
92
+
93
+ ```
94
+
95
+ ## 👀 Other Information
96
+
97
+ **License**: Please follow [Meta Llama 3 Community License](https://llama.meta.com/llama3/license).
98
+
99
+ **Conversation Template**: Please use Llama 3 **official chat template** for the best performance.
100
+
101
+ **How to use it?** Please check the official [Llama 3 repository](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct#how-to-use) for detailed instructions. Simply replace the original `model_id` with `Magpie-Align/Llama-3-8B-Magpie-Align-v0.1`.
102
+
103
+ The detailed training pipeline is as follows.
104
+
105
+ ## Stage 1: Supervised Fine-tuning
106
+
107
+ We use [Axolotl](https://github.com/OpenAccess-AI-Collective/axolotl) for SFT.
108
+
109
+ ### Training hyperparameters
110
+
111
+ The following hyperparameters were used during training:
112
+ - learning_rate: 2e-05
113
+ - train_batch_size: 1
114
+ - eval_batch_size: 1
115
+ - seed: 42
116
+ - distributed_type: multi-GPU
117
+ - num_devices: 4
118
+ - gradient_accumulation_steps: 8
119
+ - total_train_batch_size: 32
120
+ - total_eval_batch_size: 4
121
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
122
+ - lr_scheduler_type: cosine
123
+ - lr_scheduler_warmup_steps: 100
124
+ - num_epochs: 2
125
+
126
+ ### Training results
127
+
128
+ | Training Loss | Epoch | Step | Validation Loss |
129
+ |:-------------:|:------:|:----:|:---------------:|
130
+ | 0.8807 | 0.0007 | 1 | 0.9001 |
131
+ | 0.5113 | 0.3337 | 464 | 0.5178 |
132
+ | 0.4668 | 0.6673 | 928 | 0.4792 |
133
+ | 0.4492 | 1.0010 | 1392 | 0.4582 |
134
+ | 0.3498 | 1.3205 | 1856 | 0.4575 |
135
+ | 0.3525 | 1.6542 | 2320 | 0.4555 |
136
+
137
+ ### Framework versions
138
+
139
+ - Transformers 4.40.2
140
+ - Pytorch 2.3.0+cu121
141
+ - Datasets 2.19.1
142
+ - Tokenizers 0.19.1
143
+
144
+ [<img src="https://raw.githubusercontent.com/OpenAccess-AI-Collective/axolotl/main/image/axolotl-badge-web.png" alt="Built with Axolotl" width="200" height="32"/>](https://github.com/OpenAccess-AI-Collective/axolotl)
145
+ <details><summary>See axolotl config</summary>
146
+
147
+ axolotl version: `0.4.0`
148
+ ```yaml
149
+
150
+ base_model: meta-llama/Meta-Llama-3-8B
151
+ model_type: LlamaForCausalLM
152
+ tokenizer_type: AutoTokenizer
153
+
154
+ load_in_8bit: false
155
+ load_in_4bit: false
156
+ strict: false
157
+
158
+ datasets:
159
+ - path: Magpie-Align/Magpie-Pro-MT-300K-v0.1
160
+ type: sharegpt
161
+ conversation: llama3
162
+ dataset_prepared_path: last_run_prepared
163
+ val_set_size: 0.001
164
+ output_dir: ./out_Llama-3-8B-Magpie-Pro-300K-MT
165
+
166
+ sequence_len: 8192
167
+ sample_packing: true
168
+ eval_sample_packing: false
169
+ pad_to_sequence_len: true
170
+
171
+ gradient_accumulation_steps: 8
172
+ micro_batch_size: 1
173
+ num_epochs: 2
174
+ optimizer: paged_adamw_8bit
175
+ lr_scheduler: cosine
176
+ learning_rate: 2e-5
177
+
178
+ train_on_inputs: false
179
+ group_by_length: false
180
+ bf16: auto
181
+ fp16:
182
+ tf32: false
183
+
184
+ gradient_checkpointing: true
185
+ gradient_checkpointing_kwargs:
186
+ use_reentrant: false
187
+ early_stopping_patience:
188
+ resume_from_checkpoint:
189
+ logging_steps: 1
190
+ xformers_attention:
191
+ flash_attention: true
192
+
193
+ warmup_steps: 100
194
+ evals_per_epoch: 3
195
+ eval_table_size:
196
+ saves_per_epoch: 3
197
+ debug:
198
+ deepspeed:
199
+ weight_decay: 0.0
200
+ fsdp:
201
+ fsdp_config:
202
+ special_tokens:
203
+ pad_token: <|end_of_text|>
204
+
205
+ ```
206
+
207
+ </details><be>
208
+
209
+ ## Stage 2: Direct Preference Optimization
210
+
211
+ We use [alignment handbook](https://github.com/huggingface/alignment-handbook) for DPO.
212
+
213
+ ### Training hyperparameters
214
+
215
+ The following hyperparameters were used during training:
216
+ - learning_rate: 1e-06
217
+ - train_batch_size: 2
218
+ - eval_batch_size: 4
219
+ - seed: 42
220
+ - distributed_type: multi-GPU
221
+ - num_devices: 4
222
+ - gradient_accumulation_steps: 16
223
+ - total_train_batch_size: 128
224
+ - total_eval_batch_size: 16
225
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
226
+ - lr_scheduler_type: cosine
227
+ - lr_scheduler_warmup_ratio: 0.1
228
+ - num_epochs: 1
229
+
230
+ ### Training results
231
+
232
+ | Training Loss | Epoch | Step | Validation Loss | Rewards/chosen | Rewards/rejected | Rewards/accuracies | Rewards/margins | Logps/rejected | Logps/chosen | Logits/rejected | Logits/chosen |
233
+ |:-------------:|:------:|:----:|:---------------:|:--------------:|:----------------:|:------------------:|:---------------:|:--------------:|:------------:|:---------------:|:-------------:|
234
+ | 0.628 | 0.2138 | 100 | 0.6641 | -0.8806 | -1.0146 | 0.6240 | 0.1340 | -362.7133 | -343.6060 | -0.7539 | -0.7528 |
235
+ | 0.6935 | 0.4275 | 200 | 0.6352 | -1.3660 | -1.6311 | 0.6545 | 0.2651 | -424.3628 | -392.1437 | -0.6649 | -0.6629 |
236
+ | 0.6376 | 0.6413 | 300 | 0.6178 | -1.3533 | -1.6413 | 0.6748 | 0.2880 | -425.3859 | -390.8818 | -0.6753 | -0.6758 |
237
+ | 0.5888 | 0.8550 | 400 | 0.6088 | -1.6321 | -1.9785 | 0.6829 | 0.3464 | -459.1051 | -418.7560 | -0.6440 | -0.6435 |
238
+
239
+ It achieves the following results on the evaluation set:
240
+ - Loss: 0.6084
241
+ - Rewards/chosen: -1.6265
242
+ - Rewards/rejected: -1.9735
243
+ - Rewards/accuracies: 0.6809
244
+ - Rewards/margins: 0.3470
245
+ - Logps/rejected: -458.6070
246
+ - Logps/chosen: -418.2021
247
+ - Logits/rejected: -0.6447
248
+ - Logits/chosen: -0.6439
249
+
250
+ ### Framework versions
251
+
252
+ - Transformers 4.41.2
253
+ - Pytorch 2.3.1+cu121
254
+ - Datasets 2.20.0
255
+ - Tokenizers 0.19.1
256
+
257
+ <details><summary>See alignment handbook config</summary>
258
+
259
+ ```yaml
260
+
261
+ # Model arguments
262
+ model_name_or_path: Magpie-Align/Llama-3-8B-Magpie-Pro-MT-SFT-v0.1
263
+ torch_dtype: null
264
+
265
+ # Data training arguments
266
+ # For definitions, see: src/h4/training/config.py
267
+ dataset_mixer:
268
+ princeton-nlp/llama3-ultrafeedback: 1.0
269
+ dataset_splits:
270
+ - train
271
+ - test
272
+ preprocessing_num_workers: 12
273
+
274
+ # DPOTrainer arguments
275
+ bf16: true
276
+ beta: 0.01
277
+ do_eval: true
278
+ evaluation_strategy: steps
279
+ eval_steps: 100
280
+ gradient_accumulation_steps: 16
281
+ gradient_checkpointing: true
282
+ gradient_checkpointing_kwargs:
283
+ use_reentrant: False
284
+ hub_model_id: Magpie-Align/Llama-3-8B-Magpie-Pro-MT-UltraDPO2
285
+ learning_rate: 1.0e-6
286
+ log_level: info
287
+ logging_steps: 1
288
+ lr_scheduler_type: cosine
289
+ max_length: 2048
290
+ max_prompt_length: 1800
291
+ num_train_epochs: 1
292
+ optim: adamw_torch
293
+ output_dir: data/magpie-pro-mt-ultradpo-1e-6
294
+ per_device_train_batch_size: 2
295
+ per_device_eval_batch_size: 4
296
+ push_to_hub: true
297
+ save_strategy: "steps"
298
+ save_steps: 100
299
+ save_total_limit: 1
300
+ seed: 42
301
+ warmup_ratio: 0.1
302
+
303
+ ```
304
+
305
+ </details><be>
306
+
307
+ ## Downstream Performance
308
+ | Datasets | Llama-3-8B-Magpie-Align-v0.1 |
309
+ | :--- | :---: |
310
+ | MMLU (5) | 64.61 |
311
+ | ARC (25) | 62.03 |
312
+ | HellaSwag (25) | 82.10 |
313
+ | TruthfulQA (0) | 58.26 |
314
+ | Winogrande (5) | 73.01 |
315
+
316
+ ## Paper Abstract
317
+
318
+ <details><summary>Click Here</summary>
319
+ High-quality instruction data is critical for aligning large language models (LLMs). Although some models, such as Llama-3-Instruct, have open weights, their alignment data remain private, which hinders the democratization of AI. High human labor costs and a limited, predefined scope for prompting prevent existing open-source data creation methods from scaling effectively, potentially limiting the diversity and quality of public alignment datasets. Is it possible to synthesize high-quality instruction data at scale by extracting it directly from an aligned LLM? We present a self-synthesis method for generating large-scale alignment data named Magpie. Our key observation is that aligned LLMs like Llama-3-Instruct can generate a user query when we input only the left-side templates up to the position reserved for user messages, thanks to their auto-regressive nature. We use this method to prompt Llama-3-Instruct and generate 4 million instructions along with their corresponding responses. We perform a comprehensive analysis of the extracted data and select 300K high-quality instances. To compare Magpie data with other public instruction datasets, we fine-tune Llama-3-8B-Base with each dataset and evaluate the performance of the fine-tuned models. Our results indicate that in some tasks, models fine-tuned with Magpie perform comparably to the official Llama-3-8B-Instruct, despite the latter being enhanced with 10 million data points through supervised fine-tuning (SFT) and subsequent feedback learning. We also show that using Magpie solely for SFT can surpass the performance of previous public datasets utilized for both SFT and preference optimization, such as direct preference optimization with UltraFeedback. This advantage is evident on alignment benchmarks such as AlpacaEval, ArenaHard, and WildBench.
320
+ </details><be>
321
+
322
+ ## 📚 Citation
323
+
324
+ If you find the model, data, or code useful, please cite our paper:
325
+ ```
326
+ @article{xu2024magpie,
327
+ title={Magpie: Alignment Data Synthesis from Scratch by Prompting Aligned LLMs with Nothing},
328
+ author={Zhangchen Xu and Fengqing Jiang and Luyao Niu and Yuntian Deng and Radha Poovendran and Yejin Choi and Bill Yuchen Lin},
329
+ year={2024},
330
+ eprint={2406.08464},
331
+ archivePrefix={arXiv},
332
+ primaryClass={cs.CL}
333
+ }
334
+ ```
335
+
336
+ Please also cite the creators of preference datasets:
337
+
338
+ SimPO paper:
339
+ ```
340
+ @article{meng2024simpo,
341
+ title={{SimPO}: Simple preference optimization with a reference-free reward},
342
+ author={Meng, Yu and Xia, Mengzhou and Chen, Danqi},
343
+ journal={arXiv preprint arXiv:2405.14734},
344
+ year={2024}
345
+ }
346
+ ```
347
+
348
+ UltraFeedback paper:
349
+ ```
350
+ @article{cui2023ultrafeedback,
351
+ title={{UltraFeedback}: Boosting language models with high-quality feedback},
352
+ author={Cui, Ganqu and Yuan, Lifan and Ding, Ning and Yao, Guanming and Zhu, Wei and Ni, Yuan and Xie, Guotong and Liu, Zhiyuan and Sun, Maosong},
353
+ journal={arXiv preprint arXiv:2310.01377},
354
+ year={2023}
355
+ }
356
+ ```
357
+
358
+ ArmoRM paper:
359
+ ```
360
+ @article{wang2024interpretable,
361
+ title={Interpretable Preferences via Multi-Objective Reward Modeling and Mixture-of-Experts},
362
+ author={Wang, Haoxiang and Xiong, Wei and Xie, Tengyang and Zhao, Han and Zhang, Tong},
363
+ journal={arXiv preprint arXiv:2406.12845},
364
+ year={2024}
365
+ }
366
+ ```
367
+
368
+ **Questions?** Please contact [Zhangchen](https://zhangchenxu.com/) by email.
369
+