Text Generation
Transformers
Safetensors
English
llama
alignment-handbook
trl
dpo
Generated from Trainer
conversational
text-generation-inference
Inference Endpoints
Edit model card

Magpie

🐦 MagpieLM-4B-v0.1

Project Web: https://magpie-align.github.io/

Arxiv Technical Report: https://arxiv.org/abs/2406.08464

Codes: https://github.com/magpie-align/magpie

🧐 About This Model

Model full name: Llama3.1-MagpieLM-4B-v0.1

This model is an aligned version of Llama-3.1-Minitron-4B-Width. We apply the following pipeline:

We first perform SFT using:

We then perform DPO on the Magpie-Align/Llama-3.1-70B-PO-100K-armorm dataset.

πŸ”₯ Benchmark Performance

Greedy Decoding

  • MT-Bench: 7.83 (First Turn), 7.22 (Second Turn), 7.52 (Average)
  • Alpaca Eval 2: 31.36 (LC), 36.80 (WR)
  • Arena Hard: 19.4
  • WildBench WB Score (v2.0625): 29.00

πŸ‘€ Other Information

License: Please follow NVIDIA Open Model License Agreement (Model) and Meta Llama 3.1 Community License (Data).

Conversation Template: Please use Llama 3 official chat template for the best performance.

How to use it? Please check the official Llama 3.1 repository for detailed instructions. Simply replace the original model_id with this model id.


Alignment Pipeline

The detailed alignment pipeline is as follows.

Stage 1: Supervised Fine-tuning

We use Axolotl for SFT. Please refer to the model card of SFT checkpoint for detailed configurations.

Stage 2: Direct Preference Optimization

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 3e-07
  • train_batch_size: 2
  • eval_batch_size: 4
  • seed: 42
  • distributed_type: multi-GPU
  • num_devices: 8
  • gradient_accumulation_steps: 8
  • total_train_batch_size: 128
  • total_eval_batch_size: 32
  • optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • lr_scheduler_type: cosine
  • lr_scheduler_warmup_ratio: 0.1
  • num_epochs: 1

Training results

Training Loss Epoch Step Validation Loss Rewards/chosen Rewards/rejected Rewards/accuracies Rewards/margins Logps/rejected Logps/chosen Logits/rejected Logits/chosen
0.6765 0.1306 100 0.6767 -0.0176 -0.0553 0.6944 0.0377 -422.8870 -410.7495 -1.9745 -2.0046
0.6319 0.2612 200 0.5401 -1.5893 -2.3197 0.7738 0.7304 -649.3265 -567.9156 -1.9588 -1.9858
0.4322 0.3918 300 0.4713 -2.4056 -3.7253 0.7937 1.3197 -789.8882 -649.5492 -1.9373 -1.9639
0.4339 0.5224 400 0.4453 -2.8370 -4.6277 0.8254 1.7907 -880.1238 -692.6865 -1.9365 -1.9629
0.3609 0.6531 500 0.4306 -3.1155 -5.1210 0.8532 2.0055 -929.4611 -720.5439 -1.9284 -1.9550
0.3775 0.7837 600 0.4235 -3.0531 -5.0110 0.8571 1.9579 -918.4553 -714.3006 -1.9343 -1.9605
0.3957 0.9143 700 0.4210 -3.0004 -4.9487 0.8651 1.9483 -912.2261 -709.0248 -1.9343 -1.9603

Framework versions

  • Transformers 4.45.0.dev0
  • Pytorch 2.3.1+cu121
  • Datasets 2.20.0
  • Tokenizers 0.19.1
See alignment handbook config
model_name_or_path: Magpie-Align/MagpieLM-4B-SFT-v0.1
hub_model_id: Magpie-Align/Llama3.1-MagpieLM-4B-v0.1
output_dir: alignment_handbook_out/Llama3.1-MagpieLM-4B-v0.1
run_name: Llama3.1-MagpieLM-4B-v0.1

dataset_mixer:
  Magpie-Align/Magpie-Llama-3.1-Pro-DPO-100K-v0.1: 1.0
dataset_splits:
- train
- test
preprocessing_num_workers: 24

# DPOTrainer arguments
bf16: true
beta: 0.01
learning_rate: 0.3e-6
gradient_accumulation_steps: 8
per_device_train_batch_size: 2
per_device_eval_batch_size: 4
num_train_epochs: 1
max_length: 2048
max_prompt_length: 1800
warmup_ratio: 0.1
logging_steps: 1
lr_scheduler_type: cosine
optim: adamw_torch

torch_dtype: null
use_flash_attention_2: true
do_eval: true
evaluation_strategy: steps
eval_steps: 100
gradient_checkpointing: true
gradient_checkpointing_kwargs:
  use_reentrant: False
log_level: info
push_to_hub: true
save_strategy: "steps"
save_steps: 100
save_total_limit: 1
seed: 42
report_to:
- wandb

Paper Abstract

Click Here 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.

πŸ“š Citation

If you find the model, data, or code useful, please cite our paper:

@article{xu2024magpie,
    title={Magpie: Alignment Data Synthesis from Scratch by Prompting Aligned LLMs with Nothing}, 
    author={Zhangchen Xu and Fengqing Jiang and Luyao Niu and Yuntian Deng and Radha Poovendran and Yejin Choi and Bill Yuchen Lin},
    year={2024},
    eprint={2406.08464},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}

Please also cite the reward model for creating preference datasets:

ArmoRM paper:

@article{wang2024interpretable,
  title={Interpretable Preferences via Multi-Objective Reward Modeling and Mixture-of-Experts},
  author={Wang, Haoxiang and Xiong, Wei and Xie, Tengyang and Zhao, Han and Zhang, Tong},
  journal={arXiv preprint arXiv:2406.12845},
  year={2024}
}

Questions? Please contact Zhangchen by email.

Downloads last month
49
Safetensors
Model size
4.51B params
Tensor type
BF16
Β·
Inference API
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Model tree for Magpie-Align/MagpieLM-4B-v0.1

Finetuned
this model
Quantizations
1 model

Datasets used to train Magpie-Align/MagpieLM-4B-v0.1

Collection including Magpie-Align/MagpieLM-4B-v0.1