Reasoning Through Execution: Unifying Process and Outcome Rewards for Code Generation

Zhuohao Yu, Weili Gu, Yidong Wang, Zhengran Zeng, Jindong Wang, Wei Ye, Shikun Zhang, Zhang, Shikun · DOI

Abstract

Large Language Models excel at code generation yet struggle with complex programming tasks that demand sophisticated reasoning. To bridge this gap, traditional process supervision relies on learned reward models requiring costly training data and suffering from reward misalignment, while outcome supervision fails for complex tasks needing coordinated intermediate steps. We introduce Outcome Refining Process Supervision (ORPS), which unifies process and outcome supervision by leveraging executable verification: a tree-structured search framework generates strategic alternatives, profiles execution metrics, and scores candidates via self-critique mechanisms that integrate runtime feedback with reasoning. Experiments across 5 models and 3 benchmarks show consistent gains, with 26.9% higher correctness and 42.2% improved code efficiency. The results demonstrate that ORPS enables LLMs to overcome local optima in code generation, suggesting a promising direction for combining verifiable outcomes with structured reasoning to tackle complex challenges.

Introduction: The Limits of Current Supervision

While Large Language Models (LLMs) have revolutionized automated coding, their performance degrades significantly when faced with complex algorithmic challenges, such as dynamic programming or intricate optimization. Current supervision paradigms for improving these models generally fall into two categories, each with distinct limitations:

  1. Outcome Supervision: This approach evaluates only the final output against test cases. While objective, it treats the reasoning process as a "black box," often leading the model into local optima—solutions that might pass basic tests but are inefficient, fragile, or logically flawed.
  2. Process Supervision: This method attempts to guide the model through intermediate reasoning steps using Process Reward Models (PRMs). However, PRMs are expensive to train, requiring dense human-annotated labels. Furthermore, they are susceptible to "reward hacking," where the model learns to generate text that satisfies the reward model without actually solving the underlying problem.

The fundamental insight of this work is that code, unlike natural language or mathematics, offers a unique advantage: it is verifiable through execution. By leveraging this objective signal, we can supervise the reasoning process itself without the need for external, human-labeled reward models.

Methodology: Outcome-Refining Process Supervision (ORPS)

We propose the Outcome-Refining Process Supervision (ORPS) framework, an inference-only approach that treats code refinement as a supervised reasoning process. Instead of linear generation, ORPS employs a tree-structured beam search consisting of three iterative phases:

Comparison of Outcome Supervision, Process Supervision, and the proposed ORPS framework. ORPS unifies these by using execution feedback to refine reasoning steps.
  1. Candidate Generation: The LLM generates multiple strategic alternatives (e.g., comparing a greedy approach vs. a divide-and-conquer strategy) and their corresponding implementations.
  2. Execution & Profiling: Each candidate is executed against unit tests. The system captures dynamic metrics (execution time, CPU instructions, memory usage) and static metrics (code length, cyclomatic complexity).
  3. Self-Critic & Process Rewarding: The LLM acts as its own critic, reviewing the reasoning chain alongside the hard execution data to assign a "step reward." This reward guides the search toward the most promising trajectories, preventing the hallucinations common in traditional PRMs.

Experimental Setup and Results

We evaluated ORPS across five models (including Qwen and DeepSeek variants) on three benchmarks: LBPP (Long-form Benchmark for Python Programming), HumanEval, and MBPP. LBPP is particularly noteworthy as it focuses on competitive programming algorithms, providing a more rigorous test of complex reasoning than standard functional completion tasks.

Quantitative Performance

The implementation of ORPS led to substantial improvements across all metrics:

  • Correctness: We observed an average 26.9% improvement in Pass@1 across all models and datasets.
  • Efficiency: Code generated via ORPS showed a 42.2% reduction in execution time on average.
  • Scaling with Compute: Unlike simple Best-of-N (BoN) sampling, which often hits diminishing returns, ORPS scales effectively with increased inference budgets.
Pass@1 performance vs. inference budget. ORPS demonstrates superior scaling potential compared to Best-of-N (BoN) sampling for both Qwen and DeepSeek models.

Key Insights

  • Execution as Ground Truth: Real-time execution feedback "grounds" the LLM's reasoning. If a model believes a step is correct but the code fails, the self-critique mechanism forces a strategic pivot, effectively avoiding the "hallucination" trap.
  • Strategic Reasoning over Model Scale: A smaller model (e.g., Qwen-7B) using ORPS can outperform a much larger model (e.g., Qwen-14B) using standard methods. This suggests that providing "reasoning space" and structured search can be more effective than simply increasing parameter counts.
  • Multi-Objective Optimization: By incorporating metrics like branch misses and instruction counts into the reward signal, ORPS incentivizes the discovery of superior algorithms (e.g., moving from O(n^2) to O(n log n) solutions).

Limitations and Future Outlook

Despite its success, ORPS relies heavily on the quality of available unit tests. Weak test coverage can compromise the feedback loop. Additionally, tree-structured search introduces higher inference-time computational costs, though it remains more efficient than brute-force alternatives. Future work will explore adaptive reward scaling and extending this "reasoning through execution" paradigm to other verifiable domains like formal logic and mathematics.

Summary updated

BibTeX
@inproceedings{yu2025reasoning,
  author = {Zhuohao Yu and Weili Gu and Yidong Wang and Zhengran Zeng and Jindong Wang and Wei Ye and Shikun Zhang and Zhang, Shikun},
  title = {{Reasoning Through Execution: Unifying Process and Outcome Rewards for Code Generation}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=pLQtovjXiw},
}
Figure