---
title: "Direct Preference Optimization (DPO) — 直接偏好优化"
source: "https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96"
wiki: "systems-analysis.info/int"
article: "Direct_Preference_Optimization_(DPO)_—_直接偏好优化"
language: "zh"
categories:
  - "Category:Chinese"
  - "Category:Large language models"
  - "Category:Machine learning"
revision_id: 1720
wiki_created_at: 2026-09-06T22:52:59Z
wiki_modified_at: 2026-09-06T22:52:59Z
downloaded_at: 2026-09-07T22:47:25Z
---

# Direct Preference Optimization (DPO) — 直接偏好优化

**Direct Preference Optimization** (**DPO**) 是一种将大型语言模型（LLM）与人类偏好对齐的方法，作为基于人类反馈的强化学习（RLHF）的一种更简单、更稳定的替代方案。该方法由斯坦福大学以Rafael Rafailov为首的一组研究人员于2023年提出<sup>[\[1\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-dpo_paper_2023-1)</sup>。

DPO的关键区别在于，它直接优化语言模型以符合人类偏好，无需明确训练一个独立的**奖励模型**（reward model）和复杂的强化学习（RL）阶段，从而使LLM的微调过程显著简化、加快且更稳定<sup>[\[2\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-huggingface_dpo-2)</sup>。

## 背景：RLHF的局限性

标准方法**Reinforcement Learning from Human Feedback** (**RLHF**) 包括三个主要阶段：

1.  **Supervised Fine-Tuning (SFT)**: 在高质量的示例上对模型进行基础微调。
2.  **训练奖励模型**：创建一个独立模型，该模型基于人类提供的成对比较（例如，答案A优于答案B）来学习为答案分配“评分”。
3.  **使用RL优化策略**：使用RL算法（如PPO）对主模型进行微调，使其生成的答案能够最大化奖励模型给出的评分。

尽管RLHF很有效，但它是一个复杂、昂贵且不稳定的过程。它容易出现**reward hacking**（即模型“欺骗”奖励模型）等问题，并且需要仔细调整众多超参数<sup>[\[1\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-dpo_paper_2023-1)</sup>。DPO的开发旨在克服这些限制。

## DPO工作原理

DPO方法将RLHF的多阶段流程替换为单个训练阶段，可视为一种监督式微调。

1.  **收集偏好数据**。与RLHF一样，首先收集一个数据集，其中对于每个查询\`x\`，都有两个答案：一个偏好的答案（\`y_w\`，winning）和一个被拒绝的答案（\`y_l\`，losing）。
2.  **直接优化**。DPO不训练奖励模型，而是直接使用这些数据来更新语言模型本身。优化目标是增加生成偏好答案\`y_w\`的概率，同时降低生成被拒绝答案\`y_l\`的概率。

在数学上，这归结为最小化一个损失函数，该函数基于应用于答案对数概率之差的逻辑回归。为了防止模型“忘记”其初始知识，DPO与RLHF一样，使用一个**参考模型**（*reference model*，通常是SFT版本）进行正则化，以防止其偏离原始答案分布过远<sup>[\[2\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-huggingface_dpo-2)</sup>。

## 与RLHF相比的优势

- **简洁性与稳定性**：DPO无需训练独立的奖励模型和进行复杂的RL调优。整个过程更简单、可预测，且不易出错<sup>[\[3\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-superannotate_dpo-3)</sup>。
- **效率与速度**：由于省去了两个阶段，DPO显著减少了计算开销（GPU小时）和模型微调所需的时间。据估计，DPO比RLHF节省50–60%的成本<sup>[\[4\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-arbisoft_dpo-4)</sup>。
- **结果质量**：实验表明，DPO在质量上不亚于RLHF，在某些任务（如控制回答的语气）中甚至更胜一筹。通过DPO训练的模型能更好地符合人类偏好<sup>[\[1\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-dpo_paper_2023-1)</sup>。
- **不削弱基础能力**：DPO微调对模型的通用能力（如事实性知识或逻辑推理）影响极小，而RLHF有时可能会降低这些基础指标<sup>[\[5\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-iclr_blog-5)</sup>。

## 应用与推广

由于其高效和简洁，DPO迅速得到了广泛应用。它已被集成到主流的开源库中，如**Hugging Face TRL**和**OpenRLHF**。

许多成功的开源模型都是使用DPO进行微调的，包括**Zephyr-7B**和**TÜLU 2**。这些模型在答案质量评估基准上表现出色，证明了DPO对于大规模模型的有效性<sup>[\[5\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-iclr_blog-5)</sup>。

行业领导者也已将DPO集成到其平台中。例如，微软在其Azure OpenAI服务中增加了对DPO微调的支持，允许用户使用自己的偏好数据对包括GPT-4在内的模型进行自定义<sup>[\[6\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-azure_dpo-6)</sup>。

## 局限性

尽管DPO有诸多优势，但它也继承了基于偏好学习方法本身的一些局限性：

- **数据敏感性**：收集到的偏好数据的质量和多样性至关重要。如果数据存在偏见（例如，只包含一种语言或风格），模型可能会过拟合，导致在其他领域的性能下降<sup>[\[7\]](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_note-toloka_dpo-7)</sup>。
- **静态学习**：与RLHF一样，DPO在静态数据集上进行训练，不涉及与环境的动态交互。该方法适用于单步对齐，但不适用于需要通过一系列行动进行学习的任务。

## 外部链接

- <a href="https://huggingface.co/docs/trl/main/en/dpo_trainer" class="external text" rel="nofollow">Hugging Face TRL库中的DPO文档</a>
- <a href="https://iclr-blogposts.github.io/2024/blog/rlhf-without-rl/" class="external text" rel="nofollow">ICLR 2024博客文章中关于RLHF和DPO的分析性评论</a>

## 参考文献

- Rafailov, R. et al. (2023). *Direct Preference Optimization: Your Language Model is Secretly a Reward Model*. <a href="https://arxiv.org/abs/2305.18290" class="external text" rel="nofollow">arXiv:2305.18290</a>.
- Hong, J.; Lee, N.; Thorne, J. (2024). *ORPO: Monolithic Preference Optimization without Reference Model*. <a href="https://arxiv.org/abs/2403.07691" class="external text" rel="nofollow">arXiv:2403.07691</a>.
- Sun, L. et al. (2025). *BPO: Revisiting Preference Modeling in Direct Preference Optimization*. <a href="https://arxiv.org/abs/2506.03557" class="external text" rel="nofollow">arXiv:2506.03557</a>.
- Yin, Y. et al. (2024). *Self-Augmented Preference Optimization: Off-Policy Paradigms for Language Model Alignment*. <a href="https://arxiv.org/abs/2405.20830" class="external text" rel="nofollow">arXiv:2405.20830</a>.
- Wu, Y. et al. (2024). *Self-Play Preference Optimization for Language Model Alignment*. <a href="https://arxiv.org/abs/2405.00675" class="external text" rel="nofollow">arXiv:2405.00675</a>.
- Li, P. et al. (2024). *ROPO: Robust Preference Optimization for Large Language Models*. <a href="https://arxiv.org/abs/2404.04102" class="external text" rel="nofollow">arXiv:2404.04102</a>.
- Tunstall, L. et al. (2023). *Zephyr: Direct Distillation of LM Alignment*. <a href="https://arxiv.org/abs/2310.16944" class="external text" rel="nofollow">arXiv:2310.16944</a>.
- Wu, F. et al. (2023). *Diffusion-DPO: Diffusion Model Alignment Using Direct Preference Optimization*. <a href="https://arxiv.org/abs/2311.12908" class="external text" rel="nofollow">arXiv:2311.12908</a>.
- Lee, H. et al. (2023). *RLAIF vs. RLHF: Scaling Reinforcement Learning from Human Feedback with AI Feedback*. <a href="https://arxiv.org/abs/2309.00267" class="external text" rel="nofollow">arXiv:2309.00267</a>.
- Rafailov, R.; Sharma, A.; Mitchell, E.; Manning, C. D.; Finn, C. (2024). *Direct Preference Optimization (v3): Enhanced Experiments and Analysis*. <a href="https://arxiv.org/pdf/2305.18290v3" class="external text" rel="nofollow">arXiv:2305.18290v3</a>.

## 注释

1.  <span id="cite_note-dpo_paper_2023-1">↑ <sup>[1.0](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-dpo_paper_2023_1-0)</sup> <sup>[1.1](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-dpo_paper_2023_1-1)</sup> <sup>[1.2](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-dpo_paper_2023_1-2)</sup> Rafailov, R., et al. «Direct Preference Optimization: Your Language Model is Secretly a Reward Model». *arXiv:2305.18290*. <a href="https://arxiv.org/abs/2305.18290" class="external autonumber" rel="nofollow">[1]</a></span>
2.  <span id="cite_note-huggingface_dpo-2">↑ <sup>[2.0](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-huggingface_dpo_2-0)</sup> <sup>[2.1](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-huggingface_dpo_2-1)</sup> «Simplifying Alignment: From RLHF to Direct Preference Optimization (DPO)». *Hugging Face Blog*. <a href="https://huggingface.co/blog/ariG23498/rlhf-to-dpo" class="external autonumber" rel="nofollow">[2]</a></span>
3.  <span id="cite_note-superannotate_dpo-3">[↑](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-superannotate_dpo_3-0) «What is direct preference optimization (DPO)?». *SuperAnnotate Blog*. <a href="https://www.superannotate.com/blog/direct-preference-optimization-dpo" class="external autonumber" rel="nofollow">[3]</a></span>
4.  <span id="cite_note-arbisoft_dpo-4">[↑](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-arbisoft_dpo_4-0) «RLHF vs DPO: A Closer Look into the Process and Methodology». *Arbisoft Blog*. <a href="https://arbisoft.com/blogs/rlhf-vs-dpo-a-closer-look-into-the-process-and-methodology" class="external autonumber" rel="nofollow">[4]</a></span>
5.  <span id="cite_note-iclr_blog-5">↑ <sup>[5.0](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-iclr_blog_5-0)</sup> <sup>[5.1](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-iclr_blog_5-1)</sup> «RLHF without RL - Direct Preference Optimization». *ICLR Blogposts 2024*. <a href="https://iclr-blogposts.github.io/2024/blog/rlhf-without-rl/" class="external autonumber" rel="nofollow">[5]</a></span>
6.  <span id="cite_note-azure_dpo-6">[↑](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-azure_dpo_6-0) «Direct preference optimization». *Azure OpenAI \| Microsoft Learn*. <a href="https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/fine-tuning-direct-preference-optimization" class="external autonumber" rel="nofollow">[6]</a></span>
7.  <span id="cite_note-toloka_dpo-7">[↑](https://systems-analysis.info/int/Direct_Preference_Optimization_(DPO)_%E2%80%94_%E7%9B%B4%E6%8E%A5%E5%81%8F%E5%A5%BD%E4%BC%98%E5%8C%96#cite_ref-toloka_dpo_7-0) «Direct Preference Optimization (DPO): A Lightweight Counterpart to RLHF». *Toloka AI Blog*. <a href="https://toloka.ai/blog/direct-preference-optimization/" class="external autonumber" rel="nofollow">[7]</a></span>
