Paper
Direct Preference Optimization: Your Language Model is Secretly a Reward Model
DPO eliminates the reward model training step by directly optimizing preferences as a classification objective.
Rafailov et al., Stanford2023arXiv ↗Views: –
The problem with the RLHF pipeline
Standard RLHF aligns a language model in three stages: supervised fine-tuning (SFT), then training a separate reward model on human preference pairs, then optimizing the policy against that reward model with PPO. The last stage is the painful one. It keeps several models in memory at once (policy, reference, reward, and a value head), depends on an on-policy RL loop that is sensitive to hyperparameters, and is easy to destabilize — the policy can drift until it exploits flaws in the frozen reward model.
The DPO derivation
DPO starts from the same KL-regularized objective that RLHF optimizes, but instead of solving it with RL, it uses the closed-form solution. For the standard objective the optimal policy satisfies
which can be rearranged to express the reward in terms of the policy itself:
The intractable partition function cancels when you take a difference of rewards between two completions of the same prompt. Substituting into the Bradley–Terry preference model turns the whole problem into a simple binary classification loss on the policy.
The loss
The first term raises the log-probability of the preferred completion ; the second lowers it for the rejected completion . The reference model and keep the policy from drifting too far — exactly the role the KL penalty plays in RLHF.
Tradeoffs vs PPO-based RLHF
DPO is dramatically simpler: one stage, no reward model, no sampling loop, stable supervised-style training. The costs are that it is purely offline (it only ever sees the fixed preference dataset, never fresh on-policy samples), it can over-fit to the preference data, and a strong explicit reward model still has uses — for best-of-n sampling, online exploration, and reward-signal reuse — that a DPO-trained policy does not directly provide.
RLHF vs DPO
RLHF — three stages
Train a separate reward model, then optimize the policy against it with RL. Two extra models, an unstable RL loop.
DPO — one stage
No reward model, no RL. Preferences become a single classification-style loss on the policy itself.
Prompt: Explain why the sky is blue to a five-year-old.
Preferred y_w
Sunlight is made of every color. Tiny bits of air bounce the blue light all around, so the whole sky looks blue!
Rejected y_l
Rayleigh scattering. The atmospheric scattering cross-section scales as λ⁻⁴, hence shorter wavelengths dominate.
L_DPO = −log σ( β log π(y_w)/π_ref(y_w) − β log π(y_l)/π_ref(y_l) )
The greenterm pushes the preferred completion's probability up; the redterm pushes the rejected completion's probability down. β controls how far the policy may drift from the reference.
Log-probability gap (implicit reward margin): +1.52 — widens as training proceeds.