The conditioning notation π(y∣x): every probability is conditioned on the promptx. So πθ(yw∣x) means "the probability the policy assigns to producing the winning response ywgiven the prompt x." We always keep the same x when comparing yw and yl. In some exercises we write πθ(yw) as shorthand, but x is always implicitly there and always the same for both responses in a pair.
The partition function Z(x): when we solve the RLHF objective for the best policy, the answer must be a valid probability distribution — its values over all possible responses must sum to 1. The quantity that rescales it to do so is
Both log-ratios are log1=0, so r^w=r^l=0, margin =0, and ℓ=−logσ(0)=−log(0.5)=log2≈0.693.
This is the coin-flip baseline: before any training the model has no preference, so it scores exactly log2 per example.
Recall Solution
The margin is negative, meaning the model gives the loser a higher implicit reward than the winner — the model is wrong on this pair. Since −logσ is decreasing in z (see figure), any z<0 gives loss abovelog2.
Positive margin ⇒ loss below log2: the model already leans the right way.
Recall Solution
The reward margin is z=βΔ.
β=0.1: z=0.2, σ(0.2)≈0.5498, ℓ≈0.598.
β=0.5: z=1.0, σ(1.0)≈0.7311, ℓ≈0.313.
Larger β turns the same policy shift into a bigger reward margin, saturating the sigmoid → smaller loss → the model is "satisfied" and deviates less. Bigger β = tighter leash.
Recall Solution
ℓ=log2 happens only when σ(z)=0.5, i.e. z=0. Since z=βΔ and β=0, we need Δ=0: the winner and loser have identical policy shifts. This is exactly the initialization / indifference case.
r^(x,yw)−r^(x,yl)=βlogπref(yw∣x)π(yw∣x)+βlogZ(x)−[βlogπref(yl∣x)π(yl∣x)+βlogZ(x)].
The two βlogZ(x) terms are identical because Z(x) depends only on x, and both responses share the same x. They subtract to 0:
=βlogπref(yw∣x)π(yw∣x)−βlogπref(yl∣x)π(yl∣x).Condition: both responses must be conditioned on the same promptx. That is why DPO needs pairs per prompt — Bradley-Terry Model uses a difference of scores.
Recall Solution
Deriving the weight. We need dzd[−logσ(z)]. Two facts:
Therefore
dzdℓ=−(1−σ(z))=−σ(−z),
using the symmetry 1−σ(z)=σ(−z). By the chain rule the parameter gradient is dzdℓ⋅∇θz, and ∇θz=β(∇θlogπθ(yw∣x)−∇θlogπθ(yl∣x)). So the multiplying factor (the "weight") is exactly σ(−z)=σ(r^l−r^w). Intuition:1−σ(z) is "how much probability the model is missing" on getting the winner right — a bigger miss means a bigger push.
The weight is large exactly when the model ranks the loser above the winner (a mistake), and near zero when the model is already correct. DPO automatically focuses on hard/wrong examples — a built-in hard-example weighting, no explicit Reward Modeling needed.
Recall Solution
Raw version:βlogπθ=βlog0.95, a large-ish absolute value driven mostly by the token already being common — the model gets "credit" for probability it didn't create.
Ratio version:βlog0.90.95=βlog(1.056)≈β(0.0541) — a small reward, because the model barely changed anything.
The ratio rewards only the change the policy made over the reference. This is what prevents collapse onto high-frequency generic text (degeneration) — the failure the raw version invites.
Notice pair 2 (negative margin, a mistake) dominates the loss — consistent with the L3.2 hard-example weighting.
Recall Solution
We need z=βΔ=1.0 with Δ=4.0, so β=1.0/4.0=0.25.
If instead β=2.5 (ten times larger), then for the same Δ=4.0, z=10.0, deep in the saturated region (σ(10)≈0.99995). The gradient nearly vanishes, so the model stops moving early → it deviates much less from πref. Larger β = stronger leash, as in PPO - Proximal Policy Optimization's KL penalty analogue.
Recall Solution
Take the natural log of both sides:
logπ∗=−logZ(x)+logπref+β1r(x,y).
Isolate β1r:
β1r(x,y)=logπ∗−logπref+logZ(x)=logπrefπ∗+logZ(x).
Multiply through by β:
r(x,y)=βlogπref(y∣x)π∗(y∣x)+βlogZ(x).■
This is the bridge: the reward is now written in terms of the policy, which is what lets us delete the separate reward model.
z→+∞:e−z→0, so ℓ→log1=0. The model confidently prefers the winner → no loss, no gradient. (Fully learned pair.)
z=0:ℓ=log2≈0.693. The indifference / initialization baseline.
z→−∞:e−z dominates, ℓ≈log(e−z)=−z→+∞, growing linearly in ∣z∣. Confidently wrong pairs incur unbounded, linearly-growing loss — DPO punishes confident mistakes hard but not explosively (linear, not exponential), keeping training stable.
Recall Solution
If yw=yl then πθ(yw∣x)=πθ(yl∣x) and likewise for πref, so r^w=r^l exactly. Margin z=0, loss =log2, for every β and every parameter setting.
Why the gradient is zero. From L3.2 the parameter gradient of a pair is
∇θℓ=−βσ(r^l−r^w)(∇θlogπθ(yw∣x)−∇θlogπθ(yl∣x)).
Here two things both hit zero. First, the weight is σ(r^l−r^w)=σ(0)=0.5 (finite). Second, and decisively, since yw=yl the two log-prob terms are the same function, so their gradients are identical and ∇θlogπθ(yw∣x)−∇θlogπθ(yl∣x)=0. The product is −β⋅0.5⋅0=0.
So the pair contributes no learning signal but still counts toward the batch loss, dragging the reported average toward log2 and wasting compute. Such pairs should be filtered out.
Recall Solution
Both margins equal r^w−r^l=0.3, so both give the same loss
ℓ=−logσ(0.3)=−log(0.5744)≈0.554,
and the same gradient weight σ(r^l−r^w)=σ(−0.3)≈0.4256. Pair A gives σ(2.7−3.0)=σ(−0.3) and Pair B gives σ(0.0−0.3)=σ(−0.3) — literally the same input, hence identical.
Why DPO treats them the same. The loss depends only on the differencer^w−r^l, never on the absolute reward levels 3.0 and 2.7 versus 0.3 and 0.0. This is by design: absolute r^ values carry the arbitrary βlogZ(x) offset that cancels in the difference (L3.1 / L4.3). So only the relative preference strength matters — exactly what the Bradley–Terry model encodes. Pair A's larger absolute rewards are completely invisible to the objective; a pair is "learned" based on how much the winner beats the loser, not on how large either raw score is.
Recall Solution
ℓ(z)=−logσ(z) is a strictly decreasing function of z (since σ is strictly increasing and −log is decreasing). At z=0, ℓ=log2. Therefore:
z>0⟺ℓ(z)<ℓ(0)=log2 (model prefers winner ⇔ loss below baseline).
z<0⟺ℓ(z)>log2 (model prefers loser ⇔ loss above baseline).
The equivalence is exact because ℓ is strictly monotone, so it crosses log2 exactly once, at z=0. ■
Why is the gradient weight large on wrong examples?
Does DPO loss depend on absolute reward or only the difference?
What happens to deviation when β increases?
Answers: 1) z=0. 2) Linearly, as −z. 3) Weight =σ(r^l−r^w), near 1 when the loser is ranked above the winner. 4) Only the difference r^w−r^l. 5) Deviation decreases (tighter leash).