Foundations to Frontier
Tests

Reward hacking, overoptimization

A reward model is only a proxy for what people want. Optimise against it hard enough and the policy finds responses the proxy overrates: longer answers, confident-sounding errors, flattery, tests that are special-cased. True quality then stops improving or falls while the proxy score keeps rising (Goodhart's law). Gao et al. measured this over-optimisation: true reward first rises with the KL from the reference and then falls, with the peak moving later as the reward model gets bigger. This page covers the forms of reward hacking, the over-optimisation curve and the defences. Those defences are KL penalties, early stopping on held-out human judgements, reward-model ensembles, length control and better reward models. In the exercises you compute best-of-n KL and the Gao functional form. You then optimise three flawed proxies ever harder over 256 samples per prompt. With light-tailed proxy errors, more optimisation kept helping (true reward 0 → 2.0). With heavy-tailed errors, the proxy soared to 42 while true reward stayed near 0.1. With a rare exploit the proxy overrates, true reward peaked at 0.35 and then fell to −0.85, below the reference.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

When the score stops measuring what we want

If a student is graded only on essay length, they learn to write long essays, not good ones. A language model trained against a reward model does the same: it finds whatever the scorer likes, including things the scorer likes by mistake. A little optimisation helps; too much makes the answers worse even while the score keeps rising. This is called reward hacking, an example of Goodhart’s law. The demo shows the score and the real quality diverging as pressure increases.

Alignment lab
Proxy (red) = true reward + a bonus for length. At this pressure: proxy 1.34, true 0.68. Pushing harder keeps raising the proxy while true reward falls: Goodhart's law.
Why engineers care

For any AI system tuned against an automatic score (a simulator, a test suite, a learned judge), plan for the system to exploit the score’s blind spots, and keep an independent check of real quality.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Goodhart's law: when a measure becomes a target…
  2. 2. Reward hacking means…
  3. 3. Under heavy optimisation, true quality can…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Common hacks in LLMs: verbosity, confident tone over correctness, sycophancy (agreeing with the user), formatting tricks, hedging boilerplate; in code RL, special-casing or editing tests.
  • Over-optimisation curve (Gao et al., 2023): true (gold) reward against d = √KL. Best-of-n follows d(α − βd); RL follows d(α − β log d). The peak moves later for larger reward models and more preference data.
  • Best-of-n KL: log n − (n − 1)/n; a cheap way to apply controlled optimisation pressure.
  • Why it happens: the policy selects responses where the proxy is high, and among those the proxy’s errors are biased upwards (winner’s curse). Rare responses the proxy badly overrates are found by strong optimisation.
  • Defences: KL penalty or KL budget; early stopping on held-out human or gold evaluation; reward-model ensembles (mean − k·std, or minimum); length penalties and normalisation; retraining the reward model on the policy’s new outputs (iterated RLHF); verifiable rewards where possible.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Gao et al. plot true reward against…
  2. 2. The over-optimisation peak moves later with…
  3. 3. A defence against reward hacking:

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Detecting and limiting reward hacking

Exercise 1.

  • Compute the KL of best-of-n.
  • Evaluate the Gao et al. best-of-n functional form.
  • Find where that curve peaks.

Practice.

  • Log the proxy reward and a held-out true signal (human ratings, a stronger judge, verifier pass rate) at every checkpoint; stop when the true signal plateaus.
  • Track response length, refusal rate and other easy exploits during training.
  • Use a reward-model ensemble and penalise disagreement.
  • Regularly read samples: hacks are often obvious to a human and invisible in the metrics.
for step, batch in enumerate(loader):
    trainer.step(batch)
    if step % 200 == 0:
        proxy = eval_reward_model(policy, heldout_prompts)
        gold = eval_human_or_strong_judge(policy, heldout_prompts)
        log(step=step, proxy=proxy, gold=gold, kl=trainer.kl(), length=mean_length(policy))
        if gold < best_gold - tol: break        # stop when true quality turns down
🐍 Exercise 1: best-of-n KL and the over-optimisation curve
Implement the best-of-n KL, the Gao et al. curve and its peak.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Choose checkpoints by…
  2. 2. An ensemble defence penalises…
  3. 3. Hacks are often spotted by…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Light vs heavy tails. Suppose proxy = true + error, independent. If the error is Gaussian (light-tailed), selecting the highest proxy still selects for high true reward: E[true | proxy] grows linearly in the proxy, so optimisation always helps, just less efficiently. If the error is heavy-tailed, the largest proxy values are almost always caused by huge errors, not by good responses. Then E[true | proxy] returns towards the mean, and hard optimisation buys almost nothing (‘catastrophic Goodhart’, Kwa et al., 2024).

Exploitable flaws. If a class of responses is truly bad but overrated, mild optimisation mostly picks good normal responses, while strong optimisation finds the flawed class, whose proxy beats every honest response. True reward then rises and falls below the starting point. This is the shape Gao et al. observed.

Policy class matters. A tilted distribution over many samples puts weight on the exploit as soon as any is present. Best-of-n with small n often contains no exploit at all, so it can peak higher. The ability to find rare exploits grows with the policy’s freedom and the optimisation strength.

📝 Quick check (Level 3)
0/3 answered
  1. 1. With Gaussian proxy errors, more optimisation…
  2. 2. With heavy-tailed errors, top proxy scores are mostly…
  3. 3. An exploitable flaw produces…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How does the shape of a reward model’s errors decide whether optimising harder helps or hurts?

History.

  • C. Goodhart (1975) and M. Strathern’s phrasing of Goodhart’s law.
  • V. Krakovna et al., “Specification gaming examples in AI” (2020).
  • L. Gao, J. Schulman and J. Hilton, “Scaling laws for reward model overoptimization” (ICML 2023).
  • T. Kwa, D. Thomas and A. Garriga-Alonso, “Catastrophic Goodhart” (2024).

Exercise 2.

  • Setup: 400 prompts, each with 256 candidate responses from the reference policy; true reward N(0, 1).
  • Proxies:
    • Gaussian error: true + N(0, 1);
    • heavy-tailed error: true + Student-t (1.5 degrees of freedom), with the same median error size;
    • exploitable flaw: 2% of responses are hacks with true reward −1 that the proxy scores about 4; honest responses get true + N(0, 0.5²).
  • Optimisation: the KL-regularised optimum π ∝ exp(proxy/β) over the 256 samples for β from 100 down to 0.01 (KL from 0 to about 5.5 nats), plus best-of-n for n = 1 to 256 on the flawed proxy.
proxy peak true reward KL at peak true reward at max optimisation proxy at max
Gaussian error 1.999 5.46 1.997 3.96
heavy-tailed error 0.140 3.40 0.080 42.1
exploitable flaw 0.349 0.57 −0.849 4.55

(Reference true reward 0.00; best possible 2.85.)

best-of-n on the flawed proxy 1 4 16 64 256
KL (nats) 0 0.64 1.84 3.17 4.55
true reward 0.05 0.71 0.86 −0.11 −0.85
  • Light-tailed errors are benign: true reward kept rising to 2.0, about 70% of the best possible.
  • Heavy-tailed errors make optimisation useless: the proxy reached 42 (impossible for a true reward of about N(0, 1)) while the true reward barely moved; it peaked at 0.14 and then slipped.
  • Exploits cause the classic rise and fall: the peak at KL 0.57 was followed by a fall below the reference. Best-of-n showed the same shape, peaking at n = 16, where a hack appears in only 28% of samples, against almost always at n = 256.
  • Best-of-n peaked higher than the tilted policy (0.86 against 0.35), because the tilt over all 256 samples weights hacks as soon as they exist.
  • Seeds 1 and 2: same shapes (flaw peak 0.35 and 0.34, final −0.87 and −0.95; heavy-tailed peak 0.21 and 0.14).
🐍 Exercise 2 (research): how does the shape of a reward model's errors decide whether optimising harder helps or hurts?
Optimise against proxies with Gaussian, heavy-tailed and exploitable errors at increasing strength; trace true reward against KL.

Reward hacking in AI, robotics and aerospace

  • LLMs: sycophancy and verbosity in RLHF models; test tampering by code agents trained with RL.
  • Robotics and RL: agents exploiting simulator physics bugs or reward-shaping loopholes (specification gaming).
  • Engineering optimisation: a design optimised against a surrogate model drifts to regions where the surrogate is wrong; validate optima with the high-fidelity model.

References

  1. L. Gao, J. Schulman and J. Hilton (2023). “Scaling laws for reward model overoptimization.” ICML.
  2. V. Krakovna et al. (2020). “Specification gaming: the flip side of AI ingenuity.” DeepMind blog.
  3. T. Kwa, D. Thomas and A. Garriga-Alonso (2024). “Catastrophic Goodhart: regularizing RLHF with KL divergence does not mitigate heavy-tailed reward misspecification.” NeurIPS.
  4. T. Coste, U. Anwar, R. Kirk and D. Krueger (2024). “Reward model ensembles help mitigate overoptimization.” ICLR.