DPO: How Direct Preference Optimization Replaced Reward Models With a Classification Loss
2026-09-04
Reinforcement learning from human feedback became the dominant method for aligning large language models after InstructGPT demonstrated in 2022 that a model trained on human preference comparisons could be substantially more useful than a larger model trained only on next-token prediction. The RLHF pipeline has three stages: supervised fine-tuning on high-quality demonstrations, training a separate reward model on human preference pairs, and running proximal policy optimization (PPO) to maximize the reward while staying close to the reference policy via a KL divergence penalty. All three stages together produce the alignment, but the third stage in particular is complex. PPO requires generating samples from the live policy during training, which means keeping multiple model copies in memory, tuning a separate set of RL hyperparameters, managing reward hacking, and accepting the training instabilities that arise when a neural network serves as both the optimizer target and the data generator. Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, and Chelsea Finn at Stanford University (and Ermon also at CZ Biohub) asked whether that complexity was necessary. Their paper 'Direct Preference Optimization: Your Language Model is Secretly a Reward Model,' submitted to arXiv on May 29, 2023 (arXiv:2305.18290) and presented as an Oral at NeurIPS 2023, where it received an Outstanding Paper Runner-up award, shows that it is not.
The three-stage RLHF pipeline and what makes it expensive
The RLHF pipeline described by Ziegler et al. (2019) and refined by Stiennon et al. (2020) and Ouyang et al. (2022) works as follows. First, a pretrained language model is supervised fine-tuned on a curated dataset of high-quality completions; this produces a reference policy. Second, the reference policy is used to generate pairs of responses to prompts, and human annotators label which response in each pair they prefer. A separate reward model is trained on these labeled pairs using the Bradley-Terry preference model, which treats the probability that response A is preferred over response B as a sigmoid of the difference in their rewards. Third, PPO is run to fine-tune the language model to maximize the reward assigned by the reward model, subject to a per-token KL divergence constraint that penalizes deviating too far from the reference policy. The KL constraint prevents reward hacking: without it, the policy would find high-reward responses that look nothing like natural text. The constraint requires computing log probabilities from both the trained policy and the frozen reference policy at every PPO step, doubling the memory required. Sampling from the policy during training adds further memory pressure and forces the optimizer to handle the non-stationarity of its own training distribution.
The mathematical insight: optimal policy and reward are equivalent
Rafailov et al. show that the constrained reward maximization objective at the core of RLHF has a known closed-form solution. Given a reward function r(x, y) and a KL constraint weighted by a coefficient beta, the optimal policy takes the form: pi*(y|x) is proportional to pi_ref(y|x) times exp(r(x,y) / beta), where pi_ref is the reference policy. This expression can be inverted: the reward consistent with any policy pi and reference pi_ref is r(x,y) = beta times log(pi(y|x) / pi_ref(y|x)) plus a partition function term that depends only on x and cancels in pairwise comparisons. Substituting this reparameterization into the Bradley-Terry preference model yields a preference probability that depends only on ratios of log probabilities from pi and pi_ref, with no separate reward model in the expression. Maximizing the log-likelihood of observed human preferences under this preference model gives a binary cross-entropy loss defined entirely over policy outputs. This is the DPO loss. It pushes up the log probability ratio of preferred responses relative to the reference and pushes down the log probability ratio of dispreferred responses, with a per-example importance weight derived from how well the current policy already fits each pair. The weight prevents the degenerate solution in which the policy simply maximizes the ratio for every pair regardless of quality.
What DPO eliminates from the training pipeline
The practical consequence of the reparameterization is that the three-stage RLHF pipeline collapses to two stages. Supervised fine-tuning on demonstrations still happens first; DPO does not change that step. But the reward modeling stage and the RL optimization stage are replaced by a single gradient descent pass on a static dataset of preference pairs. No reward model is trained. No samples are generated from the live policy during training. No RL hyperparameters, including the KL coefficient, PPO clip ratio, value function loss weight, and generalized advantage estimation parameters, need to be tuned; DPO has one main hyperparameter, beta, which controls how strongly the loss weights deviations from the reference policy. The memory footprint of DPO training is also smaller than PPO because only two model copies need to be held simultaneously (the trained policy and the frozen reference), whereas PPO with a learned value function typically requires three or four copies. The authors describe the resulting algorithm as transforming preference learning into a supervised learning problem over a static dataset.
- Rafailov et al. (arXiv:2305.18290, submitted May 29, 2023): NeurIPS 2023 Oral, Outstanding Paper Runner-up; authors from Stanford University and CZ Biohub.
- Core result: the KL-constrained reward maximization objective in RLHF has a closed-form optimal policy; inverting this mapping yields a reward parameterized by policy log probability ratios.
- DPO loss: binary cross-entropy on human preference pairs, with per-example importance weights from the log probability ratio of policy vs. reference on preferred and dispreferred responses.
- What is eliminated: separate reward model training, online policy sampling during fine-tuning, PPO and value-function hyperparameter tuning.
- Evaluated on sentiment modulation (GPT-2 scale), TL;DR summarization (6B scale), and single-turn dialogue using the Anthropic Helpful and Harmless dataset.
- Results: DPO exceeds PPO-based RLHF on sentiment control; matches or improves PPO on summarization and dialogue win rates against the reference policy.
Experiments: sentiment, summarization, and dialogue
The paper evaluates DPO on three tasks of increasing scale and open-endedness. For sentiment modulation, a GPT-2-scale model is fine-tuned to generate positive continuations of movie reviews; success is measured by a separate sentiment classifier, and the KL divergence from the reference policy is measured to confirm the response is still fluent. DPO achieves a better trade-off between high sentiment score and low KL divergence than PPO. For TL;DR summarization, a 6 billion parameter language model is fine-tuned on the Reddit TL;DR dataset, which was also used in the Stiennon et al. RLHF summarization paper. Summary quality is evaluated by GPT-4 win rate comparisons between DPO outputs and PPO outputs, with human judgments used to validate that GPT-4 win rates track human win rates reliably (the paper reports human and GPT-4 rates for several matchups and shows consistent agreement). DPO matches or exceeds the PPO baseline across a range of KL budgets. For single-turn dialogue, the Anthropic Helpful and Harmless dataset is used; DPO responses are again compared by GPT-4 win rate, and DPO improves over the supervised fine-tuned baseline more reliably than PPO. The 6B scale experiment is notable because PPO at that scale requires significant engineering to stabilize, whereas DPO training at that scale is described as straightforwardly stable throughout.
Adoption and influence since NeurIPS 2023
DPO became one of the most widely adopted alignment techniques in the period following its publication. The Hugging Face TRL library added DPO training within months of the paper's release, making it accessible to practitioners who already used the library for supervised fine-tuning. Llama-based community models were among the first to be aligned with DPO rather than RLHF, and the combination of LoRA fine-tuning with DPO alignment became a standard recipe for resource-constrained preference tuning. Several variants followed quickly. Identity Preference Optimization (IPO) addressed an overfitting issue identified in DPO by removing the implicit Bradley-Terry assumption. Kahneman-Tversky Optimization (KTO) showed that a model could be aligned from unpaired preference feedback, one response labeled good or bad at a time, rather than requiring contrastive pairs. Odds Ratio Preference Optimization (ORPO) eliminated the need for a separate reference model entirely by incorporating a reference-free regularization term. Each of these variants preserves the core DPO insight: alignment can be formulated as a supervised loss on a static dataset rather than as an RL problem. The paper's framing that a language model is 'secretly a reward model' because its log probability ratios directly encode an implicit reward has become a standard conceptual tool in alignment research. PromptingIndex covers DPO alongside RLHF, InstructGPT, Constitutional AI, and GRPO in its series on alignment and preference learning techniques that determine how raw pretraining capability is converted into safe and helpful behavior.
Put these ideas to work.
Browse the prompt library