4.4.4 · D3Alignment, Prompting & RAG

Worked examples — Direct Preference Optimization (DPO)

2,331 words11 min readBack to topic

Everything below uses two quantities from the parent note. Let us re-say them in words so no symbol is unearned:

We will keep one fact handy for every example, so define it once:


The scenario matrix

Every DPO pair, no matter how weird, lands in one of these cells. The examples that follow cover all of them.

# Cell class Concretely Example
A Winner ahead () model already prefers Ex 1
B Winner behind () model prefers the loser — a mistake Ex 2
C Perfect tie / degenerate start () , or ratios equal Ex 3
D Limit loss floor, saturation, dead gradient Ex 4
E Limit loss blow-up, exploding gradient Ex 4
F Same , sweep (small→large) how the leash bites Ex 5
G Gradient sign / weight check which way does each response move? Ex 6
H Real-world word problem chatbot politeness pair, whole batch Ex 7
I Exam twist: sign trap negative log-ratios that still satisfy the model Ex 8
Figure — Direct Preference Optimization (DPO)

The worked examples

Figure — Direct Preference Optimization (DPO)
Figure — Direct Preference Optimization (DPO)

Active recall

Recall Cover the answers and predict each cell

Which cell has loss exactly ? ::: Cell C — the tie / untrained start, , for any . Sign of margin whenever the model is currently wrong? ::: Negative (), giving . Two negative log-ratios — can the loss still be small? ::: Yes (Ex 8) — only the difference matters, so the winner just needs to drop less than the loser. As rises with fixed , loss goes...? ::: Down (Ex 5) — bigger margin, more saturation, tighter leash, less deviation. Where is the gradient dead vs maximal? ::: Dead at large positive margin (confident-correct, Ex 4D); near-maximal at large negative margin (confident-wrong, Ex 4E). Batch loss of Ex 7? ::: , dominated by the one negative-margin pair.