Open the workspace
Algorithms 101

IPO (Identity Preference Optimization), explained

How IPO fixes DPO's overfitting on deterministic preferences: the ΨPO objective, the squared loss and its target, τ tuning, and toy runs with real numbers.

Identity Preference Optimization (IPO) is a preference-tuning loss that looks like DPO with one change: instead of pushing the gap between chosen and rejected log-likelihood ratios through a logistic loss, it regresses that gap onto a fixed target with a squared error. The target is , where is the regularization strength. That small edit matters when preferences in the data are deterministic or nearly so, which is most real datasets: DPO keeps widening the gap indefinitely and the KL penalty stops binding, while IPO stops at the target. IPO occupies the same slot in the stack as DPO, after SFT, trained offline on (prompt, chosen, rejected) triples with a frozen reference model.

Where IPO comes from#

IPO was introduced by Mohammad Gheshlaghi Azar, Mark Rowland, Bilal Piot, Daniel Guo, Daniele Calandriello, Michal Valko and Rémi Munos (Google DeepMind) in A General Theoretical Paradigm to Understand Learning from Human Preferences, posted in October 2023 and published at AISTATS 2024. The paper is mostly theory. It asks what DPO and RLHF actually optimize once you stop assuming a perfect Bradley-Terry reward, finds a failure mode, and proposes IPO as the simplest objective that avoids it.

The authors point at two approximations in standard RLHF. First, pairwise preferences are replaced by pointwise rewards through the Bradley-Terry model. Second, a reward model trained on that substitution is assumed to generalize to the policy's own outputs. DPO removes the second approximation but keeps the first, and the first is where the trouble lives.

The ΨPO objective#

Let be the true probability that response is preferred to for prompt , the distribution that generated the comparison responses, the reference policy and a regularization weight. For any non-decreasing function , Azar et al. define

