Before you move a control in the demo, say what you expect to change.
Foundation reference
Direct Preference Optimization: RL-Free Alignment from Human Preferences
DPO trains a model on preference pairs with a single classification-style loss, without a separate reward model or a reinforcement-learning loop (Rafailov et al., 2023).
Study guide
Where to start
Why is DPO better described as moving probability mass between responses than as learning a scalar reward?
How to study this pagePredict · Check · Generalize · Continue
Compare what the demo shows with the key equation and with the papers cited below.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
The newer notebook covers the same concept and has an interactive demo.
Why It Matters for Modern Models
- DPO trains a model on preference pairs with a single classification-style loss, without a separate reward model or a reinforcement-learning loop (Rafailov et al., 2023).
- Several open models were post-trained with DPO, including Zephyr-7B (Tunstall et al., 2023) and Llama 3 (Grattafiori et al., 2024).
- Variants change the loss: SimPO drops the reference model and uses length-normalized log-probabilities (Meng et al., 2024), and DPO-Positive adds a term that keeps the likelihood of the preferred response from falling (Pal et al., 2024).
- DPO makes explicit that preference training is a KL-regularized reshaping of the reference model's distribution, whether or not reinforcement learning is used.
Questions to Think About
- What role does the reference model play, and why does the KL term act like a trust region that keeps the policy where the preference data are informative?
- How can DPO widen the gap between preferred and rejected responses while lowering the likelihood of the preferred one (Pal et al., 2024)?
- What can offline preference optimization learn about situations that its preference data never cover?
- In what sense is DPO logistic regression on log-probability ratios, and what does it keep and lose relative to RLHF with an explicit reward model?
Interactive Demo
Core Math
If you prefer intuition first, try the demo above, then come back for the math.
DPO replaces the reinforcement-learning loop of RLHF with a classification loss on preference pairs. Under the Bradley–Terry preference model it optimizes the same KL-constrained objective (Rafailov et al., 2023).
KL-regularized RLHF objective:
Closed-form optimal policy (Boltzmann):
DPO loss (RL-free):
Given preference pairs (winner, loser):
This is logistic regression on log-probability ratios: there is no separately trained reward model and no sampling from the policy during training.