TL;DR
Standard reinforcement learning for code generation suffers from "sparse rewards"—you only know if the code works after it's finished. This paper introduces PSGPO, a method that uses a Process Reward Model (PRM) to provide line-by-line feedback, significantly boosting the performance of LLMs on complex, long-form coding tasks by mimicking how humans debug and refine code.
What Problem Does This Paper Address?
Reinforcement Learning from Unit Test Feedback (RLTF) is the current state-of-the-art for fine-tuning coding models. However, it has a major flaw: the reward signal is binary and sparse. If a model generates 50 lines of code and a single typo on line 5 causes a test failure, the model receives a reward of zero for the entire attempt.
This "all-or-nothing" approach makes it incredibly difficult for models to learn from their mistakes, especially on difficult problems where they might never stumble upon a perfect solution by chance. Humans don't code this way; we write a few lines, check our logic, and fix errors incrementally. The authors aim to bridge this gap by providing "dense" rewards—feedback for every single line generated.
Methods
The authors propose Process Supervision-Guided Policy Optimization (PSGPO). The workflow consists of two main phases:
-
Automated Data Collection & PRM Training: To train a reward model without expensive human labeling, the researchers used a binary search strategy (Figure 2). For a given code snippet, they check if the first $m$ lines can be completed into a working solution. If yes, that prefix is labeled "correct" (+1); if no, it's "incorrect" (-1). This allows them to pinpoint the exact line where a program goes off the rails.
Figure 2. Binary search over code steps at line level to label pre- fixes. The first midpoint at m = 3 is accepted, so the search interval moves to [4, 5]. The next midpoint at m = 4 is rejected, indicating errors occur after step 3. -
Integrating PRM into RL: They integrate the trained PRM into the Proximal Policy Optimization (PPO) framework in two ways:
-
Dense Rewards: The PRM acts as an "intermediate judge," giving a score at every newline character.
- Value Initialization: The PRM is used to initialize the RL "value function," giving the model a better starting estimate of how "good" a partial state is.
To prevent "reward hacking"—where the model might learn to generate endless comments to farm positive rewards—the authors implemented length normalization and neutral labeling (0 reward) for comment lines.
Datasets
- Training: An in-house RLHF dataset containing approximately 30,000 diverse coding problems with associated unit tests.
- Evaluation:
- HumanEval: 164 hand-crafted Python problems.
- MBPP: 974 entry-level Python programming tasks.
- LiveCodeBench (v3): A high-difficulty benchmark featuring 612 tasks from recent competitive programming contests (May 2023 – July 2024).
Key Insights and Ideas
- Synergy is Key: Using the PRM for both dense rewards and value function initialization performed better than using either alone. The dense rewards encourage exploration, while the value initialization stabilizes the training.
- Long-Horizon Specialist: PRMs provide the most benefit for complex, long-form code (over 100 tokens). For very short snippets, the standard "pass/fail" reward is often sufficient, but for long programs, the intermediate guidance is transformative (Figure 4).
- Quality Over Quantity: The most valuable training data for the PRM came from "Revised" samples—cases where the model initially failed but a viable prefix existed. Training only on these "hard-won" corrections yielded better results than using the full, noisier dataset.
- Exploration Boost: Models trained with PRMs showed a much higher "Best-of-K" pass rate, suggesting they are better at exploring the solution space and finding correct answers within a few attempts.
Key Results
The researchers tested their method on two base models: Qwen2.5-7B and Doubao-Lite.
- LiveCodeBench: Qwen2.5-7B-RL improved from a 27.5% pass rate (baseline) to 30.1% using the full PSGPO method.
- HumanEval: Doubao-Lite-RL saw a jump from 65.1% to 70.9%.
- Efficiency: The model achieved a nearly 4% increase in Pass@30 over the baseline, demonstrating that the PRM helps the model learn more robustly from fewer training steps.
Limitations and Future Work
-
Data Noise: The automated binary search method relies on the model's own ability to "complete" a prefix. If the model is weak, the labels might be noisy.
-
Computational Cost: Running binary search and multiple rollouts for every training sample is computationally expensive.
- Domain Specificity: The method currently relies on unit tests. Applying this to "softer" domains like creative writing or open-ended reasoning remains a challenge because there is no "compiler" to verify intermediate steps.
- Future Directions: The authors suggest exploring alternative evaluation methods to extend PRMs beyond structured domains like code.
Summary updated