Direct Preference Optimization (DPO)
Volume III, Chapter 13 — Part I. Deriving DPO from the RLHF objective: Bradley-Terry preferences, closed-form optimal policy, implicit reward modeling, and the DPO loss without reinforcement learning.
Prerequisites
Table of Contents
- Learning Objectives
- Prerequisites
- Notation
- Core Intuition
- Preference Data and Bradley-Terry Model
- The RLHF Objective
- Closed-Form Optimal Policy
- Deriving the DPO Loss
- Implicit Reward Model
- DPO vs. RLHF Pipeline
- Worked Examples
- Connection to the Broader Curriculum
- Common Pitfalls and Misconceptions
- Research Perspective
- Summary of Takeaways
- Exercises
Learning Objectives
After reading this chapter, you should be able to:
- State the Bradley-Terry preference model .
- Write the RLHF objective with KL penalty to reference policy .
- Derive the closed-form optimal policy in terms of reward .
- Eliminate the reward model to obtain the DPO loss directly on policy log-probabilities.
- Explain why DPO avoids reinforcement learning (PPO) during alignment.
Prerequisites
- Logistic Regression — sigmoid, cross-entropy
- KL Divergence
- Scaling Laws — pretrained reference policy
Notation
- — Prompt
- — Preferred (winner) and dispreferred (loser) completions
- — Trainable and frozen reference policies
- — Latent reward function
- — KL penalty coefficient
- — Logistic sigmoid
Core Intuition
Alignment adjusts a pretrained LLM to produce helpful, harmless outputs. RLHF (Reinforcement Learning from Human Feedback) trains a reward model on human preferences, then optimizes the policy with PPO — unstable and complex.
DPO (Rafailov et al., 2023) shows the optimal RLHF policy has a closed form in terms of the reward. Substituting back into the preference model eliminates the reward entirely — alignment becomes supervised learning on preference pairs with a simple classification loss.
Series context. Volume III, Chapter 13 (Alignment).
Direct Preference Optimization
Preference Data and Bradley-Terry Model
Definition 1 (Preference Dataset). Triples where is preferred (winner) over (loser) for prompt .
Definition 2 (Bradley-Terry Model).
where is a latent reward function and is the logistic sigmoid from Logistic Regression.
The RLHF Objective
Definition 3 (KL-Constrained RLHF).
where is the frozen pretrained policy and controls deviation from reference.
Closed-Form Optimal Policy
Theorem 1 (Optimal Policy). The unique maximizer of (2) is:
where is the partition function.
Proof. Lagrange multipliers on probability simplex; Gibbs distribution form.
Corollary 1 (Reward Recovery).
Deriving the DPO Loss
Substitute (4) into Bradley-Terry (1). The partition function cancels:
Theorem 2 (DPO Loss).
Proof. From (1):
using (4) and cancellation of . Maximum likelihood on preferences gives (5).
Important equation. DPO optimizes policy directly — no explicit reward model, no PPO.
Implicit Reward Model
Definition 4 (Implicit Reward).
DPO implicitly defines a reward through the policy ratio to reference.
DPO vs. RLHF Pipeline
- 1 — SFT on demonstrations — SFT (same)
- 2 — Train reward model — —
- 3 — PPO on reward — DPO loss (5)
- Stability — PPO hyperparameters — Standard SGD
- Compute — 3 models — 2 models (, frozen )
Worked Examples
Example 1: Preference Probability
If and ratio for is 1, DPO logit . For , preference probability .
Example 2: Identical to Reference
If , DPO logit — 50% preference probability (uninformative).
Connection to the Broader Curriculum
- Logistic Regression — sigmoid preference model
- KL Divergence — RLHF penalty
- LoRA — efficient DPO fine-tuning
- RAG — complementary alignment technique
Common Pitfalls and Misconceptions
Pitfall 1: DPO still requires good SFT initialization.
Pitfall 2: too small → ignore preferences; too large → collapse to reference.
Pitfall 3: Length bias in preferences affects DPO.
Pitfall 4: DPO assumes Bradley-Terry transitivity.
Research Perspective
DPO (Rafailov et al., 2023). Extensions: IPO, KTO, ORPO, SimPO. Active: online DPO, multi-objective alignment.
Summary of Takeaways
- Bradley-Terry —
- Optimal policy —
- DPO loss — (5)
- Implicit reward —
Next: LoRA
Exercises
Exercise 1. Derive (3) from (2).
Exercise 2. Prove cancels in (6).
Exercise 3. Derive gradient of (5) w.r.t. .
Exercise 4. Effect of and .
Exercise 5. Connect Bradley-Terry to Logistic Regression.
Exercise 6. Why store separately?
Exercise 7. DPO with LoRA on both policies?
Exercise 8. Limitations of preference transitivity.