[论文解读] Magpie: Alignment Data Synthesis from Scratch by Prompting Aligned LLMs with Nothing
Magpie 自动通过仅使用预查询模板向对齐的 LLM 提示,自动生成大规模高质量指令数据,产出多达 4 百万条指令并筛选出 300K 条高质量实例用于对开源权重模型进行微调。
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.
研究动机与目标
- 通过减少对人工撰写数据或访问生产模型的 API 的依赖,推动 LLM 对齐数据的民主化。
- 提出一种自我合成方法,直接从对齐的 LLMs 使用预查询模板提取多样化的指令。
- 在无种子提示或种子的情况下生成大规模指令数据集(Magpie-Air 与 Magpie-Pro)以及多轮变体。
- 证明使用 Magpie 数据对开源权重模型进行微调可以优于基线并接近官方对齐模型。
提出的方法
- 仅用预查询模板对齐的 LLM 进行提示以诱发自主指令生成(无种子问题)。
- 利用对齐 LLM 的自回归特性生成多样化指令,直到产生结束序列标记。
- 通过用生成的指令对同一 LLM 进行查询来生成指令-应答对。
- 在无需人工干预的情况下创建 Magpie 数据集(Magpie-Air 与 Magpie-Pro)及多轮变体(Magpie-Air-MT、Magpie-Pro-MT)。
- 应用筛选和分析以选取用于微调的高质量实例(如 300K 的高质量子集)。
- 通过对开源权重模型(Llama-3-8B-base、Qwen1.5-4B/7B)进行微调来评估,并在对齐基准上进行评估。

实验结果
研究问题
- RQ1是否可以直接从对齐的 LLMs 在不需要种子或种子工程的情况下进行大规模高质量指令数据的合成?
- RQ2Magpie 生成的数据集是否使开源权重模型达到或超过在公开基线或私有数据上训练的模型的性能?
- RQ3Magpie 数据的质量、覆盖范围和安全性特征是什么,它们如何影响下游微调?
- RQ4与传统数据创建流程相比,Magpie 是否具成本效益且具可扩展性?
主要发现
- Magpie 可以生成大约 4 百万 条指令和应答,并筛选出 30 万 条高质量子集以实现有效调优。
- 使用 Magpie 数据对 Llama-3-8B-base 进行微调在 AlpacaEval 2 和 Arena-Hard 上的表现优于使用相似数据规模的模型基线。
- 用 Magpie 数据微调的模型可以与官方 Llama-3-8B-Instruct 模型抗衡,尽管后者用于 SFT 和 RLHF 的数据点超过 1,000 万。
- Magpie 数据在对齐基准测试中优于若干公开指令数据集(ShareGPT、Evol Instruct、UltraChat、OpenHermes、WildChat),并且与偏好调优的组合效果良好。
- 将 Magpie 数据应用于 Qwen 基模型时也提升了性能,优于官方指令微调的对应模型。
- 经过筛选后,Magpie 实现了广泛的主题覆盖和高质量指令,安全风险低(<1% 可能有害)。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。