Training Language Models to Generate Quality Code with Program Analysis Feedback

Feng Yao, Zilong Wang, Liyuan Liu, Junxia Cui, Li Zhong +5 more
5/28/2025
cs.CLcs.AI

No official code found. Best implementation: yaof20/ReaL (43 stars, Apache-2.0, last commit 2025-07-21).

Abstract

Code generation with large language models (LLMs), often termed vibe coding, is increasingly adopted in production but fails to ensure code quality, particularly in security (e.g., SQL injection vulnerabilities) and maintainability (e.g., missing type annotations). Existing methods, such as supervised fine-tuning and rule-based post-processing, rely on labor-intensive annotations or brittle heuristics, limiting their scalability and effectiveness. We propose REAL, a reinforcement learning framework that incentivizes LLMs to generate production-quality code using program analysis-guided feedback. Specifically, REAL integrates two automated signals: (1) program analysis detecting security or maintainability defects and (2) unit tests ensuring functional correctness. Unlike prior work, our framework is prompt-agnostic and reference-free, enabling scalable supervision without manual intervention. Experiments across multiple datasets and model scales demonstrate that REAL outperforms state-of-the-art methods in simultaneous assessments of functionality and code quality. Our work bridges the gap between rapid prototyping and production-ready code, enabling LLMs to deliver both speed and quality.

View on arXivView PDF

Code Implementations(1)

yaof20/ReaLCommunity100%
Apache-2.0

Implementation and datasets for "Training Language Models to Generate Quality Code with Program Analysis Feedback"

431Shell, PythonMay 18, 20251 years agoApache-2.0
codegenprogram-analysisreinforcement-learning

Similar Papers

Cite this paper

@article{yao2025training,
  title  = {Training Language Models to Generate Quality Code with Program Analysis Feedback},
  author = {Feng Yao and Zilong Wang and Liyuan Liu and Junxia Cui and Li Zhong and Xiaohan Fu and Haohui Mai and Vish Krishnan and Jianfeng Gao and Jingbo Shang},
  year   = {2025},
  eprint = {2505.22704},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.22704v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.22704.svg)](https://codeofpaper.com/paper/2505.22704)

Discussion