Preference tuning teaches a model which of two answers people prefer. Three small calculations carry the whole idea: a loss built from comparisons, a penalty that stops the model gaming its judge, and a margin that DPO reads straight off the model. Change the numbers and watch each one move. They come from alignment.py, so they match the chapter.
A reward model gives each answer a score. The Bradley-Terry model says the chance it agrees with the person is σ(rw − rl), where w is the answer they preferred and l the one they rejected.
The policy is optimised against the reward model, and left alone it finds text the reward model loves and people do not. The objective is the reward minus β times the KL divergence from the model it started as. Set β and see which candidate the optimiser picks.
honest answer (reward 4.00, KL 1.00) reward hack. The ringed point is where the two lines cross.
DPO drops the reward model. A policy trained under the penalised objective already carries a reward in its own log-ratio against the reference: r̂(y) = β(log πθ(y) − log πref(y)). Slide the policy away from the reference and watch the margin and the loss.
With β = 0.1 the three named stages are the chapter's table. At the start the policy is the reference, so the margin is 0 and the loss is log 2 = 0.6931, the same number the undecided Bradley-Terry pair gave. Moving past 1 over-corrects.
This is Adaptation and Alignment. Run alignment.py to print the same tables as text.