Visual walkthrough — Reward modeling
Step 1 — Two answers, two numbers
WHAT. For one prompt (the question a human asked) we have two answers. A human already told us which they liked: the winner and the loser . Our machine — the reward model — reads each answer and spits out a single number: a score.
Reading it out loud, symbol by symbol:
- :: the "niceness meter". The little subscript (theta) just means "its dials/settings are called " — the numbers we will later tune.
- :: the prompt (same for both answers).
- , :: the winning and losing answer.
- , :: two plain real numbers on a number line — that is all a "score" is.
WHY. We cannot argue about "which answer is better" mathematically until better is a number. Step 1 turns a fuzzy comparison into two dots on a line.
PICTURE. Two dots on a number line — the winner's dot sits to the right (higher) when the model is doing its job.
Step 2 — Only the gap between the dots matters
WHAT. Define the difference
- (Greek "Delta") :: literally "the gap". It is the winner's score minus the loser's score.
- :: winner is ahead (good).
- :: model got it backwards (bad).
- :: the model can't tell them apart (a tie — a degenerate case we return to in Step 6).
WHY use the difference and not the two scores separately? Because a human's choice has no absolute zero. If I like card A more than card B, that judgement is unchanged whether the meter reads or — both have . So the whole story must depend on only. Sliding both dots left or right by the same amount must change nothing. Watch the two rows in the figure: different absolute positions, same gap, and (spoiler) the same loss.
PICTURE. Two number lines stacked. Top: dots at and . Bottom: dots at and . The green "gap" bracket is identical length in both.
Step 3 — Turn the gap into a probability (why we need the S-curve)
WHAT. We want to predict the chance a human prefers the winner. A chance must live between and . But roams over the whole number line, . We need a squashing function that:
- sends a huge gap to almost ("surely the winner"),
- sends a huge negative gap to almost ("surely not"),
- sends to exactly (a coin flip),
- rises smoothly and never repeats.
The function that does exactly this is the logistic sigmoid :
Term by term:
- :: read "" as is preferred to; the whole thing is "probability the human picks the winner".
- (sigma) :: our squasher.
- :: raised to the power . It is huge when is very negative (so the fraction ) and tiny when is very positive (so the fraction ). This single term is what bends the S.
WHY the sigmoid and not a straight line? A straight line would eventually give probabilities above or below — nonsense. The sigmoid is the smallest, smoothest tool that maps the whole line into with a coin-flip at the middle.
PICTURE. The S-curve. Mark the three anchor points: hugs , hits exactly , hugs .
Step 4 — From "probability" to "loss" (why the )
WHAT. Training means: make the human's actual choice as likely as possible under our model. The likelihood of the observed choice is exactly . Maximizing a number is the same as minimizing its negative logarithm, so we define the loss of one example:
- :: the natural logarithm. It turns products into sums (handy when we multiply many examples' probabilities) and it explodes as its input approaches .
- the minus sign :: flips "big probability = good" into "small loss = good", so we can minimize.
Behaviour of :
- confident & correct ( large ): , , so — almost no penalty.
- coin flip (): , — a fixed middling penalty.
- confidently wrong ( large ): , — huge penalty.
Averaged over the dataset this is the parent's headline formula:
- :: the average over all preference triples in the data.
WHY and not, say, ? Because a wrong-and-confident answer should hurt without limit, dragging the model back hard. Only gives that unbounded penalty near probability ; a plain tops out at and lets confident mistakes off cheap.
PICTURE. Plot against : near-flat at on the right, passing through at , curving up steeply toward on the left.
Step 5 — The gradient: why the loss fixes itself
WHAT. To learn, we nudge the scores in the direction that lowers . That direction is the gradient — the slope of the loss with respect to each score. A famous identity () gives:
- :: "if I raise the winner's score a little, how does the loss change?" It is negative, meaning raising lowers loss — so training pushes the winner up.
- :: positive, so training pushes the loser down.
- :: the shared size of the nudge — call it the error signal.
The magic is in :
- already right ( big ): — tiny nudge, nothing to fix.
- wrong (): is large — big nudge, swap the order.
So the update is self-correcting: the size of the fix equals the size of the mistake.
WHY does this shape appear? Because the loss is flat where the model is confidently right (Step 4's right tail) and steep where it is confidently wrong (the left tail). Gradient = slope, so it is automatically small where things are fine and large where they are broken.
PICTURE. The loss curve from Step 4 with tangent-line arrows: a nearly flat tangent on the confident-right side (small push), a steep tangent on the confident-wrong side (big push).
Step 6 — Edge and degenerate cases (nothing left unshown)
WHAT & WHY. A derivation is only trustworthy if the boundaries behave.
| Case | Loss | Gradient size | Meaning | ||
|---|---|---|---|---|---|
| Confident correct | Leave it alone | ||||
| Exact tie | Max uncertainty, medium push | ||||
| Confident wrong | Hardest correction | ||||
| Shift both scores by | unchanged | unchanged | unchanged | unchanged | Scale/shift invariance |
- The tie () is the only place with no "right answer"; the loss sensibly sits at the coin-flip value and pushes with a middling .
- The shift-invariance row is the parent's warning made visible: only differences mean anything, so the raw reward number carries no global meaning (see the [!mistake] about absolute values in the parent). This is why in RLHF we mean-center rewards before feeding PPO.
PICTURE. Three mini number-lines side by side (correct / tie / wrong) with the resulting printed under each — the whole behavioural range at a glance.
Step 7 — Beyond two answers, and where this loss lives
WHAT. Given a human ranking of answers, we don't invent new math — we reuse Steps 1–5 on every ordered pair. With answers there are pairs; average their losses.
For : comparisons from one labelling effort.
WHY. One human ranking yields many training signals cheaply, and averaging tames noise in any single pair.
Downstream. The trained then becomes the objective the policy climbs, leashed by a KL divergence penalty so it can't wander to where is confidently wrong — that failure is Goodhart's law in action. A newer route, DPO Direct Preference Optimization, folds this very same loss directly into policy training, skipping the separate model. Either way, the S-curve you drew in Step 3 is the beating heart.
The one-picture summary
Everything above, as one flow: two answers → two scores → a gap → the sigmoid → the loss → a self-correcting gradient.
Recall Feynman retelling — the whole walkthrough in plain words
A human points at the answer they like more. We give both answers a score (Step 1). We only ever care about the gap between the two scores, never the raw numbers — the same gap means the same thing whether the scores are or (Step 2). To turn that gap into a chance of preferring the winner, we push it through an S-shaped squasher that lives strictly between 0 and 1, is a coin-flip in the middle, and never wraps around (Step 3). We then say "make the human's real choice as likely as possible", which — after taking a negative logarithm so we can minimize — becomes our loss: tiny when we're confidently right, huge when we're confidently wrong (Step 4). The slope of that loss (the gradient) is automatically small where we're already right and big where we're wrong, so the meter fixes its own mistakes in proportion to how badly it messed up (Step 5). Ties and score-shifts behave exactly as they should (Step 6), and a ranking of many answers is just lots of these pair comparisons averaged together — later fed to a policy that climbs the meter on a short leash (Step 7).
Recall Quick self-check
The loss when ::: Why does raising lower the loss ::: is negative, so increasing the winner's score decreases loss What cancels when you divide Bradley–Terry top and bottom by ::: the absolute scale , leaving only Number of pairs from a ranking of :::