- Introduced by
- Rafael Rafailov
- Year
- 2023
- Type
- Training methodology
- Family
- Deep Learning, Language Models, RLHF Alternatives
What does it do?
Direct Preference Optimization (DPO) is a training method for language models introduced by Rafailov et al. in 2023.
It fits a model to pairs of responses labelled by human preference, without first training a separate reward model or running the reinforcement-learning loop used in RLHF. The objective is defined relative to a frozen reference model, which keeps the trained model close to its starting behaviour.
The intuition behind the method
RLHF first trains a reward model on human preference data and then uses reinforcement learning to maximise that reward. DPO starts from the same preference objective but rearranges it so that the language model carries the reward itself. The trained model's log-probability of a response, compared with the reference model's log-probability, plays the role of an implicit reward. Training then raises the relative probability of the preferred response over the dispreferred one in each labelled pair. The reference model and the regularisation coefficient stop the model from moving arbitrarily far from its starting point while it does this.
History
Rafailov et al. (2023) introduced DPO in the paper 'Direct preference optimization: Your language model is secretly a reward model'. Its central step is a reparameterisation of the KL-regularised reward-maximisation objective used in RLHF, which allows the policy to be trained directly on preference pairs without fitting a separate reward model.
When to use it
Choose DPO when you have pairwise preference data, meaning for each prompt a preferred and a dispreferred response, and want to align a pre-trained language model without building and training a separate reward model. It is a reasonable choice when the goal is to shape the model's outputs toward those preferences. Do not choose it when the main need is a reusable reward model, for example to score or rank outputs from several different policies or at inference time, because RLHF-style pipelines produce such a model as an explicit artefact. DPO cannot be applied directly to single scored responses without pairs, and it does not correct bias or noise already present in the pairs it is given.
Limitations and considerations
- Each training example must be a prompt with a preferred and a dispreferred response, so preference data has to be collected in that pairwise form.
- The implicit reward is anchored to the reference model's probabilities; if the reference is a weak starting point, the preference signal is interpreted relative to that weak baseline.
- The objective fits the preference distribution present in the training pairs and does not directly constrain behaviour on prompts or response types that the pairs do not cover.
- The derivation assumes that pairwise preferences follow a Bradley–Terry-type model, in which each response has a latent scalar reward and the probability that one response is preferred depends only on the difference between the two rewards. The results therefore depend on this assumption holding for the annotation data. Preferences that are intransitive or that depend on context beyond the two compared responses fall outside what the derivation models.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- No separate reward-model training stage and no reinforcement-learning sampling loop; the model is optimised directly on the preference pairs.
- The loss is computed from log-probabilities of existing responses, so training does not require generating new responses from the policy at each update.
- The reference model appears explicitly in the loss, so the trade-off between fitting preferences and staying near the starting model is part of the objective rather than an added penalty term.
Applications
- Aligning instruction-tuned chat models to pairwise human judgements of response quality.
- Adjusting the style of generated text where annotators can say which of two drafts they prefer.
- Tuning writing or code assistants where pairwise judgements of solution quality exist and reflect the criteria the model should follow.
How it works
How it works
Annotators compare two responses to the same prompt and mark one as preferred and the other as dispreferred. These labelled pairs are the training signal the method uses.
A reference model, usually the model before preference training, is copied and its weights are kept fixed. It supplies the baseline log-probabilities against which the trained model is compared, and it anchors the trained model to its starting behaviour.
For each pair, the loss compares the difference in log-probability between the preferred and dispreferred responses under the trained model with the same difference under the reference model. Each difference is taken as the trained model's log-probability minus the reference model's, computed for the preferred and for the dispreferred response. The per-pair loss is the negative log of a logistic function applied to β times the gap between these two log-ratios. A regularisation coefficient, conventionally written β, sets how strongly deviation from the reference is penalised.
Parameters are updated by gradient descent on this loss, which increases the relative probability of preferred responses and decreases that of dispreferred ones. The reference-based term limits how far this shift can go.
Common pitfalls
- The loss treats every labelled pair as correct, so noisy or inconsistent labels can push the model in contradictory directions, and the loss itself does not reveal which labels are wrong.
- The regularisation coefficient sets the balance: a large value keeps the model near the reference and learns little from the pairs, while a small value lets the model drift far from the reference and over-optimise the preference signal.
- Where annotators disagree about what counts as better, the pairs encode a mixture of standards; how disagreements are resolved, such as by majority label or by dropping contested pairs, changes what the model learns.
Frequently asked questions
How does DPO differ from RLHF?
RLHF fits a separate reward model to preference data and then optimises the language model against it with reinforcement learning. DPO skips both the separate reward model and the reinforcement-learning loop: it trains the language model directly on preference pairs, and the model's probabilities relative to the reference model play the role of the reward. The title of the original paper expresses this idea: the language model is itself implicitly a reward model.
What is the KL divergence penalty for?
The regularisation term keeps the trained model close to the reference model. Optimising the preference objective alone places no built-in limit on how far the model's probabilities can move from its starting point. In DPO this constraint enters the loss through the reference-model log-probabilities and the regularisation coefficient.
How sensitive is DPO to preference data quality?
The loss treats every labelled pair as correct, so noisy or inconsistent labels push the model toward contradictory directions. Clear annotator guidelines and checks of agreement between annotators are the main practical safeguards. How much label noise is tolerable depends on the task and the dataset, so it should be checked on the specific data rather than assumed.
Related methods
Sources
Rafailov, R., Sharma, A., Mitchell, E., Manning, C. D., Ermon, S., & Finn, C. (2023). Direct preference optimization: Your language model is secretly a reward model. arXiv preprint arXiv:2305.18290.
Open publication reference