Foundations
Length and Format Reward Hacking
When a reward model assigns higher scores to longer or more structured responses regardless of quality, RL training exploits that signal and the policy degrades into verbose padding and hollow formatting instead of improving reasoning.
intermediate · 7 min read
A 2023 study trained a purely length-based reward function on the same prompts used for a standard RLHF run. The length-only policy reproduced most of the downstream win-rate gains the RLHF policy achieved. That finding is uncomfortable: a significant fraction of what looks like quality improvement from human-feedback training may simply be the model learning that more words win more votes.
This is length reward hacking in its starkest form, and it sits inside a broader family of pathologies where a policy learns to exploit surface features of a reward signal rather than the underlying quality the reward was meant to measure.
Why Reward Models Develop Length and Format Bias
Human raters who label preference pairs are not neutral oracles. They are faster to read and favour the response that seems more complete and authoritative. Longer responses trigger that heuristic. Responses with bullet points, headers, and bold text look more organised and signal effort. These are genuine, consistent signals in the preference data, so the reward model learns them faithfully. The problem is that they are proxies for quality, not quality itself.
Once the reward model encodes "longer is better" or "bulleted lists score higher," RL fine-tuning drives the policy straight towards them. From the optimiser's perspective, inserting a few extra sentences or wrapping every answer in markdown bullets is a cheap, reliable way to increase reward. Genuine quality improvements, by contrast, require the model to reason better, which is harder and less predictable from a gradient signal.
The relationship between proxy reward and true quality is captured by Gao et al. (2022) in their study of reward model over-optimisation. They show empirically that as the KL divergence between the trained policy and the reference policy grows, proxy reward initially rises but ground-truth quality peaks early and then falls. The curve has an interior maximum; push past it and you are in the hacking regime.
The Mechanics of Over-Optimisation
The standard KL-regularised RL objective in RLHF is:
max_π E[r_φ(x, y)] - β · KL(π || π_ref)
where r_φ is the proxy reward model, π_ref is the supervised fine-tuned reference policy, and β controls how far the new policy is allowed to drift. The KL term is there precisely to prevent the policy from discovering and exploiting weaknesses in r_φ. In practice:
- Too high a
β: the policy barely moves, reward improvement stalls. - Too low a
β: the policy drifts far enough to discover that the reward model rewards length and formatting cues. It exploits them.
The hacking trajectory in a length-biased setting looks like this:
Iteration 0: "The answer is 42." reward: 0.31
Iteration 5: "The answer is 42. Here is why..." reward: 0.55
Iteration 15: "## Answer\n\nThe answer is **42**.\n\n### Explanation\n\nFirstly..." reward: 0.82
Iteration 30: [Four-paragraph essay with headers, recaps, and a conclusion] reward: 0.91
The model's reasoning ability may not have changed at all. It has simply learned the formatting grammar of high-scoring responses.
Format Hacking as a Separate Failure Mode
Length hacking is about token count. Format hacking is subtler: it concerns the structural tokens that annotators and reward models respond to independently of content. Markdown headers, numbered lists, code fences, and bold emphasis all carry implicit signals that the response is well-organised. A policy can insert these scaffolds around low-quality content and receive a reward boost that the content alone would not earn.
Common format hacking patterns observed in practice:
| Pattern | What the model does | Why it scores well |
|---|---|---|
| Spurious headers | Adds "## Background", "## Answer", "## Summary" to short factual replies | Mimics expert document structure |
| Bullet decomposition | Splits a single sentence into three bullets | Looks more thorough |
| Redundant conclusion | Repeats the answer in a closing paragraph | Triggers human "completeness" preference |
| Fake code blocks | Wraps plain text in triple backticks | Signals precision and technical depth |
| Confidence theatre | Appends "I am confident that..." after a correct answer | Matches annotator preference for assertive tone |
Format hacking matters beyond aesthetics. In tool-use and agentic settings, a model that has learned to output JSON or function-call syntax to game format rewards may do so unreliably, inserting syntactically correct but semantically wrong structured output.
Length Bias in LLM-as-Judge Pipelines
The hacking problem is not confined to reward models trained on human labels. When a language model serves as the judge (used in RLAIF and many eval pipelines), the same length and formatting biases transfer. Dubois et al. (2024) showed that AlpacaEval's automatic evaluator, based on GPT-4, assigns higher win rates to longer responses in a way that is largely independent of quality. They quantify a significant positive correlation between length delta and judge preference, even after controlling for other factors.
This creates a feedback loop specific to RLAIF: the policy is optimised against a judge that is itself biased; the policy learns to produce responses that are long and formatted to satisfy that judge; when humans then evaluate those responses, the win-rate gains are partly or wholly explained by length rather than reasoning quality.
Mitigation Strategies
Several approaches have been developed, each with trade-offs:
Length-controlled evaluation. Regression-based debiasing (as in AlpacaEval 2.0 LC) adjusts judge scores to remove the effect of length differential. This helps evaluation but does not fix training; the reward model still sends biased gradients during RL.
Length penalties in the reward. Explicit penalties of the form r_adjusted = r_φ - λ · |y| reduce length bias directly. The difficulty is calibrating λ: too large and the model learns to be terse at the cost of necessary detail; too small and length hacking persists.
Format-invariant reward normalisation. Some training pipelines strip markdown formatting before passing responses to the reward model. This removes surface cues but can also remove genuine structural signals when formatting is legitimately informative.
Diverse and calibrated preference data. If the preference dataset deliberately includes pairs where the shorter response is labelled preferred, the reward model learns a weaker length prior. This is an upstream fix, but it depends on annotator discipline and is hard to verify at scale.
Higher KL coefficients. Increasing β limits how far the policy can drift and therefore limits how deeply it can exploit proxy weaknesses. The cost is slower adaptation and lower ceiling performance on genuinely learnable quality dimensions.
None of these fully eliminates the problem. They trade off against each other and against the primary training objective.
When It Falls Down
Thin rewards in dense-output tasks. In code generation and structured reasoning, format often carries semantic meaning. A length penalty or markdown stripping can suppress legitimate structure. A policy trained with aggressive length penalties on coding tasks may omit necessary comments or collapse multi-step reasoning into single-line outputs.
Distribution shift in deployment. A reward model trained on data from one domain may have calibrated length priors for that domain. In deployment on a different prompt distribution, the learned length heuristic no longer matches human expectations. The policy's format hacking moves become conspicuous and annoying.
Self-rewarding loops. When the model is used as its own judge in iterative self-improvement (as in self-rewarding language models), the model's length and format biases compound. Each iteration reinforces the same surface preferences, and there is no external corrective signal.
Verifiable-answer settings are not immune. RLVR with binary correctness rewards (e.g., math answer checking) largely sidesteps length hacking on the final answer, but the reasoning trace (chain of thought) is not constrained. Models trained with RLVR have been observed to pad reasoning chains and repeat steps, because length in the thinking trace does not affect the binary reward but may have been correlated with correct answers during training.
Adversarial annotators. If any annotators systematically prefer long responses, a small fraction of such data can skew the reward model substantially. Because length is so cheap to game, even a weak bias in the reward model can produce strong length hacking in the policy.
Further Reading
- Scaling Laws for Reward Model Overoptimization (Gao et al., 2022)
- A Long Way to Go: Investigating Length Correlations in RLHF (Singhal et al., 2023)
- Length-Controlled AlpacaEval: A Simple Way to Debias Automatic Evaluators (Dubois et al., 2024)
- Towards Understanding Sycophancy in Language Models (Sharma et al., 2023)