Worked examples — Reinforcement Learning from Human Feedback (RLHF)
Parent: Reinforcement Learning from Human Feedback (RLHF). This deep dive drills the numbers behind RLHF until no scenario can surprise you. We reuse only three tools you already met in the parent: the sigmoid , the Bradley–Terry reward-difference likelihood, and the KL leash. Every symbol below is re-earned in plain words before use.
Before we start, one shared reminder of the two atoms we lean on everywhere:

Read the three landmark points off that curve now, because every example uses them:
- — zero gap means a coin flip.
- — a huge positive gap means "certainly the winner."
- — a huge negative gap means "certainly wrong."
And the KL leash term, restated once so the word problems can cite it:
The scenario matrix
Every RLHF numerical question falls into one of these cells. The examples that follow each carry a tag like (Cell A) so you can see the whole space is covered.
| Cell | Case class | What's special about it |
|---|---|---|
| A | RM loss, model already correct () | small positive loss |
| B | RM loss, model exactly tied (, gap ) | degenerate midpoint, loss |
| C | RM loss, model wrong () | large loss, strong correction |
| D | RM limiting behaviour (gap ) | loss or |
| E | RM scale invariance (add constant to both rewards) | loss unchanged |
| F | KL leash, policy more confident than SFT | positive penalty (log-ratio ) |
| G | KL leash, policy less confident than SFT | negative penalty — a bonus (log-ratio ) |
| H | KL leash, policy equals SFT | zero penalty |
| I | Combined reward-minus-penalty decision (word problem) | does the reward gain beat the leash? |
| J | Exam twist — accuracy vs. margin, or full sequence KL | subtle "feels right but wrong" |
Example 1 — Model already ranked the winner higher (Cell A)
Forecast: Guess first — will the loss be big or small? The model already prefers the true winner, so we expect a small loss.
- Gap . Why this step? Bradley–Terry says only the difference of rewards matters, never the absolute values. The comparison is our only data.
- Probability of correct ranking . Why this step? The sigmoid turns the reward gap into "chance we'd predict this winner." sits on the rising right side of the s-curve — clearly above .
- Loss . Why this step? Loss is negative log-likelihood: correct-and-confident small loss.
Verify: confirms the model is already right, and is well below the tied-case value — consistent with "model was correct." ✓
Example 2 — Exact tie: the degenerate midpoint (Cell B)
Forecast: The gap is zero — the model has no opinion. Guess: it should be penalized for not having learned the preference yet. How much?
- Gap . Why this step? A tie is the boundary between "right" and "wrong" — worth pinning down exactly.
- Probability . Why this step? Landmark point from the figure: zero gap is a coin flip.
- Loss . Why this step? This is the reference loss — every comparison starts here before the RM learns anything.
Verify: Note was arbitrary; any equal pair gives the same . The value sits between the correct case (Ex. 1, ) and the wrong case (Ex. 3, ), exactly where a "no-opinion" answer belongs. ✓
Example 3 — Model got it backwards (Cell C)
Forecast: The model is confidently wrong. Guess: loss much larger than the tied .
- Gap . Why this step? A negative gap means the model prefers the loser — the sign carries the mistake.
- Probability of correct ranking . Why this step? Negative lands on the left side of the s-curve, below : the model thinks the true winner is unlikely.
- Loss . Why this step? Big loss big gradient strong correction. This is the point: wrong-and-confident is punished hardest.
Verify: By the symmetry , we have . ✓ And : the wrong case is punished harder than the right case with the same gap size.
Example 4 — Limiting behaviour of the RM loss (Cell D)
Forecast: Guess the two extremes: one loss should shrink toward , the other should explode.
- Hugely right: , loss . Why this step? As , , so and . The model is certain and correct — almost nothing left to learn.
- Hugely wrong: , loss . Why this step? As , , and . Note for large the loss is — it grows linearly, no explosion faster than that, which is why training stays stable.
Verify: The two limits bracket the whole range: , minimum at gap, unbounded above. Consistent with the s-curve saturating at both ends. ✓
Example 5 — Scale invariance: the zero point is arbitrary (Cell E)
Forecast: Guess before computing — should the loss move if we shift both rewards equally?
- Shifted gap . Why this step? The constant cancels in the subtraction. This is the whole reason the RM output has no absolute meaning — only differences survive.
- Loss — identical to Example 1. Why this step? Confirms the common mistake that "the RM is an absolute quality score" is false. It's a relative score.
Verify: . Same number, same loss. ✓
Example 6 — KL leash: policy MORE confident than SFT (Cell F)
Forecast: The policy is more confident than the trusted model. Guess the sign of the penalty.
- Log-ratio . Why this step? Positive because the policy inflated this token's probability above SFT — exactly the drift the leash watches for.
- Penalty . Why this step? This amount is subtracted from the token's reward: "only be this bold if the reward gain clearly beats ."
Verify: Sign check — policy more confident log-ratio positive penalty (a cost). Matches the parent note's worked example. ✓
Example 7 — KL leash: policy LESS confident than SFT gives a BONUS (Cell G)
Forecast: Many students assume the KL penalty is always a cost. Guess: cost or bonus here?
- Log-ratio . Why this step? Negative because the policy is less confident than SFT on this token — it pulled probability away.
- Penalty . Why this step? Subtracting a negative number adds to the reward — a small bonus for staying humble / closer-to-uniform than SFT on this token.
Verify: Exact sign-mirror of Example 6: became . The per-token log-ratio can be either sign; only the expected value over the whole response, the true , is guaranteed non-negative. ✓ (See KL Divergence.)
Example 8 — KL leash: policy EQUALS SFT (Cell H)
Forecast: No drift. Guess the penalty.
- Log-ratio . Why this step? Identical probabilities ratio .
- Penalty . Why this step? The leash is slack when the policy agrees with the trusted model — it only bites on departures. This is the degenerate/zero case of the KL term.
Verify: regardless of ; a fully un-drifted policy pays nothing. ✓
Example 9 — Combined decision: does the reward beat the leash? (Cell I — word problem)
Forecast: The bold phrasing has higher raw reward (). Guess: does it still win after paying the KL cost?
- Bold phrasing net value . Why this step? We subtract Example 6's penalty because that's the drift cost of being bold.
- Safe phrasing net value . Why this step? Example 8's zero penalty — SFT already likes it, no leash cost.
- Compare: , so the safe phrasing wins on the full objective. Why this step? The raw-reward lead of the bold option () is smaller than its leash cost, so the leash correctly vetoes it. This is PPO's objective in miniature.
Verify: Raw-reward gap penalty, so the bold option must lose — and confirms it. The leash prevented a small reward bump from buying a big confidence drift. ✓
Example 10 — Exam twist: accuracy is NOT the loss (Cell J)
Forecast: Both are "correct" (positive gaps). Guess whether the mean loss is really near zero.
- Loss 1 . Why this step? is barely positive — correct but unconfident, near the tied midpoint . Accuracy says "right"; the loss says "barely."
- Loss 2 . Why this step? is confidently correct — tiny loss.
- Mean loss . Why this step? Far from zero, even at 100% accuracy — because loss rewards margin, not just the sign of the gap. This is why RM training keeps improving after accuracy plateaus.
Verify: accuracy but mean loss ; and comparison 1's sits just under the tied bound , exactly as "barely correct" should. The claim is false. ✓
Recall Self-check clozes
The RM loss depends only on the reward difference , never absolute values.
A tied comparison () gives loss :::
Adding the same constant to both rewards changes the loss by ::: nothing (scale invariance)
When the policy is less confident than SFT on a token, the KL term acts as a ::: bonus (negative penalty)
A batch at 100% ranking accuracy can still have loss well above zero because loss rewards ::: margin, not just the sign of the gap