Counterfactual rewards reduce text-to-SQL reward hacking from 54.1% to 1.9%
November 26, 2026
A counterfactual-database reward approach improves text-to-SQL reinforcement learning by validating queries against multiple hidden, code-generated database copies. On 1,302 synthetic questions, the strict reward form reduced reward hacks from 54.1% to 1.9% and buggy queries from 29.5% to 16.8%.
HOW THIS AFFECTS YOU
●
builderYou can make your SQL agents more reliable by training them against multiple database variations rather than just one.
●
researcherUsing counterfactual execution helps prevent models from learning to exploit single-database biases during RL.