mohith
← All writing

Reward Hacking: When the Model Learns the Metric Instead of the Task

Notes on reward hacking in reinforcement learning and RLHF: what it is, why RL is so prone to it, Goodhart's Law and its four flavors, how it shows up in LLMs (sycophancy, evaluator hacking, in-context reward hacking), and the mitigations that exist today.

These are my study notes on Lilian Weng's excellent survey, Reward Hacking in Reinforcement Learning, cleaned up and reorganized in my own words. If you want the full depth and every citation, read her post. This is the version that stuck in my head.

The one-line definition

Reward hacking is when an RL agent exploits flaws or ambiguities in its reward function to score highly without actually doing what we wanted.

It sounds like an edge case. It isn't. It's close to the default outcome whenever you optimize hard against a reward you wrote by hand, and it's one of the main practical blockers to deploying RL-trained language models on real tasks.

Why we can't just reward the right thing

In RL we usually can't directly measure what we truly want, so we write a reward function that approximates it. That approximation is the proxy reward. The thing we actually care about is the true reward.

A concrete example:

True goalGenerate music that sounds good
Proxy reward+1 for staying in key, +1 for every valid note
What the model learnsTechnically correct, completely boring music

Nothing in the proxy says "be interesting." Scales up and down, all in key, all valid, maximum reward. The model did exactly what we asked. It just wasn't what we wanted.

Goodhart's Law

The cleanest summary of the whole problem is Goodhart's Law:

When a measure becomes a target, it ceases to be a good measure.

Optimize too aggressively for a metric and the metric stops reflecting what you care about. RL is, by design, an extremely aggressive optimizer.

The four flavors of Goodhart

Garrabrant and Manheim split Goodhart's Law into four distinct failure modes. They're worth knowing separately because they need different fixes.

TypeWhat happens
RegressionalOptimizing an imperfect metric also selects for noise and luck in it, not just signal.
ExtremalThe metric tracks the goal under normal conditions but breaks at the extremes optimization pushes you toward.
CausalThe metric is correlated with the goal, but changing the metric doesn't change the goal.
AdversarialSomeone (or something) deliberately exploits the metric for their own benefit.

Proxy reward going up does not guarantee true reward going up.

A taxonomy of what goes wrong

Two types of reward hacking

  1. Environment or goal misspecification. The agent finds a way to get high reward by exploiting a bug in the environment, or by optimizing a reward that was never aligned with the real objective.
  2. Reward tampering. The agent interferes with the reward mechanism itself, so the observed reward no longer represents the intended goal at all. This is the more alarming one.

Two classic examples

  • The robot hand. In OpenAI and DeepMind's 2017 work on learning from human preferences, a robot hand trained to grasp an object learned to place its hand between the object and the camera. To the human evaluators it looked like a successful grasp. It wasn't.
  • The coding model. A model rewarded for passing unit tests can learn to modify the unit tests rather than fix the code. Tests pass, reward goes up, nothing works.

Three ways a reward can be misspecified

Pan et al. studied reward misspecification systematically and grouped it into three kinds:

  • Misweighting: the right goals, but with the wrong relative importance.
  • Ontological: the wrong measurement for the concept you meant.
  • Scope: the reward only looks at part of the situation.

Two kinds of robustness failure

When you test an agent out of distribution or in the real world, it can fail in two very different ways:

  • Capability robustness failure. The model simply fails to generalize. It isn't capable enough. Annoying, but at least it's obviously broken.
  • Objective robustness failure. The model generalizes capably, but in pursuit of a different objective than the one we meant. This happens when the proxy reward diverges from the true reward, and it's the dangerous case, because the agent looks competent.

The supervised-learning cousin: spurious correlation

Supervised learning has its own version of this. Under Empirical Risk Minimization (ERM), the model is asked to find whatever patterns minimize mistakes on the training data. If an easy shortcut does that, the model will learn the shortcut instead of the thing that actually matters. Same disease, different optimizer.

Why RL is especially vulnerable

  1. Partial observability. The agent never has a complete picture of the environment, and neither does the reward function.
  2. Complex environments. Software bugs and unexpected interactions create loopholes. Every simulator has them.
  3. Hard-to-specify objectives. Abstract goals like helpfulness or safety are very hard to express as a number.
  4. Optimization pressure. RL aggressively searches for any way to increase reward, which amplifies even tiny flaws.

Two findings stood out to me here:

  • More capable agents are better at reward hacking. A smarter policy finds better exploits of an imperfect reward.
  • Scale doesn't fix it. Longer training and larger models don't automatically produce better alignment. Sometimes they make it worse.

Reward hacking in LLMs

All of this applies to language models trained with RLHF, where the "reward function" is a learned reward model standing in for human judgment.

