paperbot · PL 论文追踪

全部论文 待读 收藏

P1 ROCODE: Integrating Backtracking Mechanism and Program Analysis in Large Language Models for Code Generation

ROCODE:将回溯机制与程序分析集成到大型语言模型中以用于代码生成
ICSE 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE)2025匹配度 6/10 · 该论文将程序分析(增量检错)与回溯机制融入 LLM 代码生成流程,属于 PL 与 LLM 交叉的 coding agent 方向,与“在 Agentic 程序中应用静态分析”有交集;但其核心目标仍是提升 LLM 代码生成,而非用 LLM/Agent 改进静态分析,也未涉及浮点或贝叶斯程序分析,因此匹配度中等。引用 6 inbox
Xue Jiang, Yihong Dong, Yongding Tao, Huanyu Liu, Zhi Jin, Ge Li
crossref: 2026-09-12

AI 速览

一句话:提出 Rocode,将程序分析增量检错与回溯重生成融入 LLM 代码生成,提前消除错误并提升通过率、降低开销。

大型语言模型自回归生成代码时易累积错误,且生成后修正成本高。Rocode 在生成过程中引入程序分析进行增量错误检测;一旦发现错误,触发回溯机制,执行回滚策略与约束重生成,从而尽早消除错误并在正确基础上继续生成。在多个代码生成基准上,编译通过率达 99.1%,测试通过率相较最佳基线最高相对提升 23.8%,相较生成后修正基线 token 成本降低 19.3%;方法模型无关,在九种代表性 LLM 上均取得一致提升。

问题
LLM 自回归代码生成中错误会逐步累积,且模型无法调整已生成内容,现有生成后修正方法难以及时消除累积错误并浪费资源。
方法
将程序分析用于生成过程中的增量错误检测,并在检测到错误时触发回溯机制,通过回滚策略和约束重生成实现即时纠错。
评估
在多个代码生成基准上与多个基线比较,并跨九种代表性 LLM 验证;报告编译通过率、测试通过率与 token 成本等指标。
原文摘要(Abstract)

Large language models (LLMs) have achieved impressive performance in code generation recently, offering programmers revolutionary assistance in software development. However, due to the auto-regressive nature of LLMs, they are susceptible to error accumulation during code generation. Once an error is produced, LLMs can merely continue to generate the subsequent code conditioned on it, given their inability to adjust previous outputs. Existing LLM-based approaches typically consider post-revising after code generation, leading to the challenging resolution of accumulated errors and the significant wastage of resources. Ideally, LLMs should rollback and resolve the occurred error in time during code generation, rather than proceed on the basis of the error and wait for post-revising after generation. In this paper, we propose Rocode,which integrates the backtracking mechanism and program analysis into LLMs for code generation. Specifically, we employ program analysis to perform incremental error detection during the generation process. When an error is detected, the backtracking mechanism is triggered to priming rollback strategies and constraint regeneration, thereby eliminating the error early and ensuring continued generation on the correct basis. Experiments on multiple code generation benchmarks show that ROCODE can significantly reduce the errors generated by LLMs, with a compilation pass rate of 99.1 %. The test pass rate is relatively improved by up to 23.8% compared to the best baseline approach. Compared to the post-revising baseline, the token cost is reduced by 19.3%. Moreover, our approach is model-agnostic and achieves consistent improvements across nine representative LLMs.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8685,
  title = {ROCODE: Integrating Backtracking Mechanism and Program Analysis in Large Language Models for Code Generation},
  author = {Xue Jiang and Yihong Dong and Yongding Tao and Huanyu Liu and Zhi Jin and Ge Li},
  booktitle = {ICSE},
  year = {2025},
  doi = {10.1109/icse55347.2025.00133}
}