[Paper Review] Coarse-Tuning Models of Code with Reinforcement Learning Feedback
This paper proposes Rlcf, a reinforcement learning-based coarse-tuning method that improves code generation in large language models by combining compiler feedback for syntactic/semantic correctness and a discriminator LLM to assess code similarity to reference solutions. The approach significantly boosts compilation and test-passing rates, enabling smaller models to match the performance of 2x–8x larger models on Java code synthesis tasks.
Large Language Models (LLMs) pre-trained on code have recently emerged as the dominant approach to program synthesis. However, these models are trained using next-token prediction, which ignores the syntax and semantics of code. We propose RLCF, that further trains a pre-trained LLM via reinforcement learning, using feedback from a grounding function that scores the quality of the code. The grounding function uses (i) compiler-derived feedback on whether the code it generates passes a set of correctness checks; and (ii) feedback from a different LLM that compares the generated code to a reference code. RLCF is model- and language-agnostic. We empirically evaluate it on the MBJP and MathQA tasks for Java. Our experiments show that RLCF raises the odds that an LLM-generated program compiles, is executable, and produces the right output on tests, often allowing LLMs to match the performance of 2x-8x larger LLMs.
Motivation & Objective
- To address the limitations of next-token prediction in code LLMs, which overlooks semantic and syntactic correctness and functional equivalence.
- To develop a reinforcement learning-based coarse-tuning method that improves code generation without requiring extensive test cases.
- To balance the objectives of generating syntactically valid, executable code and semantically correct, reference-like solutions using dual feedback signals.
- To evaluate whether this approach enables smaller LLMs to match the performance of much larger models on code synthesis tasks.
Proposed method
- Rlcf fine-tunes pre-trained code LLMs using reinforcement learning, treating code generation as a Markov decision process (MDP).
- The reward function combines two feedback signals: (1) compiler-based static analysis to detect syntax, type, and semantic errors, assigning negative rewards for failures.
- A second LLM discriminator evaluates whether the generated code is indistinguishable from a reference solution, providing positive rewards if it fools the discriminator.
- The discriminator is trained adversarially to distinguish generated code from reference code, encouraging the policy to produce more natural and correct programs.
- The method is model- and language-agnostic, applicable to models like CodeGen, CodeT5, and GPT-2.
- Training uses a policy gradient approach with a loss function that balances correctness and similarity to reference solutions.
Experimental results
Research questions
- RQ1Can reinforcement learning with dual feedback (compiler and discriminator) significantly improve the functional correctness and compilation success of LLM-generated code?
- RQ2Does Rlcf enable smaller LLMs to achieve performance comparable to much larger models on code synthesis tasks?
- RQ3How does Rlcf compare to supervised fine-tuning, compiler-only feedback, and prior RL baselines in terms of code quality and correctness?
- RQ4Is adversarial training of the discriminator necessary, or does a fixed discriminator perform just as well?
- RQ5To what extent do the gains from Rlcf stem from language-specific fine-tuning versus the RL feedback mechanism itself?
Key findings
- Rlcf significantly increases the odds that generated code compiles, is executable, and passes test cases on the MBJP and MathQA benchmarks.
- On the MathQA dataset, Rlcf improved Pass@100 from 29.40 to 29.93 for CodeGen (350M), and from 32.05 to 32.16 for CodeT5 (770M), demonstrating consistent gains.
- Rlcf enables smaller models (e.g., 350M parameter CodeGen) to match the performance of 2x–8x larger models in code generation tasks.
- The ablation study shows that Rlcf outperforms supervised baselines using cross-entropy loss, bipolar RAMP loss, and CodeRL, even when only compiler feedback is used.
- Adversarial training of the discriminator provides a marginal but consistent advantage over a fixed discriminator, though the difference is not always statistically significant.
- The method is robust across different model architectures, including CodeGen, CodeT5, and GPT-2, confirming its model-agnostic nature.
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.