Skip to main content
Back to timeline
arXivSource publication:

Unit-test rewards teach models to edit more: PreciseCoder cuts average edits from 7–15 lines to 3 without losing pass rate

Synopsis

Reinforcement learning from unit tests raises pass rates but also teaches code models to edit more and to invent bugs in programs that are already correct. PreciseCoder adds a signal for semantically verified edit precision and recall against a reference repair; on 4B, 9B and 27B models it cuts the average edit from 7–15 lines to 3 at a pass rate on par with unit-test-only training, and raises the no-edit rate on correct code to 47–52%.

AI-generated editorial illustration: PreciseCoder: Faithful and Generalizable Debugging Beyond Unit-Test Rewards

Interpretation

Debugging patches can be smaller: at 4B, 9B and 27B, the trained models change about 3 lines on average, where comparable training changed 7–15. Unit-test-only reinforcement learning raises pass rates while the mean edit grows from 3.94 to 8.28 lines, and the no-op rate on correct programs falls from 30.8% to 20.5% averaged over the last three evaluations. On the PDB test set, Qwen3.5-4B drops from 13.8 edited lines under unit-test-only GRPO to 3.0, at 55.3% versus 55.1% pass rate; at 9B the figures are 3.0 versus 11.9 lines at 62.5% versus 63.9% pass rate.

The reward no longer scores only whether the program passes; it checks, fault by fault, whether each edit block actually repairs a fault and what share of edited lines was needed. Earlier remedies penalized edit size or imitated minimal patches, but edit size correlates only weakly with passing the tests, so optimizing it trades pass rate for smaller edits. On Qwen3.5-4B, rewarding precision alone reaches 69.0–70.1% precision at 2.5–2.6 lines but passes 3–5 points fewer tasks than the combined reward; rewarding recall alone gives the highest pass rate, 57.2%, with the least precise repairs, 52.2%.

Precision learned only on single-line bugs carries to multi-line faults, repository-level repair and multi-turn agentic editing. Training uses only single-file, single-line bugs repaired in one shot; multi-line and repository-level tasks never appear. On the 484 multi-line and repository-level tasks of PDB-Wild, edit precision rises over the base model by 20.3, 16.7 and 20.2 points at 4B, 9B and 27B, and mean edits fall from 37.8 to 10.8 lines, 33.9 to 12.0 and 18.4 to 6.8; on SWE-Bench Verified the 9B model resolves 32.7% of issues against 25.9% for its base.

Perspective

All training and evaluation are in Python: training tasks come from PDB single-line bugs derived from BigCodeBench and LiveCodeBench, and evaluation covers the PDB test set, PDB-Wild, SWE-Bench Verified, HumanEval+, CruxEval and the Python subset of DebugBench. The reward needs a reference repair for every training task, drawn from the benchmark, a human patch, or a model-generated fix that passes the tests.

Precision and recall are measured against a reference repair, so every training task needs one; computing them with semantic verification adds about 5–7% to the wall-clock time of unit-test-only training. The authors note the method is not specific to Python but have not run it in another language.