Over-optimizing the reward model

Even in RLHF, pushing optimization further against the reward model can degrade true quality. The reward model keeps going up while what humans actually prefer goes down.

U-Sophistry

One of the more unsettling results: RLHF can unintentionally make models better at convincing humans that incorrect answers are correct, without making them more correct. Wen et al. call this U-Sophistry (unintended sophistry). The model learns to look right to the evaluator, which is exactly the robot-hand trick, in text.

Sycophancy

Sycophancy is when the model agrees with the user's beliefs instead of prioritizing the truth. If humans tend to rate agreement highly, a model optimized on human ratings learns to agree.

KL regularization helps, but isn't a fix

RLHF usually adds a KL penalty that keeps the trained policy close to a reference model. That limits how far the policy can drift toward exploits. It restricts the damage. It doesn't remove the incentive.

Evaluator hacking: LLM-as-a-judge

More and more pipelines use an LLM to grade another LLM. That judge has its own exploitable weaknesses:

  • Positional bias: preferring whichever answer appears first (or second).
  • Self-preference bias: preferring outputs that look like its own.

Practical mitigations:

  • swap candidate order and score both ways,
  • aggregate decisions across multiple judgments or judges,
  • require the judge to cite evidence for its verdict,
  • escalate uncertain or high-stakes cases to humans.

In-context reward hacking (ICRH)

Reward hacking doesn't need gradient updates. It can happen at deployment time, without changing any weights, whenever a model is in a feedback loop with the world.

There are two forms:

  • Output refinement: the model repeatedly revises a single output based on feedback.
  • Policy refinement: the model changes its overall strategy based on feedback.

More rounds of feedback can push the measured objective up while introducing unsafe side effects. For anyone building agents that iterate against an evaluator or a tool, this is the version that matters most.

Hacking skills generalize

Strategies learned on one exploitable task can transfer to other tasks. Models trained on a curriculum of easy, gameable tasks sometimes showed more sophisticated gaming on later, harder ones, in some cases escalating all the way to tampering with their own reward. Reward hacking isn't just a local bug in one environment. It can be learned as a general skill.

What can we do about it?

There's no single fix. There are a lot of promising partial ones:

  • Better reward engineering: tighter specifications, multiple reward signals, closing known loopholes.
  • Adversarial rewards: treat the reward model as an adversary that actively looks for cases where the agent's high reward is undeserved.
  • Model lookahead: reward based on predicted future consequences, not just the current state.
  • Sandboxing: isolate the agent so it physically can't touch its reward mechanism or escape its environment.
  • Reward capping: bound the maximum reward so there's no payoff for extreme, low-probability exploits.
  • Anomaly detection: flag policies whose behavior deviates sharply from a trusted reference.

The one I found most interesting: decoupled approval

Reward tampering works because the agent's action can influence its own feedback. Decoupled approval breaks that link. It separates the action that gets evaluated from the action that actually gets executed. Feedback is collected on a sampled action independent of the one the agent takes, so the agent can't steer its evaluation through what it does. It's a simple structural idea, and it removes the incentive rather than trying to patch the exploit.

Takeaways

  • Every reward function is a proxy, and optimizing a proxy hard enough breaks it (Goodhart).
  • Reward hacking comes in two broad kinds: misspecification (exploit the rules) and tampering (rewrite the rules).
  • The dangerous failures are the ones where the model looks competent: objective robustness failures, U-Sophistry, sycophancy.
  • Capability and scale make it worse, not better. Smarter policies find better exploits.
  • In LLMs it shows up as reward-model over-optimization, sycophancy, judge exploitation, and in-context reward hacking in deployed agents.
  • There's no universal solution, only layers: better rewards, adversarial evaluation, sandboxing, capping, anomaly detection, and structural tricks like decoupled approval.

Further reading

  • Lilian Weng, Reward Hacking in Reinforcement Learning (2024), the source for these notes
  • Amodei et al., Concrete Problems in AI Safety (2016)
  • Christiano et al., Deep Reinforcement Learning from Human Preferences (2017)
  • Manheim & Garrabrant, Categorizing Variants of Goodhart's Law (2018)
  • Pan et al., The Effects of Reward Misspecification (2022)
  • Gao et al., Scaling Laws for Reward Model Overoptimization (2022)
  • Uesato et al., Avoiding Tampering Incentives in Deep RL via Decoupled Approval (2020)
  • Sharma et al., Towards Understanding Sycophancy in Language Models (2023)
  • Wen et al., Language Models Learn to Mislead Humans via RLHF (2024)
  • Pan et al., Feedback Loops With Language Models Drive In-Context Reward Hacking (2024)
  • Denison et al., Sycophancy to Subterfuge: Investigating Reward Tampering in Language Models (2024)