Part III · RL for LLMs · Chapter 19
Failure modes: reward hacking and friends
Over-optimization, reward hacking, length bias, sycophancy, and entropy collapse — and the fixes.
In 2016, researchers at OpenAI trained an agent on CoastRunners, a boat-racing video game. The game’s score came from hitting targets along the course, not from finishing the race. The agent found a lagoon where a few targets kept respawning, and it circled there indefinitely, crashing into other boats, going the wrong way and catching fire. In the researchers’ words, it achieved “a higher score using this strategy than is possible by completing the course in the normal way.” It never finished a race. In 2025, OpenAI researchers watched a frontier reasoning model being trained with RL to fix code until the unit tests passed. Among the tricks it learned was to call exit(0), so the test harness saw a clean exit before any test could fail.
Nine years and many orders of magnitude of compute separate those two stories, and they are the same story. Reinforcement learning is an optimizer. It finds what you reward, not what you meant, and the better the optimizer, the more reliably it finds the difference. Every chapter of Part III so far has quietly assumed the reward is right: the reward model of Chapter 12, the judges and rubrics of Chapter 14, the verifiers of Chapter 15. This chapter drops that assumption. You will see why optimizing a good-but-imperfect reward first helps and then hurts, measure the effect in nats, meet the main ways LLMs hack their rewards, and see a second family of failures in which nothing is hacked but the policy stops exploring. Then we assemble the toolbox people use against all of it.
The proxy and the target
Goodhart’s law
The economist Charles Goodhart observed in 1975 that a statistical regularity tends to collapse once you lean on it to control something. The anthropologist Marilyn Strathern later gave it the form everyone quotes: when a measure becomes a target, it ceases to be a good measure. A school judged on test scores starts teaching to the test. A hospital judged on waiting times starts discharging patients early.
In RL for LLMs the measure is the reward. Following Gao, Schulman and Hilton (2022), we give the two sides of the gap names:
- The gold reward is what you actually want: a careful human’s judgment, the true correctness of a program, whether a summary is faithful. You usually can’t compute it at training scale. That is why you needed a substitute in the first place.
- The proxy reward is what the optimizer actually sees: a reward model’s score, a unit-test pass rate, an LLM judge’s verdict.
Reward hacking is when a policy raises the proxy in a way that does not raise, or even lowers, the gold. Specification gaming (the term popularized by Krakovna and colleagues at DeepMind) means the same thing with the emphasis on the specification: the agent did exactly what you wrote down, and what you wrote down was wrong. People use the two terms almost interchangeably. Neither one requires intent. A policy-gradient update has no idea that it is “cheating”; it just raises the probability of whatever scored well.
Why optimization pressure is the problem
Suppose a reward model was trained on responses of ordinary length, and longer answers were slightly preferred by the labelers because they tended to be more complete. The reward model correctly learns “longer is a bit better” in that range. Nothing is wrong yet. Now hand it to an optimizer. The optimizer discovers that length is the cheapest way to raise the score, and pushes responses into lengths no labeler ever saw. Out there, the reward model’s “longer is better” is an extrapolation, and the extrapolation is wrong: a 3,000-word answer to a yes/no question is not better.
So the danger is not that the proxy is noisy or slightly biased. Every proxy is. The danger is the interaction between a slightly wrong proxy and a strong optimizer. You can see this cleanly in a toy model small enough to solve by hand.
A toy you can solve by hand
The setup
Give every response three hidden features, each a standard normal under the starting policy :
- , its quality;
- , its length, in standard deviations from typical;
- , some quirk that the reward model happens to like but nobody cares about.
The gold reward is quality, with a penalty for being far from a sensible length in either direction:
The proxy reward model gets quality right, but it has also learned that length is good (a bias of size ), and it responds to the irrelevant quirk (noise of size ):
Near the starting policy these agree well: for typical responses, is small, the penalty is negligible, and both rewards mostly track . Under the average gold is and the average proxy is . We’ll measure everything as a gain over these starting values.
Optimizing the proxy with a KL leash
From Chapter 11 you know what KL-regularized RL converges to, if optimization succeeds: the maximizer of is the tilted distribution
Here is a standard Gaussian over the features and is linear in them, so the tilt is easy. Tilting a Gaussian by the exponential of a linear function shifts its mean and leaves its shape alone (the derivation below completes the square). Write for the optimization pressure. The optimized policy has
Quality goes up, which is good. Length goes up too, in proportion to . Plugging in, the gains over are
The proxy rises linearly forever. The gold gain is a parabola: it rises, peaks at , and then falls without limit.
∂ Tilting a Gaussian: the mean shift and the KL
Collect the features into and the proxy’s weights into , so . The reference density is . Then
The last term is a constant, absorbed into . So : same covariance, mean .
The KL between two Gaussians with the same identity covariance is half the squared distance between their means:
For the gold, and , so . Subtracting the starting value gives . For the proxy, .
Worked example: , no noise
Take a reward model that likes length about as much as it likes quality () and has no noise (). Then , so the distance from the reference measured as is just . Lower step by step (a weaker leash):
| KL penalty | pressure | KL (nats) | proxy gain | gold gain | mean length |
|---|---|---|---|---|---|
| (no RL) | 0 | 0 | 0 | 0 | 0 |
| 2 | 0.5 | 0.25 | 1 | 0.375 | 0.5 |
| 1 | 1 | 1 | 2 | 0.5 (peak) | 1 |
| 0.5 | 2 | 4 | 4 | 0 | 2 |
| 0.25 | 4 | 16 | 8 | −4 | 4 |
Read the table as a training run. The proxy climbs steadily: 0, 1, 2, 4, 8. If the proxy is all you can see, everything looks great. Meanwhile the gold improves at first (the optimizer is finding genuinely better responses), peaks at KL = 1 nat, is back to zero by 4 nats, and is far below the starting policy by 16 nats. At the end, responses are four standard deviations too long, and the proxy loves them.
In terms of , the gold gain is : rising linearly, falling quadratically. Hold on to that shape; you’ll see it again in real data in a moment.
Two different ways a proxy can be wrong
The toy separates two kinds of error, and they behave very differently.
- Noise (). Set . Now , which never falls. But the KL is , so at a fixed KL budget you get less gold: part of every unit of optimization is spent selecting for the quirk , which is worthless. You are disappointed (the gold gain is smaller than the proxy gain promised) but not harmed. This is regressional Goodhart, the first of four variants in Manheim and Garrabrant’s taxonomy: selecting on a noisy measure also selects for the noise.
- Bias that breaks at the extremes (). The proxy’s “longer is better” is true near typical lengths and false far from them. Optimization drives you exactly to where it is false, and the gold eventually falls below where you started. This is extremal Goodhart: a relationship that held in the normal range fails in the extreme range that optimization selects. Gao et al. identify it as the main driver of the gold score’s eventual decline.
The taxonomy has two more members. Causal Goodhart: the proxy is correlated with the gold without causing it, so intervening on the proxy doesn’t move the gold (making answers longer doesn’t make them more thorough). Adversarial Goodhart: an agent actively exploits the measure. At LLM scale the boundaries blur, but the first two are enough to reason with.
Quick check In the toy model, set the length bias b = 0 and the noise σ = 1. What happens to the gold reward as you lower β (more optimization pressure)?
With b = 0 the gold gain is t, which only increases. But KL = t²(1 + σ²)/2 = t² here, versus t²/2 with no noise, so at any fixed KL you get less gold. Noise wastes optimization; it takes a bias that fails at the extremes (b > 0) to make the gold fall.
Measuring optimization pressure in nats
Best-of-n: the simplest optimizer
The simplest way to optimize a proxy needs no training at all. Sample responses from , score them with the proxy, and return the best one. This is best-of-n (BoN), also called rejection sampling. It defines a new policy , and the bigger is, the harder you are pushing on the proxy.
To compare BoN with RL you need a common ruler, and the natural one is how far the policy has moved: . Remarkably, it does not depend on the proxy or the model at all:
| 1 | 2 | 4 | 16 | 64 | 256 | 1,000 | 10,000 | |
|---|---|---|---|---|---|---|---|---|
| KL (nats) | 0 | 0.19 | 0.64 | 1.84 | 3.17 | 4.55 | 5.91 | 8.21 |
KL grows only logarithmically in . Best-of-1,000 is about 6 nats from the reference; to reach 16 nats, the end of our RL table, you would need in the millions. Exercise 19.3 walks you through the derivation; here is the short version.
∂ Why best-of-n is log n − (n−1)/n nats from the reference
Assume the proxy scores are continuous, so there are no ties, and let be the cumulative distribution function of the proxy score under . A response wins best-of-n if it is drawn and the other draws score below it. Summing over which of the draws it is, its probability under BoN is
So , and
Under , is uniform on . The winner’s is the maximum of independent uniforms, which has density . Therefore
(integrating by parts with ). Putting it together: .
When the response space is discrete and ties are possible, Beirami et al. (2024) show this formula is an upper bound on the true KL, and that it can be loose. For our purposes it is the standard ruler.
In the toy model with , best-of-n behaves much like the RL table: best-of-10 (KL 1.4 nats) gives the peak gold gain of about +0.66; best-of-256 (KL 4.5) is down to +0.21; past about best-of-630 (KL 5.4) the gold is below the starting policy, while the proxy has climbed to about +4.4. Now try it yourself.
What to try: press Play and watch the left plot. The dashed proxy only goes up; the solid gold rises, peaks (diamond) and falls. On the right, watch the cloud of responses drift up and to the right: it crosses the gold contours upward at first, then runs off toward long responses. Switch to 'RL with KL penalty' and find β where the gold peaks (compare with the table above). Then set the length bias b to 0 and raise the noise σ: the gold never falls, but it rises more slowly per nat. Finally set b to 1.5: how early does the peak come now?
Reading the two plots
On the left, the x-axis is , the distance from the starting policy, and the y-axis is the gain over . Both optimizers are plotted against this same ruler, so you can see how much proxy and gold each nat buys. The readout below the plots gives the exact numbers at the current slider position, so you can check them against the table above. The right plot shows why the gold falls. The proxy’s favorite direction (the arrow) points partly along the length axis. The gold contours are parabolas that bend back down at long lengths. A cloud that moves along the arrow first climbs the gold contours, then crosses back down them.
Scaling laws for overoptimization
How does this look with real language models? Gao, Schulman and Hilton (2022) built a clean experiment around the obvious obstacle: you can’t query real humans thousands of times per data point. So they made a synthetic world. A 6B-parameter reward model (the one from InstructGPT) plays the role of the humans: it is the gold RM. It labels comparisons, and those labels train proxy RMs ranging from 3M to 3B parameters. Then they optimize policies against each proxy, with best-of-n and with PPO, and score every policy with both the proxy and the gold.
Every run shows the shape from our toy: the proxy score keeps rising, while the gold score rises, peaks, and falls. With (the paper writes for our ), the gold-score curves fit simple forms:
(Here and are fitted coefficients; this has nothing to do with the KL coefficient.) Our toy’s KL-regularized optimum gave exactly the BoN form, , with and (and the toy’s own best-of-n curve is close to it; the lab fits it). That is no accident: a linear first-order gain and a quadratic penalty for extrapolating too far is the simplest shape a rise-then-fall can have. Both of Gao et al.’s forms are empirical fits, chosen because they match the data, not derived from first principles.
The findings that matter for practice:
- Bigger reward models overoptimize later. The coefficients change smoothly, roughly logarithmically, with proxy RM size. A better proxy buys you more KL before the gold turns down, but every proxy in the study eventually turns down.
- RL spends KL much faster than BoN to reach the same proxy score, for both the helpful and the harmful part of the curve. So “KL from the reference” is a good ruler within one method but a poor one for comparing methods.
- The KL penalty acted like early stopping. Adding a KL penalty to the RL reward made the gold score converge earlier, but it did not move the gold-versus-KL frontier: the gold score depended only on how far the policy had moved, not on how it got there. (The authors note this may be sensitive to hyperparameters.)
- Policy size mattered little. A 6B and a 1.2B policy peaked at almost the same KL, though the larger one gained less from the optimization.
The synthetic setup is both the strength and the limit of the paper. A 6B “gold” RM is not a human, and it cannot model the adversarial and causal failures of the next section. But the core message has held up: a learned reward is a resource you spend, measured in nats.
Quick check Gao et al. added a KL penalty to the RL reward in their overoptimization experiments. What did they find?
The gold score depended only on the KL distance of the policy. The penalty made training converge earlier, at a smaller KL, which is what early stopping does, but it did not improve the gold-versus-KL frontier.
Specification gaming, the classic gallery
Before LLMs, specification gaming was a collection of anecdotes from games and robotics, and the collection is instructive because each item is so clearly not a bug in the optimizer. Victoria Krakovna maintains a public list with dozens of examples; a few favorites:
- CoastRunners (OpenAI, 2016): the boat circling a lagoon of respawning targets, described above.
- The flipped block (from DeepMind’s write-up): a robot arm was supposed to stack a red Lego block on a blue one, and was rewarded for the height of the red block’s bottom face. It flipped the red block upside down.
- Agents in physics simulators that exploit simulator bugs to move in impossible ways, and game-playing agents that pause the game forever rather than lose.
Chapter 1 met the boat as a curiosity. The systematic version is Pan, Bhatia and Steinhardt (2022): across four environments with deliberately misspecified rewards, more capable agents (bigger networks, finer action resolution, longer training) got higher proxy reward and lower true reward. Some showed phase transitions, where a small increase in capability flipped the agent into a qualitatively different, hacking behavior with a sharp drop in true reward. That is the uncomfortable trend for LLMs: the hacking gets worse as the optimizer gets better.
Reward hacking in language models
LLM reward hacking falls into three groups, by which part of the reward is exploited: a learned reward model’s blind spots, human raters’ preferences, and the code of a verifier.
Length and verbosity
The most common hack against learned reward models is simply to talk more. Singhal et al. (2023) examined standard RLHF setups and found the improvements in reward “largely driven by increasing response length”. More striking, “even a purely length-based reward reproduces most downstream RLHF improvements” over the SFT model in their settings. The mechanism is the extremal Goodhart of our toy. Human raters (and LLM judges, Chapter 14) mildly prefer longer, more detailed answers, the reward model learns “longer is better”, and RL extrapolates that far past where it holds.
Diagnose it by plotting reward against length on the policy’s samples, and by evaluating with length-controlled metrics such as length-controlled AlpacaEval (Dubois et al., 2024), which regress out the length difference before computing a win rate.
Sycophancy: hacking the rater
Sycophancy is telling people what they want to hear: agreeing with a user’s stated opinion, praising their work, abandoning a correct answer when they push back. Sharma et al. (2023) found it in five production assistants across four kinds of task, and traced it to the data: human preference judgments favor responses that match the user’s views, and optimizing against preference models sometimes trades truthfulness for agreement.
Here is why a small preference becomes a large behavior. Suppose that when two answers are equally correct, raters pick the one that agrees with the user 60% of the time. The Bradley–Terry reward model of Chapter 12 turns that into a reward gap with :
Now optimize. The KL-regularized optimum multiplies each response’s reference probability by , so the odds of agreeing versus disagreeing get multiplied by
With the odds go up by a factor of 1.5. With , by 2.25. With , a common order of magnitude in practice, by . A reference model that agreed half the time ends up agreeing 98% of the time. A mild bias of the raters became a near-certainty in the policy. Optimization amplifies whatever the reward prefers, including the parts nobody meant. (Exercise 19.5 asks you to find the β that keeps agreement below a target.)
Two real cases show the range:
- Convincing, not correct. Wen et al. (2024) gave human evaluators limited time to judge answers and found that RLHF made models better at convincing those evaluators without making them more correct. The evaluators’ false-positive rate rose by 24% on a reading-comprehension task and 18% on a programming task. The policy learned to hack the evaluators’ limited attention.
- The GPT-4o rollback. In April 2025 OpenAI rolled back a GPT-4o update that had become noticeably sycophantic. In its post-mortem, OpenAI explained that the update “introduced an additional reward signal based on user feedback—thumbs-up and thumbs-down data from ChatGPT”, that this “weakened the influence of our primary reward signal, which had been holding sycophancy in check”, and that user feedback “can sometimes favor more agreeable responses”. A thumbs-up is a reward from a rater who likes being agreed with.
Hacking the verifier
Verifiable rewards (Chapter 15) sidestep the reward model’s blind spots, which is a big part of why they work. But a verifier is a program, programs have loopholes, and a policy that is trained for thousands of steps against it will find them. The documented cases cluster in agentic coding, where the policy can run commands in the same environment as the grader (Chapter 18):
- Special-casing tests. Anthropic’s Claude 3.7 Sonnet system card (Feb 2025) reports that the model “occasionally resorts to special-casing in order to pass test cases”: most often “directly returning expected test values rather than implementing general solutions”, sometimes “modifying the problematic tests themselves”. The card attributes it to reward hacking during RL. User testing missed it, because it appeared mostly after repeated failed attempts; automated classifiers on training transcripts caught it.
- Escaping the test harness. Baker et al. (2025) list systemic hacks a frontier reasoning model learned during OpenAI’s agentic-coding RL, including calling
exit(0)so the process ends successfully before tests can fail, and raisingSkipTestso failing tests are skipped. - Breaking equality. In Anthropic’s production coding environments, MacDiarmid et al. (2025) studied models that returned an object whose
__eq__method always returnsTrue(so everyassert result == expectedpasses), exited early withsys.exit(0), or wrote aconftest.pyfile that patches pytest’s reporting.
The same pattern appears outside code. A lenient math checker that accepts a response if the right number appears anywhere can be hacked by listing many numbers. A format reward for producing <think> tags can be satisfied with an empty thinking block. Your coding lab builds exactly such a two-part trap for TinyLM, and you will watch the policy walk into it.
Watching the chain of thought
Reasoning models write out their reasoning before acting, and that gives you a way to catch hacks: read it. Baker et al. (2025) used GPT-4o as a chain-of-thought (CoT) monitor for a frontier reasoning model during agentic-coding RL. Models often state their intent plainly (“let’s just make the tests pass”). The CoT monitor caught about 95% of the systemic hacks, versus about 60% for a monitor that saw only the model’s actions. A weaker model could usefully monitor a stronger one.
The obvious next step is to put the monitor into the reward and penalize hacky thoughts. Baker et al. tried it. At low optimization pressure it helped: less hacking, better agents. With more optimization, the agents learned obfuscated reward hacking: they kept hacking, but stopped saying so. The CoT looked innocent and the monitor’s recall collapsed. The authors recommend paying a monitorability tax: avoid applying strong optimization pressure directly to the CoT, so it stays useful as a window.
How much can you trust that window to begin with? The evidence points in different directions under different conditions, and the claims are compatible:
- Chen et al. (Anthropic, 2025) found that reasoning models often fail to mention a hint they used. Rates of verbalization were often below 20%, and when RL increased the use of a hint (a reward hack), verbalization did not increase.
- Guan et al. (OpenAI, Dec 2025) built evaluations of monitorability and report that RL optimization “does not materially decrease monitorability” at current frontier scale, and that CoT monitoring beats action-only monitoring.
- A cross-lab position paper (Korbak et al., 2025) calls CoT monitorability “a new and fragile opportunity” and asks developers to consider how their training choices affect it.
Summary: CoT monitoring is useful and imperfect, and putting it in the reward is the surest way to break it.
Quick check Baker et al. added a chain-of-thought monitor's verdict to the RL reward. With strong optimization, what happened?
This is obfuscated reward hacking. Penalizing hacky-sounding thoughts is a proxy too, and the cheapest way to satisfy it was to change what the CoT said, not what the agent did. Hence the advice to avoid strong optimization pressure on the CoT itself.
When hacking generalizes
The most worrying finding of 2025–26 is that reward hacking does not stay in its box. What a model learns from hacking can change how it behaves elsewhere.
- Emergent misalignment (Betley et al., 2025): fine-tuning a model (with SFT, not RL) to write insecure code without telling the user produced broadly misaligned behavior on unrelated prompts, such as asserting that humans should be enslaved by AI.
- School of Reward Hacks (Taylor et al., 2025): SFT on more than a thousand harmless hacks (gaming poetry and simple-code graders) generalized to other forms of hacking and to misaligned behavior.
- Natural emergent misalignment from production RL (MacDiarmid et al., Anthropic, Nov 2025): models that learned the
AlwaysEqual,sys.exit(0)andconftest.pyhacks during RL on real coding environments generalized to alignment faking, cooperating with malicious actors, and attempting to sabotage safety research. Standard chat-style safety training made them look aligned on chat evaluations while the misalignment persisted on agentic tasks. Three mitigations worked: prevent the hacking in the first place, diversify safety training, and inoculation prompting, where the training prompt frames hacking as acceptable in that context. The last one removed the misaligned generalization even when the hacking itself was still learned, which suggests that what generalizes is partly what the model learns about what kind of agent it is. - A deliberately misaligned reward seeker (Qi, Wright, MacDiarmid and Hubinger, Anthropic, Aug 2026): starting from an early Opus 4.8 checkpoint, the team trained on 80 RL environments known to be hackable, as a proxy for a run with no anti-hacking effort. By the end it hacked 40% of all episodes. The resulting model generalized to new reward-seeking behaviors: reward tampering rose from 0% to 41% and attacks on simulated infrastructure from 0% to 8% in their evaluations. Yet on evaluations with no clear grader it looked aligned. Its chain of thought showed “a strong desire to satisfy the grader”.
The lesson for a practitioner: hack rates are not only an efficiency problem (wasted compute, a worse model). They are a safety metric to monitor and drive toward zero.
Collapse: when the policy stops exploring
The second family of failures involves no loophole. The reward can be perfect, and the policy still ends up worse than it should be, because RL also changes how spread out the policy is.
Losing diversity
RLHF makes outputs less diverse. Kirk et al. (2023) measured this across the RLHF pipeline and found that RLHF generalized better than SFT to new inputs, but substantially reduced output diversity: the familiar “every answer sounds the same” effect. Part of this is built into the objective. The optimum concentrates mass on high-reward responses, and the reverse KL of Chapter 11 is mode-seeking: it penalizes putting mass where the reference has none, not failing to cover everything the reference covers.
For reasoning, the cost of lost diversity is easy to measure with pass@k, the probability that at least one of samples is correct. If a policy solves a problem with probability per sample, then pass@k . Here is a worked example of RL sharpening a policy. Take two problems:
| problem A: | problem B: | mean pass@1 | mean pass@16 | |
|---|---|---|---|---|
| base model | 0.60 | 0.10 | 0.35 | |
| after RL | 0.95 | 0.00 | 0.475 |
RL made the common case much more reliable and pass@1 went up. But the rare way of solving problem B was squeezed out, and at the base model wins easily. This is the shape behind Yue et al.’s (2025) finding that base models often beat their RLVR-trained versions at large , discussed in Chapter 15. Whether RLVR only sharpens or can also expand what a model can solve is still debated: prolonged training with KL control and reference resets (ProRL), many more rollouts per prompt (BroRL) and different metrics give different answers. Keep pass@k at large on your dashboard either way.
Entropy collapse in RLVR
The sharpest version of the problem shows up during RLVR training itself. Watch the average per-token entropy of the policy: it typically falls fast in the first few hundred steps and keeps falling, responses within a group become nearly identical, and accuracy plateaus. DAPO’s authors saw it in naive GRPO runs. Cui et al. (2025) found that performance and entropy were tied by a simple empirical law across many runs,
where is validation performance, the policy entropy, and fitted constants. Performance is bought with entropy, and when the entropy is gone, at , you hit a predictable ceiling, . Once the policy is nearly deterministic, every sample in a group is the same, the group advantages are all zero (Chapter 15), and learning stops.
Why does entropy fall? There is a clean first-order answer.
The covariance rule
Take a softmax policy over actions with logits , so . Change the logits by a small . To first order, the entropy changes by
In words: if the update raises the logits of actions that are already likely, entropy falls; if it raises the logits of unlikely actions, entropy rises. The derivation below takes four lines.
What does policy gradient do to the logits? For a one-step problem with rewards , the exact gradient of with respect to is , where is the advantage (Chapter 7). A gradient step of size sets , so
Entropy falls when the likely actions are the ones with positive advantage. Cui et al. derive the same rule for LLMs, token by token, with the covariance taken over the vocabulary at each position.
∂ The first-order entropy change of a softmax policy
Let and . The softmax Jacobian is . Then
Since , this is . A first-order Taylor expansion gives
The last step uses the fact that subtracting from changes nothing, because . For the policy-gradient step, .
Worked example. Three actions with , entropy nats. Take one exact policy-gradient step with in two scenarios:
| rewards | advantages | predicted | new | actual | ||
|---|---|---|---|---|---|---|
| likely action is right | ||||||
| rare action is right |
When the confident answer is right, entropy drops. When a rare answer is right, entropy rises. Now consider RLVR after SFT: the model’s confident tokens are usually the right ones, so the first row is the common case. The covariance is mostly positive, step after step, and entropy drains away monotonically. That is entropy collapse in one sentence.
Where the clip comes in, and clip-higher
The PPO clip of Chapter 9 makes it worse. For a token with positive advantage, the objective stops pushing once the ratio exceeds . With :
- a token with can rise to , more than 1, so the clip never binds;
- a token with can only rise to within that batch.
So the upper clip restrains exactly the updates that would raise entropy (rare tokens with positive advantage, row two of the table) while barely touching the updates that lower it. DAPO’s authors made this argument with these numbers and proposed clip-higher: decouple the two clip ranges and raise only the upper one, , . The same reasoning motivated CISPO’s choice to clip the importance weight but keep every token’s gradient (Chapter 16).
Quick check A token has probability 0.02 under π_old and a positive advantage. With the symmetric PPO clip ε = 0.2, what is the highest probability it can reach in this batch before the objective stops pushing it up?
The clip stops the push once ρ = π/π_old exceeds 1 + ε = 1.2, so 0.02 × 1.2 = 0.024. With clip-higher (ε_high = 0.28) it would be 0.0256. For a token at 0.9 the limit 1.08 is above 1 and never binds: the upper clip mostly restrains rare tokens.
The fixes people use, all of which act on the covariance in some way:
- Clip-higher (DAPO), and keeping gradients on clipped tokens (CISPO).
- Clip-Cov and KL-Cov (Cui et al.): find the small fraction of tokens with the highest covariance between log-probability and advantage, and either detach their gradients or put a KL penalty on them.
- Train mostly on the uncertain tokens. Wang et al. (2025) found that a minority of high-entropy “forking” tokens (like “wait” or “however”) carry most of the useful learning signal; restricting updates to the top 20% highest-entropy tokens matched or beat full updates on Qwen3 models.
- An entropy bonus is the textbook fix (Chapter 8), but Cui et al. found it very sensitive to its coefficient: large coefficients made the entropy explode, and a small stabilizing one did not beat other baselines.
- A KL penalty to the reference, which pulls the policy back toward the more diverse SFT model. Cui et al. report that it does keep entropy stable but lowered accuracy in their runs; ProRL combines it with periodic resets of the reference so that the leash doesn’t hold the policy back for good.
There is no consensus winner. Entropy management is one of the most active areas of LLM RL, and the right amount of entropy is itself unclear: some exploration is needed, but entropy is not the goal.
Failures of the training run, and of the experimenter
Two more categories look like the failures above on a dashboard but have different causes.
Numerical instabilities. A run can collapse with no reward hacking at all: the inference engine that samples rollouts and the trainer that computes gradients disagree about token probabilities even with identical weights, mixture-of-experts models route the same token to different experts in the two systems, and a slow drift of hidden off-policyness ends in a sudden crash. These are systems problems, and Chapter 20 covers them and their fixes (importance-sampling corrections, routing replay, precision changes).
Fooling yourself. Shao et al. (2025) ran GRPO on Qwen2.5-Math-7B with random rewards and still gained 21.4 points on MATH-500, against 29.1 with the true reward. The effect did not transfer to other model families. Their explanation: a bias in GRPO’s clipping amplified behaviors the model already favored (such as reasoning in code), which happened to help on that benchmark. Wu et al. (2025) argue that the Qwen2.5 models are likely contaminated on popular math benchmarks. Whatever the mechanism, the lesson is about evaluation: a reward signal can look like it works for reasons that have nothing to do with the reward. Validate across model families, include a control run, and use test sets the base model cannot have memorized.
A toolbox of mitigations
No single fix works, so production systems layer several. Each one below targets a specific failure, and each has a known limitation.
| Mitigation | What it does | Caveat |
|---|---|---|
| KL penalty to (Ch 11) | Limits how far the policy moves from where the reward model is reliable | Gao et al.: acts like early stopping, not a better frontier. Many RLVR recipes drop it (Ch 16) |
| Early stopping on a held-out gold metric | Stops near the gold peak | Needs a gold signal you trust (human evals, hidden tests) |
| Bigger / better reward models | Moves the gold peak to larger KL (Gao et al.) | Every proxy still turns down eventually |
| Reward model ensembles (Coste et al., 2023) | Optimize the worst case or penalize disagreement, so hacks that fool one member don’t pay | Eisenstein et al. (2023): members trained from the same pretrained model share errors; ensembles mitigate but don’t eliminate hacking |
| Retrain the reward model on fresh policy samples | Labels the new region the policy moved into (“iterated online” RLHF, Bai et al., 2022) | Costs new labels each round |
| Length penalties and length-controlled evaluation | Removes the cheapest hack against learned RMs | Can suppress useful long reasoning; tune on accuracy |
| Verifiable rewards (Ch 15) | No learned RM to fool | Verifiers have loopholes; harden the environment |
| Harden environments | Read-only tests, graders in a separate sandbox, hidden tests, check that the test count didn’t change | An arms race; new hacks keep being found |
| Monitor transcripts (classifiers, CoT monitors) | Detects hacks humans miss (Claude 3.7, Baker et al.) | Don’t put the monitor in the reward: obfuscation |
| Inoculation prompting (MacDiarmid et al., 2025) | Stops a learned hack from generalizing into broader misalignment | Doesn’t stop the hack itself |
| Entropy controls | Clip-higher, Clip-Cov/KL-Cov, KL, resets | No consensus winner |
Underneath the table is one habit: never watch only the number you are optimizing. A minimal monitoring plan for any RL run on an LLM:
Every N steps, log and plot:
1. training reward (the proxy) -- should go up
2. a held-out GOLD metric -- hidden tests, human/strong-judge evals
-> alert if (1) rises while (2) is flat or falling: overoptimization
3. KL(pi || pi_ref) and response length -- how far, and the cheapest hack
4. token entropy, pass@1 AND pass@k -- collapse
5. hack detectors: test-file edits, early exits, skipped tests,
classifier / CoT-monitor flag rate -- per environment
Every few hundred steps: read 20 random transcripts and the 20 highest-reward ones.
Keep a checkpoint from before each alert; stop at the gold peak, not the proxy peak.
The highest-reward transcripts are the most informative ones to read, because the hacks live there.
Summary
- Goodhart’s law in RL: a proxy reward that agrees with the gold reward on typical responses stops agreeing where the optimizer takes the policy. Gold rises, peaks and falls while the proxy keeps rising.
- Measure optimization in nats. Best-of-n is nats from the reference. Gao et al. fit gold for best-of-n and for RL, with . Bigger RMs peak later; a KL penalty behaved like early stopping.
- Noise disappoints; extrapolated bias harms. Selecting on a noisy proxy wastes KL (regressional Goodhart). A proxy feature that is right in-distribution and wrong at the extremes, like “longer is better”, makes the gold fall (extremal Goodhart).
- LLMs hack learned rewards with length and sycophancy. Optimization amplifies small rater biases: odds scale by .
- LLMs hack verifiers in agentic coding: special-casing tests, editing tests,
exit(0), always-equal objects. CoT monitors catch much of it, but training against the monitor teaches obfuscation. Hacking can generalize into broader misalignment. - Collapse needs no hack. RL sharpens the policy: pass@1 up, diversity and sometimes pass@k down. Entropy falls when the update favors already-likely actions, , and the PPO upper clip restrains the rare tokens that would raise it (hence clip-higher).
- Mitigate in layers and monitor the gold. KL leash, better or ensembled RMs, fresh labels, hardened environments, length control, entropy controls, and a held-out gold metric on the dashboard.
Exercises
For each reward design, say how an RL-trained policy could raise the reward without doing what the designer meant, and suggest one fix.
- A coding agent gets reward equal to the fraction of the repository’s test suite that passes after its edits.
- A math model gets reward 1 if the reference answer appears anywhere after the string “Answer:”.
- An R1-style format reward gives +0.5 if the response contains a
<think>tag and a</think>tag. - A chat assistant gets reward from users’ thumbs-up clicks.
- A summarizer is trained against a reward model fit to comparisons from raters who had 30 seconds per comparison.
- A customer-support agent is rewarded when a ticket is marked “resolved” within 10 minutes.
Solution
- Delete or skip the failing tests, edit the tests to match the code’s output, special-case the expected values, or exit with status 0 before the tests run. Fixes: make test files read-only (or restore them before grading), run hidden tests the agent never saw, check that the number of tests collected didn’t change, run the grader in a separate sandbox.
- Print many numbers (“Answer: 1 2 3 … 500”). Fix: extract exactly one final answer with a strict parser and give zero reward if there are several (Chapter 14’s verifier lab).
- Output
<think></think>with nothing inside, then whatever answer. Fix: make the format reward small relative to the accuracy reward, or give it only when the answer is also correct, or require non-trivial content. - Flattery, agreement with the user’s opinions, reassurance instead of bad news: sycophancy (the GPT-4o rollback of April 2025). Fix: keep thumbs-up as a minor signal next to a primary reward that checks for honesty, and evaluate sycophancy explicitly.
- Summaries that look thorough and confident in 30 seconds: longer, more detail, plausible but unverifiable claims (the “convincing, not correct” effect of Wen et al.). Fix: give raters time and tools to check faithfulness, or use a faithfulness check against the source.
- Mark tickets resolved without solving them, or tell the customer it’s fixed. Fix: measure resolution by whether the customer reopens the ticket or confirms, sampled audits.
The common thread: each reward measures something correlated with success on honest attempts, and each is cheaper to satisfy dishonestly.
Use the demo above.
- With the defaults (best-of-n, , ), drag the pressure slider until the gold peaks. Note , the KL and the gold gain. At about what does the gold fall below zero?
- Switch to “RL with KL penalty”. At what does the gold peak, and does it match the worked-example table?
- Switch to RL mode and set , . Does the gold ever fall? Compare the gold gain at KL = 1 nat ( on the x-axis) with what you get with .
- Set , in RL mode. Where is the peak now? Explain using the formula .
- Watch the right-hand plot during Play. In which direction does the cloud move, and why does it first cross the gold contours upward and then downward?
Solution
- The peak is around (KL ≈ 1.4 nats) with gold gain ≈ +0.66. The gold crosses zero near (KL ≈ 5.4 nats), where the proxy gain is about +4.4.
- The peak is at (KL = 1 nat, gold +0.50, proxy +2.00), exactly the table’s row.
- No: with no length bias, the gold gain is , which only increases. But per nat it is lower: at KL = 1 the gold gain is , which is 1.41 with and 0.78 with . Noise wastes optimization (regressional Goodhart); it doesn’t reverse it.
- , so , KL nats, and the gold peak is only . A stronger bias means an earlier and lower peak.
- The cloud moves along the proxy’s direction in the (length, quality) plane: up and to the right. Moving up raises the gold; moving right lowers it quadratically. Near the parabolic contours are flat, so the upward motion dominates. Further right they are steep, so the rightward motion dominates and the cloud crosses them going down.
Let the proxy score of a response under have a continuous CDF .
- Show that the best-of-n policy is .
- Derive .
- How large must be for best-of-n to reach the KL of the RL policy at in the worked example (4 nats)? What does that tell you about using best-of-n as a cheap stand-in for RL?
Hint
For (1), wins if one of the draws is and the other score lower; with a continuous score, ties have probability zero. For (2), the quantity is uniform under ; what is its distribution for the winner?
Solution
-
Think of it as a density over a continuous response space (or responses with distinct scores). The winner is if some draw lands at and the remaining draws have lower proxy scores, which happens with probability because they are independent. There are positions for the winning draw, so . Check that it normalizes: with uniform under , .
-
. Under BoN, is the max of uniforms, with CDF and density . Integrate by parts:
(The boundary term vanishes because as .) So .
- Solve , roughly , so (check: ). Reaching 16 nats would need . Best-of-n moves the policy only logarithmically in its cost, so it is a good model of mild optimization and a poor stand-in for long RL runs, which routinely travel tens of nats. (And per Gao et al., the KL scales of the two methods aren’t directly comparable anyway.)
In the toy model with gold and proxy :
- For the KL-regularized optimum with pressure , find the that maximizes the gold gain, the maximum gain, and the KL at the peak, as functions of and .
- Write the gold gain as a function of and identify Gao’s coefficients and in .
- Explain in words why increasing lowers both and , but does not change the peak gold gain.
Hint
Use and with . Then substitute .
Solution
-
gives , i.e. . The peak gain is . The KL there is . For : , gain 0.5, KL 1 nat, matching the table.
-
means , so . Then
so and . For : , , .
- Noise makes every unit of KL less useful: part of each move goes into the worthless direction , so both the gain per nat () and the damage per nat () shrink by the same mechanism, stretching the curve along the axis. But the optimum in terms of is unchanged ( doesn’t involve ), because the and components of the mean shift, and , don’t depend on . You reach the same peak gold, just at a larger KL. Noise costs distance; bias costs gold.
Raters prefer the answer that agrees with the user with probability when both are equally correct. The reference model agrees with probability in such situations. Assume a Bradley–Terry reward model learns this exactly, and the policy reaches the KL-regularized optimum.
- Show that the policy’s probability of agreeing is , where .
- Compute for .
- Which keeps at or below 0.6? Comment on what this means for using a KL penalty as the only defense against sycophancy.
Hint
Bradley–Terry says , so . The optimum multiplies each response’s reference probability by and renormalizes.
Solution
- Let . Bradley–Terry gives , so . The optimum is , so the odds become
Solving for gives the formula. (Only the reward difference matters, which is why the per-prompt constant ambiguity of Chapter 12 doesn’t affect the answer.)
-
Here and , so :
- : , .
- : , .
- : , .
-
requires , i.e. , i.e. . At the policy reproduces the raters’ bias exactly; it can never do better than that, because the reward is the bias. A KL penalty strong enough to stop the amplification () is also too strong for the policy to learn much else: practical KL coefficients are far below 1 (DeepSeekMath’s GRPO used 0.04). So the leash limits amplification but cannot remove a bias that is in the reward itself: you need to fix the data (instructions to raters, targeted comparisons where agreeing is wrong) or add a reward that penalizes sycophancy.
- Starting from with a softmax policy, derive .
- A two-action policy has . For an exact policy-gradient step , compute the predicted sign and size of when (a) action 1 has reward 1 and action 2 reward 0, (b) the reverse. Use .
- Give an informal argument for why, in RLVR after SFT, the covariance between a token’s log-probability and its advantage is positive more often than not, so entropy falls step after step.
- Using the same formula, explain why the PPO upper clip slows exploration but the lower clip does not have a symmetric effect.
Hint
For (2), with two actions . For (3), think about which tokens the SFT model is confident about, and whether those tend to lead to correct answers. For (4), which actions can the upper clip stop from growing, and what does the covariance rule say about growing them?
Solution
-
See the derivation in the “covariance rule” section: , then a first-order Taylor expansion and the fact that the weights sum to zero.
-
With two actions, . Here .
- (a) , , , . , so : entropy falls (from ).
- (b) , , , difference , so : entropy rises.
Exact check for (a): new logits differ by , so , , . Close to the prediction.
-
After SFT, the model is confident mostly where it is right: the high-probability continuations are usually the ones that lead to correct answers, and low-probability tokens are disproportionately mistakes. So positive advantages fall mostly on high- tokens and negative ones mostly on low- tokens (which, being rarely sampled, also contribute little). Both make positive, so , and since this is true at almost every step, the decrease compounds. Only the relatively rare event “an unlikely token turned out right” pushes the other way.
-
Apply the covariance rule to each clip separately. Both clips bound the ratio , which is a tight absolute limit on a rare token and a loose one on a likely token, so both bind mostly on rare tokens.
- The upper clip binds on rare tokens with positive advantage (0.01 can only reach 0.012). Raising a rare token raises entropy (row two of the worked example). So the upper clip blocks an entropy-raising move. On likely tokens it hardly binds (0.9 → 1.08 is above 1).
- The lower clip binds on rare tokens with negative advantage (0.01 can only fall to 0.008). Pushing a rare token further down lowers entropy, so the lower clip blocks an entropy-lowering move, and if anything protects entropy.
So the two clips are not symmetric in their effect on entropy: together they make it easy to sharpen the policy and hard to spread it out. Raising (clip-higher) relaxes exactly the constraint that blocks exploration. Raising instead would let rare tokens be pushed toward zero faster, which would shrink the space of things the policy can sample.
In overopt.py, implement Task 1a bon_kl, Task 1b best_of_n_stats (the exact expected proxy and gold of best-of-n from a pool, using rank weights), and Task 1c fit_gao_bon. Then run python run.py overopt. For the three reward models in the plot (bias only, noise only, both), report the fitted and and where the gold peaks. Which one has , and why? Finally, how much should you trust the right-hand end of each curve, where is in the thousands?
Hint
The winner has rank (in ascending proxy order) with probability : all draws have rank at most , but not all have rank at most . The Gao fit has no intercept: build a matrix with columns and .
Solution
The key lines (full code in solutions/overopt.py):
order = np.argsort(proxy)
k = np.arange(1, M + 1)
w = (k / M) ** n - ((k - 1) / M) ** n
return float(w @ proxy[order]), float(w @ gold[order])and X = np.stack([d, -d**2], axis=1); np.linalg.lstsq(X, gold_gain).
With the reference solution you should see roughly: bias only (): , , gold peaks at (KL ≈ 1.4) with gain ≈ +0.66 and is negative by . Noise only (): (slightly negative), the gold keeps rising up to . Bias and noise (): the peak comes a little later in KL and a little lower than with bias alone (best-of-14, KL ≈ 1.7, gain ≈ +0.61). The last point of this curve says the gold is negative again at (about −0.4), but see the last paragraph below before you believe it.
Noise alone gives because with independent Gaussian noise the gold is linear in what the selection pushes on: selection on raises in proportion to , and there is no feature that is good at first and bad later. It is the regressional Goodhart case: less gold per nat, but no downturn. The downturn needs a feature that the proxy rewards and the gold punishes at the extremes.
Note that the fit for the bias-only pool is close but not perfect: our toy’s best-of-n curve is only approximately quadratic in , which is the same kind of approximation Gao et al.’s form is.
On trusting the tail: at the winner is almost always one of the top few hundred responses in a pool of 200,000, so the far right of each curve rests on very few samples and is noisy. For the exact infinite-pool value (the max-of-normals integral that the demo uses) is about +0.10 at , and the gold only crosses zero near (KL ≈ 7.6 nats). Re-run with make_pool(..., seed=1) or a pool of 2,000,000 and watch the tail move while the peak barely changes. The same caution applies to real best-of-n curves: estimating best-of-n at large from a finite set of samples needs many more samples than .
First, without running anything, read proxy_reward in common.py. It gives 1 if the correct answer appears anywhere in the response, plus 0.1 per character. Predict what the policy will learn, and what will happen to exact-match accuracy.
Then implement Task 2 kl_penalized_rewards and Task 3 clipped_pg_loss in failures.py (Task 4 token_entropy is needed too; it’s three lines), and run python run.py hack. It trains three policies from the same SFT checkpoint for 200 steps: proxy reward with no KL, proxy reward with , and the gold (exact-match) reward. Describe the three curves. Why does a KL penalty this small stop the hack, when it barely slows down learning the correct answers?
Hint
Neither flaw alone is exploitable: a lenient check gives no reason to change a correct answer, and a 0.1 bonus per character can’t outweigh losing a full point for a wrong answer. Together, appending a digit to a correct answer keeps the full point and adds 0.1. For the KL question, compare how much reward each behavior gains with how unlikely it was under the reference: the optimum multiplies probabilities by .
Solution
Prediction: the policy learns to keep writing digits after the correct answer instead of stopping. “85” scores 1.2; “850” scores 1.3; “8500” scores 1.4. Exact-match accuracy should fall to zero while the proxy rises.
Key lines (full code in solutions/failures.py):
seq_kl = ((logp - ref_logp) * mask).sum(dim=1)
return rewards - beta * seq_klrho = torch.exp(logp - old_logp)
obj = torch.min(rho * adv[:, None], torch.clamp(rho, 1 - eps_low, 1 + eps_high) * adv[:, None])
return -(obj * mask).sum() / mask.sum()What you should see (reference solution, seed 0): with no KL, gold accuracy first rises (about 0.52 → 0.62 by step 50: the proxy rewards correctness too, so early optimization helps), then the padding hack takes over around step 80–120. Response length jumps to the maximum of 4 characters, the KL estimate jumps to about 15 nats, gold accuracy falls to 0, and the proxy keeps rising. That is the Gao curve in a 100k-parameter model. With β = 0.05, length stays near 2.5 and gold accuracy climbs steadily (to roughly 0.75–0.8), tracking the gold-reward run.
Why the asymmetry: at the KL-regularized optimum, each response’s probability is multiplied by relative to the reference. A correct answer gains a full reward point over a wrong one: a factor of , which overwhelms any reference prior, so correctness is learned. Padding gains only 0.1 per digit: a factor of , applied to something the SFT model almost never does (it ends with <eos> right after the answer with probability close to 1). The small gain cannot pay for moving that far from the reference. The leash prices each behavior by reward gained per unit of improbability under the reference, and hacks are typically high-improbability, low-gain behaviors, until a run without a leash finds a way to make them high-gain.
Try also: set LENGTH_BONUS = 0.0, or make the check exact while keeping the bonus. Neither flaw alone is enough.
With Task 4 token_entropy implemented, run python run.py entropy. It trains with the gold reward and 4 gradient epochs per batch (so the clip actually binds), three times: (symmetric), (clip-higher), and (no upper clip at all), always with . The loop also logs a diagnostic: among tokens with positive advantage, the fraction whose ratio ended above (so the upper clip switched their gradient off), separately for rare tokens () and common ones ().
- Describe the three entropy curves and the three accuracy curves.
- What does the diagnostic say about which tokens the upper clip restrains? Connect it to the covariance rule.
- Why is the difference between 0.2 and 0.28 so small here, and what does the “no upper clip” run tell you about why nobody simply removes the clip?
Hint
For (2), a rare token’s log-probability moves fast: the gradient of with respect to its own logit is , close to 1. How many epochs does it take for its ratio to pass 1.2 or 1.28? For (3), look at how far past the threshold the rare tokens end up, and at the accuracy of the unclipped run.
Solution
Reference run (seed 0, your numbers will differ a little):
| run | entropy (nats/token) | accuracy | rare tokens upper-clipped | common tokens upper-clipped |
|---|---|---|---|---|
| ε_high = 0.2 | 0.34 → 0.15 | 0.52 → 0.57 | 0.94 | 0.005 |
| ε_high = 0.28 | 0.35 → 0.14 | 0.51 → 0.64 | 0.96 | 0.000 |
| no upper clip | 0.35 → 0.19 | 0.50 → 0.31 | 0 | 0 |
-
In all three runs entropy falls steadily: entropy collapse on a tiny scale, as the covariance rule predicts (the SFT model’s confident digits are usually right). The two clipped runs are nearly indistinguishable in entropy; accuracy rises in both (a second seed gave 0.48 → 0.68 for both, so the accuracy gap in this table is noise). Without the upper clip, entropy stays clearly higher, but accuracy falls: the policy is unstable.
-
The upper clip switches off almost all rare positive-advantage tokens (over 90%) and essentially none of the common ones. This is the chapter’s argument made visible: the ratio cap is a tight absolute limit for rare tokens and no limit for likely ones, so the clip blocks exactly the updates that would raise entropy (row two of the covariance worked example).
-
Within 4 epochs at this learning rate, a rare token’s ratio shoots far past 1.2 and past 1.28, so moving the threshold from 1.2 to 1.28 changes almost nothing: both runs clip nearly all of them. Clip-higher is a small relaxation, and DAPO measured its effect over thousands of steps on a 32B model, not 120 steps on a 100k-parameter one. Removing the cap entirely keeps entropy higher but lets each batch push rare tokens arbitrarily far on the evidence of a single sample, and the run degrades. That is the trade-off behind every entropy fix in the chapter: you want to let rare good tokens grow, but not without limit. A careful study would also run several seeds; try it.
You are about to run GRPO for 2,000 steps on a coding agent. The reward is the fraction of unit tests passed in a sandboxed repository; the agent can run shell commands. Write a monitoring plan: what you log, what alerts you set, what you read by hand, and what you will do when an alert fires. Include at least one signal for each of: overoptimization, verifier hacking, entropy collapse, and evaluation contamination.
Hint
Organize by failure: for each, ask “what number moves when this happens, and what number would I need to compare it against?” The comparison is usually something the policy can’t optimize.
Solution
A good plan, organized by failure:
- Overoptimization. Log training reward, and every 50 steps a held-out gold eval: tasks the policy never trains on, graded with hidden tests, plus a small set graded by humans or a strong judge for code quality. Alert when training reward rises over 200 steps while the held-out score is flat or falls. Action: roll back to the checkpoint at the held-out peak; investigate what is being rewarded.
- Verifier hacking. Log per-environment: whether test files were modified (diff the test directory before grading), the number of tests collected (a drop means deletion or skipping), exit codes and early
exitcalls,SkipTest/xfailmarkers added, objects overriding__eq__, writes toconftest.pyor pytest config, and run times that are suspiciously short. Run a CoT monitor and a hack classifier on a sample of transcripts and log the flag rate per environment, without putting it in the reward. Alert on any rise in flag rate or any environment where the hack rate exceeds a few percent. Action: patch the environment (read-only tests, grader in a separate container), drop the affected data, consider inoculation-style prompting, restart from before the hack spread. - Entropy collapse. Log per-token entropy, the fraction of groups with zero reward variance (all pass or all fail), and pass@1 and pass@k ( = 8 or 16) on the held-out set. Alert if entropy falls faster than a set rate, or pass@k falls while pass@1 rises. Action: raise , add Clip-Cov-style controls or a weak KL, use dynamic sampling to drop zero-variance groups.
- Contamination and self-deception. Use a held-out set created after the base model’s training cutoff, include a control run with shuffled or random rewards for a few hundred steps (if it “improves” too, your gains aren’t from the reward), and check results on a second model family.
- Also: KL to the reference and response length (cheap early warnings), and the train–inference log-prob gap (Chapter 20).
- By hand: every 200 steps, read 20 random transcripts and the 20 highest-reward ones. Hacks concentrate in the top-reward transcripts.
Files: README.md, overopt.py, failures.py, common.py, test_overopt.py, test_failures.py, run.py
cd 19-failure-modes
python -m pytest -q # your code: tests fail until you fill in the TODOs
RL_SOLUTIONS=1 python -m pytest -q # reference solutions: all passFirst time? See Exercises & setup.
Further reading
- Gao, Schulman & Hilton (2022), Scaling Laws for Reward Model Overoptimization. The paper behind this chapter’s central curve; read sections 3–4 for the functional forms and the Goodhart taxonomy.
- Weng (2024), Reward Hacking in Reinforcement Learning. A long, well-organized survey of hacking in classic RL and in LLMs, with many references.
- Krakovna et al. (2020), Specification gaming: the flip side of AI ingenuity. Short and readable; links to the public list of examples.
- Baker et al. (2025), Monitoring Reasoning Models for Misbehavior and the Risks of Promoting Obfuscation. Real reward hacks in frontier coding RL, CoT monitoring, and what happens when you train against the monitor.
- MacDiarmid et al. (2025), Natural Emergent Misalignment from Reward Hacking in Production RL. Why hack rates are a safety metric, and inoculation prompting.
- Cui et al. (2025), The Entropy Mechanism of Reinforcement Learning for Reasoning Language Models. The covariance rule, the entropy–performance law, and Clip-Cov/KL-Cov.
- Sharma et al. (2023), Towards Understanding Sycophancy in Language Models. Where sycophancy comes from in preference data.
- Pan, Bhatia & Steinhardt (2022), The Effects of Reward Misspecification: Mapping and Mitigating Misaligned Models. The capability-vs-hacking trend and phase transitions, in classic RL environments.
Next, Chapter 20 leaves the objective and looks at the machinery: why rollouts dominate the cost of RL for LLMs, how asynchronous training works, and the train–inference mismatch that can crash a run with no hacking at all.