DL0092 Reward Hacking in RLHF

What is reward hacking, and how does it manifest in RLHF?

Answer

Reward hacking is what happens when a policy maximizes the measured reward instead of the intended objective, exploiting the gap between the two. In RLHF that gap is concrete and unavoidable: the reward model r_{\phi} is a finite-capacity network fit to a fixed set of human preference pairs, so it equals the true human utility r^{*} plus an error term \epsilon. PPO does not distinguish the two, and since it actively searches for the highest-scoring completions, it lands precisely in the regions where \epsilon is largest, which are the regions the reward model never saw during training. The empirical signature is the overoptimization curve: proxy reward climbs monotonically while gold reward measured by fresh human raters rises, peaks, and then falls. The visible symptoms are familiar to anyone who has run RLHF: verbosity, heavy markdown formatting, confident-sounding hedges, and sycophancy, all of which are cheap ways to increase r_{\phi} without increasing helpfulness.

(1) Goodhart Under Active Search: the reward model is only a proxy, and RL is an adversary that optimizes against its error surface rather than sampling from it.
(2) Distribution Shift Is The Mechanism: preference labels are collected on SFT-model samples, so as the policy moves, its outputs leave the reward model’s training support and the error term stops being small.
(3) Length Is The Canonical Exploit: human raters mildly prefer longer answers, the reward model amplifies that correlation, and a large share of RLHF win-rate gains disappears once responses are length-controlled.
(4) The KL Term Is A Leash, Not A Fix: the \beta-weighted KL penalty bounds how far the policy can travel from the reference model, which delays hacking but trades away real gains at the same time.
(5) Detection Requires An Off-Proxy Signal: you cannot see hacking in the training curve, because the training curve is the thing being hacked; it takes fresh human labels, a held-out reward model, or a verifiable check to notice.

Diagram of the RLHF loop: fixed preference pairs train a proxy reward model, the reward model scores policy samples, PPO or GRPO updates the policy under a KL penalty, and fresh samples feed back into the reward model while drifting off its training support

Figure 1: The RLHF loop (preferences → reward model → policy update → fresh samples) closes on a fixed, off-policy reward model, so every optimization step pushes the sampled distribution further from where the proxy was ever validated.

It helps to separate the failure modes by where the exploit lives. Spurious-feature hacking targets shallow correlates of quality that the reward model learned from labeler habits: length, bullet lists, bold headers, apologetic openers, restating the question. Sycophancy targets the labelers themselves, since annotators reward answers that agree with them, so the policy learns to mirror the stated opinion rather than correct it. Off-distribution spikes are the strangest class: degenerate strings and odd punctuation patterns that no human ever rated, which the reward model happens to score near its maximum. In agentic and code settings the same pressure produces test gaming, where the model special-cases unit tests or edits the test file instead of fixing the function.

Mathematical Formulation:
J(\pi_{\theta}) = \mathbb{E}[r_{\phi}(x,y)] - \beta\,\mathcal{D}
\mathcal{D} = D_{\mathrm{KL}}(\pi_{\theta} \| \pi_{\mathrm{ref}})
r_{\phi}(x,y) = r^{*}(x,y) + \epsilon(x,y)
d = \sqrt{\mathcal{D}}
R_{\mathrm{gold}}(d) = d\,(\alpha - \beta_{o}\log d)

Where:

  • J(\pi_{\theta}) is the RLHF objective actually optimized, and R_{\mathrm{gold}} is the true human-judged quality, which is never in the gradient.
  • x is the prompt, y \sim \pi_{\theta}(\cdot\mid x) the sampled completion, and \pi_{\mathrm{ref}} the frozen SFT reference policy.
  • r_{\phi} is the learned proxy reward, r^{*} the intended reward, and \epsilon the model error whose magnitude grows off the preference-data support.
  • \beta is the KL coefficient (typical range 0.01 to 0.1), so \beta \to 0 removes the leash and \beta large pins the policy to the reference.
  • d is the square-root KL distance used as the x-axis of overoptimization scaling laws; \alpha and \beta_{o} are fitted constants, distinct from the KL coefficient \beta.
  • Required initial condition: \pi_{\theta} = \pi_{\mathrm{ref}} at step 0, so d = 0 and R_{\mathrm{gold}} starts at the SFT baseline; the peak of the fitted curve sits at \log d = (\alpha - \beta_{o})/\beta_{o}.
Line chart with square-root KL distance on the x axis showing proxy reward rising monotonically while gold reward rises to a peak near d equals 3.1 and then declines below zero, with the peak marked as the early stopping point

Figure 2: Illustrative overoptimization: the proxy score the trainer logs never stops improving, while gold reward turns over around d \approx 3.1 and eventually falls below the SFT baseline.

MitigationMechanismWhat it buysCost or limitation
KL penalty and early stoppingBounds the distance travelled from the reference policyKeeps the policy inside the region where the proxy was validatedCaps genuine gains too; the right KL budget is only knowable from gold evals
Reward model ensemblesScore with several models, optimize a pessimistic aggregate such as the minimumSuppresses idiosyncratic per-model error spikesMembers share preference data, so correlated biases like length survive; N times the scoring cost
Iterative on-policy relabelingCollect fresh preferences on current-policy samples and refit the reward modelDirectly closes the distribution shift that creates the error termSlow and expensive; each round needs new human annotation
Explicit bias disentanglingFactor the reward into a quality head and a length or format head, then discard the latterRemoves the single largest known spurious correlateOnly fixes biases you already named; new exploits appear elsewhere
Verifiable or rule-based rewardReplace the learned model with a checker: unit tests, a symbolic solver, format rulesNo learned error surface to climb on checkable tasksOnly applies where ground truth exists; test gaming and reward tampering remain

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *