Iterative Alignment › Iterative DPO

Michael BrenndoerferJanuary 5, 202610 min read
Language AI HandbookAll chapters
Part 37 of 67Alignment and RLHF
Chapter 287Iterative Alignment › Iterative DPO
Reading section 3 of 12 · Iterative DPO · 10 minSection 3 of 12 · 10 min

Book contents

Section 3 of 12 · 10 min read

Iterative Alignment › Iterative DPOOne section · Sections in this chapter3 / 12 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

As we discussed in the DPO chapters, Direct Preference Optimization implicitly defines a reward function through the log-probability ratio between the policy and reference model. This mathematical relationship makes the reference model central to what DPO learns. The reference model is an anchor point that defines the baseline against which improvements are measured. When we iterate DPO, we have a choice: keep the original reference model fixed, or update it at each iteration. This choice significantly affects training dynamics and the final model's behavior.

Fixed Reference Iteration

The simplest form of iterative DPO keeps the original reference model πref\pi_{\text{ref}} fixed across all iterations. At each round tt, we generate responses from the current policy πt\pi_t, collect preferences, and train to get πt+1\pi_{t+1}. This approach maintains a consistent anchor point throughout the entire iterative process, always measuring progress relative to where the model started.

The loss at iteration tt becomes:

L(t)=−E(x,yw,yl)∼D(t)[log⁡σ(βlog⁡πθ(yw∣x)πref(yw∣x)−βlog⁡πθ(yl∣x)πref(yl∣x))]\mathcal{L}^{(t)} = -\mathbb{E}_{(x, y_w, y_l) \sim \mathcal{D}^{(t)}} \left[ \log \sigma \left( \beta \log \frac{\pi_\theta(y_w|x)}{\pi_{\text{ref}}(y_w|x)} - \beta \log \frac{\pi_\theta(y_l|x)}{\pi_{\text{ref}}(y_l|x)} \right) \right]

Unpacking the formula components clarifies how they guide iterative training:

  • L(t)\mathcal{L}^{(t)}: the loss function minimized at iteration tt
  • E\mathbb{E}: the expectation operator averaging over all preference pairs in the dataset
  • D(t)\mathcal{D}^{(t)}: the dataset of preferences collected from responses generated by the current policy πt\pi_t
  • πθ\pi_\theta: the policy model currently being trained (parameterized by θ\theta)
  • πref\pi_{\text{ref}}: the fixed reference model (usually the initial policy)
  • xx: the input prompt
  • yw,yly_w, y_l: the winning and losing responses, respectively, for prompt xx
  • σ\sigma: the logistic sigmoid function
  • β\beta: the temperature parameter controlling the strength of the KL penalty
  • βlog⁡πθ(y∣x)πref(y∣x)\beta \log \frac{\pi_\theta(y|x)}{\pi_{\text{ref}}(y|x)}: the implicit reward term (higher values indicate the policy is more likely to generate yy than the reference)

The key change from standard DPO is that D(t)\mathcal{D}^{(t)} contains preferences over responses generated by πt\pi_t, not the original reference model. This subtle but important difference ensures the model learns from comparisons that reflect its current capabilities rather than from stale comparisons between outputs it no longer produces. The model receives feedback on the kinds of responses it generates now. This makes the training signal directly relevant to improving current behavior.

However, keeping a fixed reference creates a growing gap between the reference and policy distributions. As the policy improves over iterations, it diverges further from πref\pi_{\text{ref}}. The implicit reward function r(x,y)=βlog⁡πθ(y∣x)πref(y∣x)r(x, y) = \beta \log \frac{\pi_\theta(y|x)}{\pi_{\text{ref}}(y|x)} now compares very different distributions. When the policy assigns high probability to a response that the reference considers extremely unlikely, the log ratio becomes very large. Conversely, when the policy considers a response unlikely but the reference assigns moderate probability, the log ratio becomes very negative. These extreme values can destabilize training by creating large gradients that push the model erratically.

Rolling Reference Iteration

A more common approach updates the reference model at each iteration. After training round tt, we set πref(t+1)=πt\pi_{\text{ref}}^{(t+1)} = \pi_t before starting round t+1t+1. This keeps the reference close to the current policy, maintaining stable gradients and so that the log probability ratios remain in a reasonable range throughout training.

The rolling reference focuses on incremental improvements instead of measuring progress against the initial model. By using the previous iteration's policy as the reference, we are essentially asking: "Given where we are now, which responses represent improvements?" This framing naturally prevents the extreme probability ratios that arise when comparing against a very different reference distribution.

