Specification Self-Correction: Mitigating In-Context Reward Hacking Through Test-Time Refinement

Víctor Gallego
7/24/2025
cs.CLcs.AI

Official code: vicgalle/specification-self-correction (4 stars, MIT, last commit 2025-07-24).

Abstract

Language models (LMs) are susceptible to in-context reward hacking, where they exploit flaws in tainted or faulty written specifications or rubrics to achieve high scores without fulfilling the user's true intent. We introduce Specification Self-Correction (SSC), a novel, test-time framework that enables an LM to identify and correct flaws within its own guiding specification. SSC employs a multi-step inference process where the model first generates a response based on a potentially tainted specification, critiques its output, and then revises the specification itself to remove the exploitable loophole. A final, more robust response is then generated using this self-corrected specification. Across experiments spanning creative writing and agentic coding tasks with several LMs, we demonstrate that while models initially game tainted specifications in 50-70\% of cases, the SSC process reduces this vulnerability by over 90\%. This dynamic repair occurs at inference time, requires no weight modification, and leads to more robustly aligned model behavior. Code at https://github.com/vicgalle/specification-self-correction .

View on arXivView PDF

Code Implementations(1)

MIT

Code for the paper "Specification Self-Correction: Mitigating In-Context Reward Hacking Through Test-Time Refinement"

40PythonJul 24, 20251 years agoMIT
llmreward-hackingtest-timetest-time-compute

Similar Papers

Cite this paper

@article{gallego2025specification,
  title  = {Specification Self-Correction: Mitigating In-Context Reward Hacking Through Test-Time Refinement},
  author = {Víctor Gallego},
  year   = {2025},
  eprint = {2507.18742},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2507.18742v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2507.18742.svg)](https://codeofpaper.com/paper/2507.18742)

Discussion