[Paper Review] Execution-based Code Generation using Deep Reinforcement Learning
PPOCoder fine-tunes pre-trained code models with Proximal Policy Optimization using non-differentiable execution feedback and structure-based rewards to improve compilability and functional correctness across tasks and languages.
The utilization of programming language (PL) models, pre-trained on large-scale code corpora, as a means of automating software engineering processes has demonstrated considerable potential in streamlining various code generation tasks such as code completion, code translation, and program synthesis. However, current approaches mainly rely on supervised fine-tuning objectives borrowed from text generation, neglecting unique sequence-level characteristics of code, including but not limited to compilability as well as syntactic and functional correctness. To address this limitation, we propose PPOCoder, a new framework for code generation that synergistically combines pre-trained PL models with Proximal Policy Optimization (PPO) which is a widely used deep reinforcement learning technique. By utilizing non-differentiable feedback from code execution and structure alignment, PPOCoder seamlessly integrates external code-specific knowledge into the model optimization process. It's important to note that PPOCoder is a task-agnostic and model-agnostic framework that can be used across different code generation tasks and PLs. Extensive experiments on three code generation tasks demonstrate the effectiveness of our proposed approach compared to SOTA methods, achieving significant improvements in compilation success rates and functional correctness across different PLs.
Motivation & Objective
- Motivate improving code generation beyond token-level objectives by incorporating execution and structural correctness.
- Propose a task- and model-agnostic RL framework (PPOCoder) that leverages non-differentiable execution feedback.
- Integrate compiler signals, AST-based syntactic matching, and DFG-based semantic matching into a KL-regularized PPO objective.
- Demonstrate gains in compilation rate and functional correctness across code completion, translation, and NL2Code tasks.
Proposed method
- Initialize actor/critic from a pre-trained code model for the target task.
- Sample code from the current policy and compute a composite end-of-episode reward from compiler feedback, AST, and DFG matches, plus a KL-divergence penalty.
- Optimize with PPO using a CPI surrogate objective and a value head, ensuring stable, minimal-deviation updates.
- Reward components include: compiler signal (unit tests or syntactic correctness), AST-based syntactic match, DFG-based semantic match, and KL penalty.
- Encourage exploration/exploitation balance via KL-divergence term and clip-based PPO updates.

Experimental results
Research questions
- RQ1Can PPO-based fine-tuning with non-differentiable execution feedback improve compilability and functional correctness across PLs?
- RQ2How do compiler signals, AST structural matching, and DFG semantic matching contribute to code generation quality?
- RQ3Is the approach robust across tasks (code completion, code translation, NL-to-code) and programming languages?
- RQ4Does incorporating KL-divergence penalty mitigate memorization and improve generalization?
Key findings
- PPOCoder + CodeT5 increased compilation rate from 52.14% to 97.68% on code completion.
- PPOCoder + CodeT5 achieved competitive xMatch (42.63) and higher Edit Similarity (69.22) compared to CodeT5 alone (42.61, 68.54).
- On XLCoST code translation, PPOCoder + CodeT5 yielded higher compilation rates across languages, with notable gains (e.g., Python and Java) and competitive CodeBLEU scores.
- The framework improves compilation rates across six target languages (C++, Java, Python, C#, PHP, C) and maintains semantic alignment as reflected in CodeBLEU scores.
- Ablation studies show the reward components (compiler signal, AST/DFG matches, KL penalty) contribute to performance gains and stable training.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.