NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

$\mathcal{B}$-Coder: Value-Based Deep Reinforcement Learning for Program Synthesis

Zishun Yu, Yunzhe Tao, Liyu Chen, Tao Sun, Hongxia Yang

TL;DR

$\mathcal{B}$-Coder (pronounced "Bellman coder") is a novel framework that introduces value-based reinforcement learning (RL) to automated code generation. By employing a conservative training approach and initializing from pre-trained language models, it effectively learns from both human-written code and historical samples. This allows $\mathcal{B}$-Coder to outperform traditional policy-based methods with significantly less reward engineering.

What Problem Does This Paper Address?

Reinforcement learning has become a popular technique for fine-tuning Large Language Models (LLMs) in program synthesis. It enables models to optimize directly for functional correctness—such as passing unit tests—rather than merely predicting the next token.

However, most current approaches rely on policy-based RL (like PPO or REINFORCE). These "on-policy" methods can only learn from the code the model is currently generating, making them sample-inefficient and unable to leverage a wealth of "off-policy" data, such as human-written solutions and previous versions of the model's own code.

Value-based RL (like Q-learning) is naturally suited for learning from off-policy data, but it is notoriously difficult to train for code generation. The search space is "doubly exponential," as there are nearly infinite ways to combine tokens into a valid program. Without careful design, value-based agents often fail to converge in such high-dimensional environments.

Methods

The authors introduce $\mathcal{B}$-Coder, a value-based framework built upon a Dueling Deep Q-Network (DDQN) architecture. To make training feasible in the complex domain of program synthesis, they propose three key innovations:

  1. Task-Structure Leveraging: The Q-function is decomposed into state-value ($V$) and advantage ($A$) heads. The framework enforces a structure where ground-truth programs are encouraged to achieve the highest possible "advantage" scores.
  2. Smart Initialization: Instead of training from scratch, the Q-function is initialized using the logits (raw output scores) of a pre-trained LLM. This provides the agent with a "warm start" based on existing linguistic and programming knowledge.
  3. Conservative Bellman Operator: To prevent the model from making unstable updates in the massive search space, a conservative operator is used to penalize large deviations from a base policy.

Training occurs in stages: first pre-training the state-value function, and then fine-tuning the entire model.

The forward graphs for the different training stages of $\mathcal{B}$-Coder.

Datasets

The model was primarily trained and evaluated on:

  • APPS (Automated Programming Progress Standard): A comprehensive benchmark of 10,000 Python problems ranging from "Introductory" to "Competition" difficulty levels.
  • MBPP (Mostly Basic Python Problems): Used to test the model's ability to generalize to new, unseen tasks in a zero-shot setting.

Key Insights and Ideas

  • Natural Alignment: The authors argue that program synthesis is an ideal fit for value-based RL. Unlike natural language generation, where quality can be subjective, code has objective and easily obtainable rewards: it either passes the unit tests or it doesn't.
  • Stability is Key: Vanilla value-based methods often degrade over time on this task. $\mathcal{B}$-Coder’s smart initialization and conservative operator are crucial for enabling stable training and continuous improvement.
  • Implicit Reward Modeling: A fascinating byproduct of this value-based approach is that the learned Q-function acts as a "free" reward model. Even without running a single unit test during inference, $\mathcal{B}$-Coder can use its internal value estimates to rank multiple candidate programs and select the one most likely to be correct.

Key Results

$\mathcal{B}$-Coder achieved state-of-the-art (SOTA) performance on the APPS benchmark when compared to other RL-based methods of similar size (770M parameters).

  • Pass@1 Accuracy: On the full APPS test set, $\mathcal{B}$-Coder reached 2.30%, outperforming the previous SOTA, CodeRL (2.20%).
  • Pass@5 Accuracy: It achieved 3.80%, a significant improvement over CodeRL's 3.10%.
  • Generalization: The model's ranking strategy—leveraging the implicit reward model—improved performance even on programs it did not generate itself. When used to rank programs generated by CodeRL, it consistently boosted Pass@k scores across various difficulty levels.
Comparison of $\mathcal{B}$-Coder against various baselines on the APPS test set.

Limitations and Future Work

While $\mathcal{B}$-Coder serves as a strong proof-of-concept for value-based RL in code generation, the authors note a few limitations:

  • Complexity: The framework introduces additional frozen parameters and requires a multi-stage training process.
  • Raw Performance: Without the ranking strategy, the "raw" generation performance can sometimes be mixed compared to highly-tuned policy-based baselines.
  • Scaling: Current experiments were conducted on models up to 770M parameters. Testing these value-based techniques on multi-billion parameter models remains an open challenge for future research.

Summary updated

BibTeX
@inproceedings{yu2024mathcal,
  author = {Zishun Yu and Yunzhe Tao and Liyu Chen and Tao Sun and Hongxia Yang},
  title = {{$\textbackslash\{\}mathcal\{B\}$-Coder: Value-Based Deep Reinforcement Learning for Program Synthesis}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=fLf589bx1f},
}
Figure