In words: maximize a transformed win rate against the data distribution, while staying close to the reference. If and preferences follow Bradley-Terry, , and this objective has the same optimum as RLHF and DPO (their Proposition 1, with playing the role of DPO's ). The optimal policy has the familiar form

Two choices of Ψ in the ΨPO objective -4 -2 0 2 4 0 0.2 0.4 0.6 0.8 1 Ψ(q) = log(q/(1−q)), used by RLHF and DPO Ψ(q) = q, used by IPO preference probability q = p(y ≻ y′) Ψ(q)
Figure 1. The two Ψ functions. The logit used implicitly by RLHF and DPO goes to infinity as a preference becomes certain; the identity used by IPO stays bounded between 0 and 1.

Why the logit Ψ overfits

Suppose always beats : . Bradley-Terry then needs , and plugging that into the optimal policy gives for any value of . The KL term still appears in the objective, but it can no longer hold the policy anywhere near the reference. The paper's summary: the strength of the KL regularization becomes weaker and weaker the more deterministic the preferences.

Finite data makes it worse. Even if the true preference is 0.8, a pair that appears once or twice in the dataset has an empirical preference of exactly 1. Most prompts in a real preference dataset are compared exactly once, so almost every empirical preference is 0 or 1. Standard RLHF survives this in practice because its reward model is trained with regularization and early stopping and therefore underfits: it never assigns the infinite reward gaps the data technically asks for. DPO has no reward model to underfit, so it loses that implicit protection.

The IPO loss#

Setting to the identity bounds the quantity being maximized. Azar et al. derive a sampled loss for this case that needs only preference pairs. Define the log-likelihood-ratio gap

The IPO objective, starting from , is

Compare DPO, written with the same :

Both see each pair only through . DPO's loss decreases monotonically in , so it always prefers a larger gap. IPO's loss is minimized at and rises on either side, so a gap that overshoots the target is pulled back. The gradients make the difference concrete:

The IPO derivation also uses a symmetry trick worth knowing: each observed pair contributes both with label 1 and with label 0, which halves the variance of the estimate and collapses, up to a constant, to the single squared term above. The paper's interpretation is that IPO regresses the gap between the policy's and the reference's log-likelihood ratios onto ; the weaker the regularization (smaller ), the larger the gap it asks for.

Gradient pressure on the margin, DPO against IPO -2 0 2 -10 -5 0 5 10 15 20 IPO target 1/(2τ) DPO, β = 0.1 IPO, τ = 0.1 (target 5) log-ratio margin m (nats) push on margin, relative to m = 0
Figure 2. How hard each loss pushes the margin upward, as a function of the current margin (normalized to 1 at zero). DPO always pushes up, with a slowly decaying weight. IPO pushes up below its target of 5 nats (τ = 0.1) and pushes down above it.

Where IPO sits among its siblings

Tang et al. (2024) unify DPO, IPO and SLiC as one family: apply a convex function to . DPO uses the logistic loss , SLiC the hinge , IPO the squared loss up to rescaling. Their analysis shows how the shape of determines how offline losses regularize, and that this offline regularization is related to, but not the same as, the KL penalty in the RLHF objective. Calandriello et al. (2024) go further and show that an online version of IPO (pairs sampled from the current policy) is equivalent to Nash Mirror Descent, a self-play algorithm for general, non-Bradley-Terry preferences. That makes IPO a natural loss for online and iterative preference training.

Worked example by hand#

Take , so the target margin is nats. Use the same pair as in our DPO article: policy log-probs (chosen) and (rejected), reference and .

  • Log-ratio of chosen: . Log-ratio of rejected: . Gap .
  • IPO loss . Gradient : increase the gap.
  • Suppose training continues and the gap reaches . IPO loss , gradient : decrease the gap.
  • DPO with at : loss , gradient : still pushing the gap wider, gently but forever.

Now a case where the closed form is known. Three actions , uniform reference, and a dataset with each pair observed once in a strict order: , , . With uniform reference, is just the difference of log-probabilities. Let and , with target . IPO minimizes ; by symmetry , and setting the derivative to zero gives . For (), , so . For (), , giving . DPO on the same data drives for every .

Toy runs#

Replicating the three-action bandit

We reproduced the setup from Section 5.3 of the IPO paper: softmax policy over three actions, uniform reference, dataset , Adam with learning rate 0.01, minibatches of 9 sampled with replacement, 18,000 steps. We ran DPO with and IPO with at the same four values, three seeds each.

β or τDPO π(a), π(b), π(c)IPO π(a), π(b), π(c)IPO closed form π(a)
0.11.000, 0.000, 0.0000.961, 0.038, 0.0010.965
0.51.000, 0.000, 0.0000.565, 0.288, 0.1470.566
1.01.000, 0.000, 0.0000.452, 0.319, 0.2290.448
2.00.999, 0.001, 0.0000.391, 0.331, 0.2780.391

DPO ignores its regularization entirely and becomes greedy, which is exactly what the paper reports. IPO lands on the closed-form optimum (computed from ) to within about 0.005, and now does what a regularizer should: larger keeps the policy closer to uniform.

Probability of the dominant action, 3-action bandit 0 0.25 0.5 0.75 1 1.00 0.96 τ = 0.1 1.00 0.56 τ = 0.5 1.00 0.45 τ = 1.0 1.00 0.39 τ = 2.0 DPO IPO final probability of action a
Figure 3. Final probability of the dominant action a after 18,000 Adam steps, mean of three seeds. DPO (with β set to the same value as τ) collapses onto a at every setting; IPO interpolates toward the uniform reference as τ grows.

Deterministic labels with shared parameters

The bandit has no parameter sharing. To check that the effect survives generalization, we used a log-linear policy over 200 responses with 16 shared features (the same world as in our DPO article), a deterministic annotator (the higher true reward always wins) and only 400 pairs sampled from the reference (358 after removing pairs that drew the same response twice). Adam, learning rate 0.01, batch 32, 8,000 steps.

RunKL at step 2,000KL at step 8,000Mean margin h (nats)Train pair accuracy
DPO β = 0.13.685.0628.596.6%
DPO β = 0.53.435.2412.998.9%
IPO τ = 0.12.192.323.595.5%
IPO τ = 0.50.130.130.795.0%

With deterministic labels, raising DPO's from 0.1 to 0.5 did not reduce drift; KL kept climbing in both runs and ended slightly higher at . The mean margin of 28.5 nats is far beyond anything the data supports. IPO's KL plateaus within the first 2,000 steps and stays there, at a level set by . One caveat for reading this honestly: in this toy the true reward is exactly the direction the preferences reveal, so drift happens to help; the DPO runs reached a higher expected true reward (2.99 and 3.01, against 2.05 for IPO at τ = 0.1 and a reference value of 0.21). The point is control. In a real model, drift you did not ask for is where formatting breaks and capabilities regress, and IPO gives you a dial that actually limits it.

KL drift with deterministic labels, DPO against IPO (toy run) 0 2 4 0 2000 4000 6000 8000 DPO β = 0.1 DPO β = 0.5 IPO τ = 0.1 IPO τ = 0.5 optimizer step KL(policy ‖ reference), nats
Figure 4. KL from the reference during training with deterministic labels. DPO keeps drifting regardless of β; IPO settles at a level set by τ. Toy run, one seed.

The algorithm and data#

Input: SFT model, pairs D = {(x, y_w, y_l)}, tau
pi_ref = frozen copy; pi_theta = trainable copy
target = 1 / (2 * tau)
for each minibatch:
    h = (logp(pi_theta, y_w) - logp(pi_ref, y_w)) - (logp(pi_theta, y_l) - logp(pi_ref, y_l))
    loss = mean((h - target) ** 2)
    step optimizer
    log: mean h, fraction of pairs with h > target, KL estimate on samples, eval metric

The data is identical to DPO's: one prompt, two responses, a binary label. Anything that works for DPO (human comparisons, LLM-judge rankings, reward-model-scored samples from your own model) works for IPO, and you can switch between the two losses on the same dataset with one flag. IPO is most attractive exactly where DPO is weakest: small datasets, a single comparison per prompt, and judges that produce confident, near-deterministic labels.

The length question

The paper's uses full-sequence log-probabilities, so the margin and therefore the right scale with response length. Hugging Face TRL's implementation divides each log-ratio by the number of completion tokens before computing the squared loss; the code notes that this length normalization is not explicitly discussed in the paper and that the TRL maintainers confirmed the choice with the IPO authors. In practice this means two IPO runs with the "same" can behave very differently depending on the implementation. Check which one you are using before copying a value.

Hyperparameters#

τ (the target). Choose by thinking about the margin you want, not by analogy with DPO's . With per-token averaged log-ratios, a target of nats per token () is already a large separation; with summed log-ratios over a few hundred tokens, targets of 5 to 50 nats ( between 0.1 and 0.01) are plausible. For reference points: the OAIF paper used for IPO, and the SimPO authors searched for their IPO baselines. Sweep at least three values spaced by about 3x and pick on a downstream metric.

Learning rate and epochs. Start where you would for DPO (around 5e-7 to 1e-6 for full fine-tuning at 7B scale) and adjust. The squared loss produces gradients proportional to the distance from target, which can be large early on when the target is big, so keep warmup. Because IPO has a stable optimum, it is less sensitive to training for extra epochs than DPO; watching the fraction of pairs above target tells you when it has converged.

Batch size. The usual 64 to 128 pairs. The loss is a regression, so noisy small batches show up as jitter in the mean margin rather than as instability.

Compute and memory#

Exactly DPO's. Per pair: forward and backward through the policy on two sequences, forward through the frozen reference on the same two (or a single precomputation pass). Memory is roughly 16 bytes per parameter for the trainable policy with Adam in mixed precision, plus 2 bytes per parameter for a bf16 reference, plus activations for two sequences per example. With LoRA the reference costs nothing extra because it is the base model with adapters switched off. Switching from DPO to IPO is free in compute terms, which makes it a cheap ablation.

Failure modes#

Target too large. If is bigger than any gap the data can support, IPO behaves like a DPO with an odd loss shape: margins climb for the whole run and KL drifts. Diagnose by plotting the distribution of against the target. If almost no pairs reach it after an epoch, is too small.

Target too small. The policy barely moves, training accuracy rises to the high 90s quickly (any positive margin counts as correct) and downstream metrics do not change. In our toy, held KL at 0.13 nats and expected true reward rose only from 0.21 (the reference) to 0.60, against 2.05 at .

Pushing down good margins. Pairs whose gap already exceeds the target receive gradient that shrinks it, including pairs that are clean and easy. That is the intended regularization, but on a dataset mixing trivially easy and hard pairs, a single target can be too tight for some and too loose for others.

Label noise. Squared loss treats a mislabeled pair as an instruction to reach in the wrong direction. The loss is bounded per pair only by the reachable margin, so a few percent of flipped labels contribute disproportionately at large . Filter obvious ties and disagreements before training.

Implementation mismatch. Summed versus length-averaged log-ratios changes the meaning of by a factor equal to the response length. It is an easy mistake to make when copying a from a paper or another codebase.

What a healthy run looks like

Because the policy starts equal to the reference, every gap starts at and the initial loss is exactly : 25 for , 1 for . That gives you a free sanity check on the first logged step; any other value means the reference or the masking is wrong. From there the mean margin should rise quickly and then flatten below the target, because pairs the model cannot separate (ties, label noise, near-duplicates) hold the average down while easy pairs sit at or slightly above it. The loss should flatten at a level set by the spread of margins around the target, not keep falling toward zero. A DPO run on the same data has no such equilibrium: its loss keeps creeping down as margins on easy pairs grow without bound. If an IPO run's mean margin crosses the target and keeps climbing, something other than the IPO term is driving it, usually an added NLL term with too large a weight or a learning rate high enough that the optimizer overshoots.

Metrics to log: mean and distribution of relative to target, chosen and rejected log-ratios separately, KL to the reference on generated samples, output length, and a task metric.

When to use IPO#

SituationChoiceReason
Small dataset, one comparison per prompt, confident judge labelsIPObounded target keeps regularization effective
Large, diverse, noisy human preference dataDPOempirical preferences rarely saturate; well-trodden hyperparameters
Want to train many epochs or until convergenceIPOstable optimum instead of open-ended margin growth
Online or self-play preference trainingonline IPO / online DPOonline IPO connects to Nash-style self-play
Unpaired thumbs-up / thumbs-down dataKTOIPO needs pairs
Reference model does not fit in memorySimPO or ORPOreference-free

Published comparisons do not show IPO winning consistently on chat benchmarks. In the SimPO paper's tuned baselines, IPO was competitive with DPO in some settings and behind in others; OAIF found the online versions of DPO, IPO and SLiC all improved over their offline counterparts. The honest framing is that IPO is the better-behaved loss when your labels are close to deterministic, and an easy ablation otherwise. In POFE it is one option of the preference recipe, sharing data and evaluation with the DPO run so the comparison is apples to apples.

Minimal implementation#

import torch

def ipo_loss(logp_w, logp_l, ref_logp_w, ref_logp_l, tau=0.1,
             len_w=None, len_l=None):
    """logp_*: summed response log-probs, shape [B].
    Pass token counts len_w, len_l to use the length-averaged convention."""
    rw = logp_w - ref_logp_w
    rl = logp_l - ref_logp_l
    if len_w is not None:
        rw, rl = rw / len_w, rl / len_l
    h = rw - rl
    loss = ((h - 1.0 / (2.0 * tau)) ** 2).mean()
    return loss, {"margin": h.mean().item(),
                  "frac_above_target": (h > 1.0 / (2.0 * tau)).float().mean().item()}

In TRL, IPO is a loss type on the DPO trainer, with beta playing the role of and the length-averaged convention described above:

from trl import DPOConfig, DPOTrainer

args = DPOConfig(output_dir="ipo-out", loss_type="ipo", beta=0.5,
                 learning_rate=5e-7, num_train_epochs=1, bf16=True)
trainer = DPOTrainer(model=model, args=args, train_dataset=pairs,
                     processing_class=tokenizer)
trainer.train()

Further reading#

Start with the IPO paper's Sections 4 and 5 for the overfitting argument and the sampled loss; the others place IPO in the wider family.

Frequently asked questions#

What is the difference between IPO and DPO?

Both score a pair by the gap h between the chosen and rejected log-likelihood ratios. DPO minimizes −log σ(βh), which always rewards a larger gap. IPO minimizes (h − 1/(2τ))², which is smallest at a finite target and pulls the gap back if it overshoots. That keeps the policy near the reference when labels are deterministic.

Why does DPO overfit when preferences are deterministic?

Under Bradley-Terry, a preference of exactly 1 requires an infinite reward gap, and the resulting optimal policy assigns zero probability to the losing response whatever the KL weight. With one comparison per prompt, almost every empirical preference is 0 or 1, so DPO's regularization weakens. RLHF avoids this partly because its reward model underfits.

How do I choose τ for IPO?

Pick the margin you want: the target is 1/(2τ). With length-averaged log-ratios (as in TRL), τ around 0.5 to 1 gives targets of 1 to 0.5 nats per token; with summed log-ratios, τ of 0.01 to 0.1 gives 50 to 5 nats per sequence. Sweep a few values about 3x apart and select on a downstream metric.

Is IPO better than DPO in practice?

Not uniformly. In tuned comparisons such as the SimPO paper's baselines, IPO was competitive with DPO in some settings and behind in others. Its advantage is predictable regularization on small or near-deterministic datasets, and it costs nothing extra to try because it uses the same data and compute as DPO.

Does IPO need a reference model?

Yes. The gap h is measured relative to a frozen reference, normally the SFT model, exactly as in DPO. Memory and compute are the same as DPO, and the reference log-probabilities can be precomputed once.

References#

  1. Gheshlaghi Azar, M., Rowland, M., Piot, B., Guo, D., Calandriello, D., Valko, M., Munos, R. (2023). A General Theoretical Paradigm to Understand Learning from Human Preferences. arxiv.org/abs/2310.12036
  2. Rafailov, R., Sharma, A., Mitchell, E., Ermon, S., Manning, C. D., Finn, C. (2023). Direct Preference Optimization: Your Language Model is Secretly a Reward Model. arxiv.org/abs/2305.18290
  3. Tang, Y., Guo, Z. D., Zheng, Z., Calandriello, D., Munos, R., Rowland, M., Richemond, P. H., Valko, M., Ávila Pires, B., Piot, B. (2024). Generalized Preference Optimization: A Unified Approach to Offline Alignment. arxiv.org/abs/2402.05749
  4. Calandriello, D., Guo, D., Munos, R., Rowland, M., Tang, Y., Avila Pires, B., Richemond, P. H., Le Lan, C., Valko, M., Liu, T., Joshi, R., Zheng, Z., Piot, B. (2024). Human Alignment of Large Language Models through Online Preference Optimisation. arxiv.org/abs/2403.08635
  5. Guo, S., Zhang, B., Liu, T., Liu, T., Khalman, M., Llinares, F., Rame, A., Mesnard, T., Zhao, Y., Piot, B., Ferret, J., Blondel, M. (2024). Direct Language Model Alignment from Online AI Feedback. arxiv.org/abs/2402.04792
  6. Meng, Y., Xia, M., Chen, D. (2024). SimPO: Simple Preference Optimization with a Reference-Free Reward. arxiv.org/abs/2405.14734
  7. Bradley, R. A., Terry, M. E. (1952). Rank Analysis of Incomplete Block Designs: I. The Method of Paired Comparisons. doi.org/10.2307/2334029
  8. von Werra, L. et al. (Hugging Face) (2020). TRL: Transformer Reinforcement Learning (DPOTrainer, loss_type='ipo'). github.com/huggingface/trl

Bring a model and a metric.

Tell us what the model should get better at. A post-training engineer replies within one business day with a plan, a compute estimate and an eval design.