Direct Preference Optimization and Its Variants
Suppose a team already has prompts with two candidate responses and a judgment about which response is better. Classical RLHF would fit an explicit reward model, generate new responses, and optimize a policy against that reward. Direct Preference Optimization (direct preference optimization (DPO)) takes a shorter route. DPO fits a preference classifier without an explicit reward model. Under a specific model of preferences, its loss trains the language model directly (Rafailov et al. 2023).
This simplification matters. DPO collapses the reward-model and policy-optimization apparatus into a single classification loss over a static dataset. It does not, however, turn alignment into ordinary supervised fine-tuning or make the assumptions behind RLHF disappear. DPO still needs paired judgments, a frozen reference policy, a model of how preferences arise, and evaluation outside the training pairs.
What DPO removes, and what it keeps
Let the preference dataset be
where is a prompt, is the response preferred by the rater, is the rejected response, and is the number of comparisons. Starting from an instruction- tuned model, DPO trains one policy and compares it with a frozen reference , usually a copy of that starting model.
Compared with PPO-based RLHF in Chapter 19, DPO removes three components from the training loop:
- no separately trained scalar reward model;
- no rollouts from the changing policy during the preference-training stage;
- no critic or policy-gradient optimizer.
What remains is important. The reference policy defines what counts as movement, the data contains only the candidate responses that were collected, and the pairwise loss specifies how one observed comparison should constrain the policy. The language model is an implicit reward model only in the precise sense derived below. It is not a general-purpose judge that can be queried independently of its reference.
The derivation and its assumptions
The derivation starts from a KL-regularized reward objective. For one prompt , consider all probability distributions over possible responses:
where is a scalar reward, is the KL coefficient, and is the reference policy. If the reward is finite, its normalizer exists, and puts probability only on the support of the reference policy, the maximizing distribution is
with
The closed form is over distributions, not neural-network parameters. A finite language model may not represent exactly, and gradient descent may not find the global optimum. The formula tells us what the ideal KL-regularized solution looks like; it does not solve for .
Rearranging the optimal-policy equation gives
The last term depends on the prompt but not on the response. More generally, reward is identified only up to a prompt-only constant: adding any to every response reward for the same prompt changes neither pairwise reward differences nor the optimal normalized policy. The policy-to-reference log-ratio is therefore one representative of an equivalent class of rewards, not a uniquely recovered human utility.
DPO next assumes a Bradley-Terry preference model:
Here means that is preferred to . The Bradley-Terry assumption represents each response with one scalar score and turns the score difference into a logistic choice probability. It cannot directly express ties, cyclic preferences, different rater populations, or judgments that depend on unrecorded context.
Substitute the implicit reward into the Bradley-Terry model. The prompt-only constant cancels between and , leaving the DPO loss
where
Here is the preferred response's movement relative to the reference minus the rejected response's movement relative to the reference. Exact equivalence to the idealized RLHF solution requires the Bradley-Terry model to be well specified, adequate data coverage, compatible reference and behavior-policy support, and successful optimization. DPO removes an explicit reward-model and PPO loop under these assumptions. It is not exactly equivalent for arbitrary neural models, misspecified preferences, or finite off-support data.
Interpreting relative movement
The margin equation is easy to misread. DPO does not merely ask whether the chosen response has a larger probability than the rejected response. It asks whether training has moved the chosen response upward relative to the reference more than it has moved the rejected response. Consequently, a positive DPO margin does not guarantee . A response that was already unlikely under the reference can win the relative comparison while remaining unlikely in absolute terms.
The per-example gradient makes the update clearer:
Here pairs with a negative or small margin receive the greatest weight. Once the margin is large, the sigmoid saturates and the pair contributes little. Because the two sequences share model parameters, this contrast does not promise that the chosen-response log-probability will rise monotonically at every checkpoint. Track it instead of inferring it from training loss.
Sequence log-probability is a token sum,
where is the number of response tokens and is the prefix before token . The DPO margin therefore sums policy-to-reference changes across all response tokens. Length can confound the margin when the data has systematic length differences, but the sign of each token log-ratio can be positive or negative. DPO reward is not mathematically guaranteed to increase with response length.
The role of also has two layers. In the KL-regularized objective, larger means stronger theoretical regularization toward the reference. In the implemented DPO loss, also sets the logit temperature and multiplies the gradient. Finite-step training need not produce a monotonic relationship between and measured policy drift. Tune it, then report the achieved policy/reference divergence and task quality rather than treating the configured value as the achieved constraint.
The four variants solve different constraints
IPO, KTO, ORPO, and SimPO are often arranged as a sequence of upgrades. That framing hides their actual purpose. Each changes a different part of the problem: the loss shape, the label format, the use of an SFT term, or the response score. They also require different data and different training resources.
IPO: keep pairs and the reference, change the loss shape
Identity Preference Optimization (identity preference optimization (IPO)) starts from a theoretical problem with DPO's Bradley-Terry reduction. If observed preferences are deterministic or nearly deterministic, the negative log-sigmoid loss has its infimum at an ever-larger preference margin. The loss itself is bounded below by zero; the optimizing margin is what tends toward infinity on separable comparisons (Gheshlaghi Azar et al. 2024).
IPO bypasses the pointwise Bradley-Terry reward assumption and regresses the policy/reference log-ratio gap to a finite target. With
Here denotes the chosen-versus-rejected gap in policy/reference log-ratios. The sampled IPO objective is
Here this chapter uses for the paper's positive KL-regularization parameter . The target is therefore fixed by the theory as , not chosen independently. IPO still needs paired responses and a frozen reference. Its source paper demonstrates the behavior mainly in illustrative bandit problems, so the derivation should not be read as evidence that IPO wins broadly on language-model tasks.
The runnable below isolates this difference. It optimizes one scalar gap rather than a language model, so it demonstrates loss geometry, not expected model quality.
import numpy as np
import matplotlib.pyplot as plt
def sigmoid(z):
return 1.0 / (1.0 + np.exp(-z))
beta = 0.2
learning_rate = 0.1
steps = 100
ipo_target = 1.0 / (2.0 * beta)
dpo_gap = [0.0]
ipo_gap = [0.0]
for _ in range(steps):
# d[-log sigmoid(beta*h)]/dh = -beta*sigmoid(-beta*h)
dpo_gradient = -beta * sigmoid(-beta * dpo_gap[-1])
dpo_gap.append(dpo_gap[-1] - learning_rate * dpo_gradient)
# d[(h - 1/(2*beta))**2]/dh = 2*(h - target)
ipo_gradient = 2.0 * (ipo_gap[-1] - ipo_target)
ipo_gap.append(ipo_gap[-1] - learning_rate * ipo_gradient)
print(f"IPO target: {ipo_target:.2f}")
print(f"DPO gap after {steps} steps: {dpo_gap[-1]:.2f}")
print(f"IPO gap after {steps} steps: {ipo_gap[-1]:.2f}")
plt.plot(dpo_gap, label="DPO gap")
plt.plot(ipo_gap, label="IPO gap")
plt.axhline(ipo_target, color="gray", linestyle="--", label="IPO target")
plt.xlabel("gradient step")
plt.ylabel("policy/reference log-ratio gap")
plt.legend()
plt.show()
KTO: replace pairs with desirable and undesirable examples
Kahneman-Tversky optimization (KTO) drops the paired-data requirement by learning from good/bad labels. Kahneman-Tversky Optimization changes the data requirement. Each example is a triple , where says whether response is desirable or undesirable. A positive and a negative response for the same prompt are not required (Ethayarajh et al. 2024). This fits logs built from approvals, rejections, or thresholded ratings, although the meaning and calibration of those labels still matter.
KTO retains a reference model. It defines
Here represents the response's policy/reference log-ratio, while denotes the KL reference point. KTO then scores the example relative to that point:
Its loss is , where and weight the desirable and undesirable classes. In practice, exact computation of is expensive. The paper uses a stopped-gradient, biased microbatch estimate constructed from mismatched prompts and responses. Class imbalance therefore affects both the weights and the quality of the baseline estimate.
The prospect-theory connection supplies an inductive bias: gains and losses are evaluated relative to a reference point with a saturating value function. It is not evidence that this formula is a faithful psychological model of how people judge text. KTO's practical advantage is narrower and useful: it can train from independently labeled responses without pretending that those labels form same-prompt pairs.
ORPO: combine chosen-response SFT with a preference penalty
Odds Ratio Preference Optimization (odds-ratio preference optimization (ORPO)) removes the frozen reference and the separate preference stage. It trains on pairs, uses the chosen response as an SFT target, and adds a term that separates chosen and rejected sequence scores (Hong et al. 2024). For a response of tokens, ORPO first defines the geometric-mean token probability
Here represents the geometric mean of the token probabilities. Its odds are . The objective is
Here denotes chosen-response negative log-likelihood and sets the weight of the odds-ratio term, defined as
This formula means that minimizing increases the chosen response's odds relative to the rejected response. balances demonstration learning against preference separation. ORPO is one stage, not literally one pass over the data. It saves reference inference or cached reference scores, but it also couples SFT and preference learning through . Those two signals cannot be tuned or audited as independently as a staged SFT-then-DPO pipeline.
SimPO: use average log-probability and a target margin
Simple Preference Optimization (simple preference optimization (SimPO)) also removes the reference, but it retains a pure pairwise objective. Its response score is the policy's average token log-probability:
Here denotes response length and scales the average log-probability. The training loss is
where scales the score difference and is the target margin (Meng et al. 2024). Unlike its role in the original KL objective, is not a KL coefficient here because SimPO has no reference-policy KL term.
The per-token average reduces sensitivity to response length when length and preference are correlated in the dataset. It does not eliminate all length bias, and the SimPO paper notes that DPO's policy/reference ratio can itself counteract some length effects. The original experiments also found that an overly large could reduce generation quality. Reference-free does not mean regularization-free; initialization, learning rate, data coverage, and early stopping still limit drift.
What the comparison can establish
The original papers report gains in particular settings. KTO reports competitive results with unpaired labels, ORPO reports benefits from its joint objective, and SimPO reports wins over its DPO baselines on chat evaluations. These results use different initial models, datasets, hyperparameter searches, and evaluators. They do not form one common tournament.
A 2026 preprint tested 20 DPO variants on synthetic GSM8K preference data at 1.5B parameters and reported that none of the variants reliably beats the plain loss after Bonferroni correction (Li 2026). In that experiment, SimPO was the only statistically significant difference and performed worse. The same paper's broader scale study, however, found SimPO ahead of DPO at 7B. Its variant sweep used one model family, one main training domain, published defaults rather than equal per-method tuning, and initially contained a seed-propagation fault that the authors later checked on a subset of methods.
This does not prove that DPO is universally best. It shows why an objective-level win should be treated as conditional on scale, data, initialization, tuning, and evaluation. Broader empirical comparisons likewise find rankings that vary by setting (Spangher et al. 2025; Saeidi et al. 2025).
The defensible conclusion is not that the losses are interchangeable. It is that there is no established universal winner. Compare them with the same starting checkpoint, data, optimization budget, decoding settings, and external evaluator. Report uncertainty across seeds when the decision matters.
Choose from data and pipeline constraints
The pipeline and data constraints often narrow the choice before benchmark scores do:
| Method | Feedback format | Frozen reference during training | Chosen SFT term | Response score | Main extra controls |
|---|---|---|---|---|---|
| DPO | paired | yes | no | summed policy/reference log-ratio | |
| IPO | paired | yes | no | policy/reference log-ratio gap | and finite target |
| KTO | desirable/undesirable | yes | no | log-ratio relative to KL baseline | |
| ORPO | paired | no | yes | odds of geometric-mean token probability | |
| SimPO | paired | no | no | average policy log-probability |
Use this table as a filter, not a leaderboard:
- Start with DPO when same-prompt pairs and a suitable reference are available. It is the clearest baseline and keeps SFT separate from preference learning.
- Consider IPO when separable comparisons drive margins upward and reference anchoring is still desirable. Validate the theory-derived target in the actual model regime.
- Consider KTO when feedback is genuinely pointwise. Audit label semantics, class balance, and the microbatch KL estimate before comparing quality with pairwise methods.
- Consider ORPO when a one-stage SFT-plus-preference recipe is operationally useful. Measure how trades chosen imitation against rejection rather than assuming the two cooperate.
- Consider SimPO when avoiding reference inference and using a per-token score fit the pipeline. Tune both and , and measure drift because there is no explicit reference anchor.
Reference-free methods remove reference inference and storage overhead. They do not necessarily halve peak memory: optimizer states, activations, sharding, offload, and whether reference scores are precomputed determine the realized saving. DPO and IPO can compute frozen-reference log- probabilities before training and store two scalar scores per pair, trading disk and preprocessing for lower training-time memory and compute.
The systems design in Chapter 10 reaches into the objective choice. If reference scores can be precomputed, DPO's extra model need not remain resident. If pairs are regenerated between rounds, cached scores become stale and reference inference returns. Decide the data refresh schedule, storage format, sharding plan, and precision policy before using “reference-free” as a systems argument.
A practical DPO run
A reliable first run is deliberately plain. It establishes whether the preference data carries useful signal before adding a variant.
- Freeze the starting point. Save the SFT or instruction checkpoint as and initialize from the same weights. Record tokenizer, chat template, truncation rules, and end-of-sequence handling.
- Validate every triple. Require one prompt, one chosen response, and one rejected response. Remove exact duplicates, contradictory duplicate labels, empty responses, and pairs made identical by truncation. Split by prompt or source group to prevent near-duplicate leakage.
- Inspect the preference signal. Measure response lengths, label sources, topic mixture, rater agreement where available, and the starting model's margins. A dataset in which the chosen answer is almost always longer can train style as a shortcut.
- Compute sequence scores correctly. Mask prompt tokens and padding. Sum response-token log-probabilities under the policy and reference. Use the same tokenization and truncation for both models. Precompute reference scores only after these choices are frozen.
- Run a small sweep. Vary learning rate, , and epochs. Learning rate and stopping time can matter as much as the named objective. Keep the data order and evaluation protocol fixed across methods.
- Evaluate checkpoints, not only the last step. Training preference accuracy can keep rising after held-out task quality peaks. Select with external evaluation defined before the sweep.
The minimal batch computation is
and are sums over response tokens only. Keeping them as named diagnostics makes several failures visible that a single loss curve would hide.
Failure modes and checks
Preference optimization is offline: it only constrains responses represented in the stored comparisons. As the policy changes, it can enter regions where those labels provide little coverage. No loss variant can infer missing behavior requirements from absent data.
Track at least the following on a held-out split and on generated responses:
- Measure held-out preference accuracy and margin. These show whether the loss generalizes to unseen pairs, but they do not by themselves measure open-ended generation quality.
- Chosen-response log-probability and rejected-response log-probability. A widening relative margin can coexist with falling likelihood for both responses. That may be acceptable, but it should be observed rather than assumed away.
- Policy/reference divergence. Estimate token-level KL or policy/reference log-ratios on fresh generations. The configured is not a measurement of achieved drift.
- Response length and format compliance. Compare distributions, not just their means. Length, refusal rate, and formatting can become shortcuts for the preference label.
- Held-out task quality. Use human evaluation, verifiable tasks, or a judge protocol with known limitations. Include safety and capability regressions that are not represented by the training pairs.
- Slice results. Break out prompt source, language, difficulty, response-length gap, and label provenance. Aggregate wins can conceal a severe regression on one group.
If training accuracy approaches one while external quality falls, first shorten training or lower the learning rate. Then inspect data leakage, contradictory labels, length shortcuts, and policy drift. Switching objectives before diagnosing those causes can merely move the same failure to a different loss.
Static preference optimization is valuable precisely because it is simple. Its limit is the same simplicity: the model never asks for a new comparison while it changes. Iterated or online methods refresh candidates from the current policy and collect or generate new judgments, improving coverage at the cost of bringing sampling and feedback infrastructure back into the loop. That tradeoff connects this chapter to the online RLHF system in Chapter 19.
Further reading
- Rafailov et al., “Direct Preference Optimization: Your Language Model is Secretly a Reward Model” (DPO), 2023. arXiv:2305.18290DPO optimizes a policy directly from chosen and rejected responses under its preference model, avoiding a separately fitted reward model and online RL loop.
- Gheshlaghi Azar et al., “A General Theoretical Paradigm to Understand Learning from Human Preferences” (IPO), 2024. arXiv:2310.12036This paper introduces ΨPO, a general preference optimization objective that unifies RLHF and DPO as special cases, and proposes IPO, which bypasses the Bradley-Terry assumption to avoid overfitting.
- Ethayarajh et al., “Model Alignment as Prospect Theoretic Optimization,” 2024. arXiv:2402.01306KTO aligns LLMs using a Kahneman-Tversky prospect theory objective that learns from binary desirability signals instead of preference pairs, matching or exceeding DPO at scales from 1B to 30B parameters.
- Hong et al., “ORPO: Monolithic Preference Optimization without Reference Model,” 2024. arXiv:2403.07691ORPO is a monolithic preference alignment algorithm that merges SFT and preference optimization into one step using an odds ratio penalty, eliminating the need for a reference model.
- Meng et al., “SimPO: Simple Preference Optimization with a Reference-Free Reward,” 2024. arXiv:2405.14734SimPO replaces DPO's reference-model reward with a length-normalized average log probability and a target reward margin, eliminating the reference model while outperforming DPO by up to 7.5 points on Arena-Hard.
- Schulman et al., “Proximal Policy Optimization Algorithms” (PPO), 2017. arXiv:1707.06347PPO introduces a clipped surrogate objective for policy gradient reinforcement learning that achieves TRPO-level reliability with simpler first-order optimization and better sample complexity.
Comments
Log in to comment