The iterative procedure becomes:

  1. Initialize π0\pi_0 with a supervised fine-tuned model
  2. Set πref(1)=π0\pi_{\text{ref}}^{(1)} = \pi_0
  3. For each iteration t=1,2,…,Tt = 1, 2, \ldots, T:
    • Generate responses from πt−1\pi_{t-1} on a set of prompts
    • Collect preferences over response pairs
    • Train πt\pi_t using DPO with reference πref(t)\pi_{\text{ref}}^{(t)}
    • Update πref(t+1)=πt\pi_{\text{ref}}^{(t+1)} = \pi_t

This rolling reference approach is sometimes called online DPO because the training data comes from the current policy rather than a static offline dataset. The term "online" here refers to the fact that data generation is interleaved with training, creating a dynamic feedback loop between model behavior and the training signal.

Rolling reference training starts from a neutral position. The policy and reference are identical at the beginning of each round, so the log probability ratios start at zero for all responses. This means the training signal comes entirely from the preference comparisons in the current iteration's dataset, without any accumulated bias from previous iterations. The model learns to improve relative to its immediate predecessor, and the cumulative effect of many such improvements can be substantial.

Out[4]:
Visualization
Line plot showing policy and reference positions over six iterations. Blue lines depict a policy that moves away from a stationary fixed reference, while red lines show a rolling reference that tracks the policy closely.
Policy and reference positions over iterations for fixed versus rolling reference strategies. The fixed reference stays at zero while the policy drifts away, whereas the rolling reference follows the policy at each step.
Line plot of log ratio gap versus iteration. The blue fixed-reference line grows linearly with a shaded region showing accumulated divergence, while the red rolling-reference line remains flat and bounded.
Log probability ratio gap over iterations for fixed and rolling reference strategies. The fixed reference accumulates an ever-growing gap, while the rolling reference keeps the ratio bounded to one iteration of improvement.

IPO for Iterative Training

Recall from our discussion of DPO variants that Identity Preference Optimization (IPO) avoids the length exploitation issues that can plague DPO over multiple iterations. The problem with standard DPO becomes particularly acute in iterative settings: if the model learns that slightly longer responses tend to win preference comparisons, it will generate longer responses, which will then be compared against each other, and the longest will again tend to win. This feedback loop can drive response length to extreme values over many iterations.

IPO addresses this concern through a fundamentally different objective formulation. Rather than using the sigmoid function to bound the preference probability, IPO directly targets a specific margin between the preferred and dispreferred log probability ratios. The IPO objective is:

LIPO=E(x,yw,yl)[(log⁡πθ(yw∣x)πref(yw∣x)−log⁡πθ(yl∣x)πref(yl∣x)−12β)2]\mathcal{L}_{\text{IPO}} = \mathbb{E}_{(x, y_w, y_l)} \left[ \left( \log \frac{\pi_\theta(y_w|x)}{\pi_{\text{ref}}(y_w|x)} - \log \frac{\pi_\theta(y_l|x)}{\pi_{\text{ref}}(y_l|x)} - \frac{1}{2\beta} \right)^2 \right]

The components of the IPO formula prevent the runaway behavior seen in DPO:

  • LIPO\mathcal{L}_{\text{IPO}}: the Identity Preference Optimization loss
  • E\mathbb{E}: the expectation operator averaging over the dataset
  • πθ\pi_\theta: the policy model being trained
  • πref\pi_{\text{ref}}: the reference model
  • xx: the input prompt
  • yw,yly_w, y_l: the preferred and dispreferred responses for prompt xx
  • β\beta: the hyperparameter derived from the KL regularization strength

This objective minimizes the squared error between the log-likelihood ratio gap and a finite target margin of 1/(2β)1/(2\beta). The key insight is that IPO does not simply try to make the preferred response more likely than the dispreferred one; it tries to make the gap between them equal to a specific target value. Once the model achieves this target margin, further increasing the gap raises the loss. This built-in saturation prevents the model from pushing probability ratios to extreme values.

Out[5]:
Visualization
Line plot of DPO loss versus log-ratio margin showing a monotonically decreasing steelblue curve with an annotation showing the loss keeps decreasing without saturation.
DPO loss as a function of the log-ratio margin. The loss decreases monotonically as the margin grows, with no minimum, which can incentivize unbounded length or style exploitation over iterative training rounds.
Line plot of IPO loss versus log-ratio margin showing a coral parabolic curve with a green vertical dashed line and scatter point at the target margin minimum, annotated as the minimum at target margin.
IPO loss as a function of the log-ratio margin. A parabolic curve reaches its minimum exactly at the target margin, giving symmetric regularization that prevents the model from pushing probability ratios to extreme values.

Unlike DPO, which tries to maximize the gap (bounded only by the asymptotic behavior of the sigmoid), IPO targets this specific margin, preventing the model from pushing probability ratios to extreme values. The squared error formulation means that overshooting the target margin is penalized just as much as undershooting it. This symmetric penalty structure provides natural regularization that becomes increasingly important over multiple iterations where small biases otherwise compound into significant distortions.