paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Template-Guided Program Repair in the Era of Large Language Models

大语言模型时代的模板引导程序修复
ICSE 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE)2025匹配度 4/10 · 该论文研究自动程序修复,结合模板与微调 LLM,虽属程序语言与机器学习交叉,但与用户核心方向(静态分析用于 Agentic 程序、LLM 改进静态分析/形式化验证、浮点/贝叶斯程序分析)无直接关联;其任务与评估基准(Defects4J、HumanEval-Java)也非用户关注的新场景或工业落地案例。引用 15 inbox
Kai Huang, Jian Zhang, Xiangxin Meng, Yang Liu
crossref: 2026-09-12

AI 速览

一句话:提出 NTR 两阶段框架,用微调 LLM 做模板选择与补丁生成,显著提升自动程序修复效果。

论文关注自动程序修复(APR)中 LLM 与传统模板方法结合不充分的问题:模板被不加区分地使用、覆盖不足,小规模 LLM 的零样本修复效果欠佳。作者提出 NTR(Neural Template Repair),一个包含模板选择与补丁生成两阶段的微调框架。模板选择被建模为多分类问题,微调百万级参数的 LLM 以挑选候选模板;补丁生成阶段则以选中的模板(如“修改条件表达式”)作为可能方向,指导十亿级 LLM 微调以精确生成补丁。框架还引入表示“无合适模板”的特殊模板,并按概率对模板排序,从而缓解模板不匹配问题,并在 GPU 显存受限下高效搜索补丁空间。在 Defects4J V1.2 与 HumanEval-Java 上,NTR 配合 StarCoder 分别修复 128 与 129 个缺陷,超过最佳基线 14 与 59 个;配合更大的 CodeLlama 则达 139 与 136 个,超过基线 25 与 66 个,且相比基础模型自身能力额外修复 22 与 23 个缺陷。

问题
现有基于 LLM 的自动程序修复与模板方法结合不足:模板使用不加区分、覆盖有限,且零样本下小规模 LLM 修复效果不佳。
方法
提出两阶段微调框架 NTR:先用百万级 LLM 以多分类方式选择模板,再以所选模板为方向微调十亿级 LLM 生成补丁,并引入“无合适模板”类别与基于概率的模板优先级排序。
评估
在 Defects4J V1.2 与 HumanEval-Java 上以 StarCoder 和 CodeLlama 为基座模型进行评测,与最强基线 APR 工具比较修复缺陷数量。
原文摘要(Abstract)

Recent advancements in automated program repair (APR) have been significantly driven by the application of Large Language Models (LLMs). In particular, the integration of LLMs with traditional template-based repair methods has demonstrated effective outcomes. Despite this, the synergy between the strengths of traditional methods and LLMs remains underexploited. This oversight originates from the indiscriminate use of templates and their insufficient coverage. Also, using small-scale LLMs within the zero-shot learning context proves to be suboptimal. To alleviate the limitations, we propose NTR (Neural Template Repair), a two-stage repair framework including template selection and patch generation, both of which are under the fine-tuning paradigm. In the template selection phase, we formulate it as a multiclass classification problem and fine-tune million-level LLMs for better selecting possible templates. During the patch generation phase, we leverage the chosen templates as probable directions (e.g., ‘Mutate Conditional Expression’) to guide the fine-tuning process of LLMs at the billion-level scale for precise patch creation. Moreover, we incorporate a unique template to signify the absence of a suitable template and employ a probability-based prioritization of templates, thereby optimizing patch generation. This framework not only effectively addresses template mismatch issues, but also enables the billion-level LLMs to explore the patch space more efficiently, despite the GPU memory constraints. We evaluate NTR with different foundational models on Defects4J V1.2 and HumanEval-Java, the framework consistently demonstrates significant effectiveness. When utilizing StarCoder as the foundational model for patch generation, NTR fixes 128 and 129 bugs in Defects4J and HumanEval, outperforming the best baseline APR tool by 14 and 59 bugs. With the larger CodeLlama model, the fixed bugs rise to 139 and 136, respectively, exceeding the baseline by 25 and 66 bugs. Notably, the performance stems not only from the foundational models but also benefits greatly from our NTR framework. Specifically, NTR's implementation with StarCoder and CodeLlama leads to 22 and 23 additional fixes, which is beyond what the models achieve on their own. This emphasizes the success of our new perspective on utilizing templates to unlock the bug-fixing potential of LLMs.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8756,
  title = {Template-Guided Program Repair in the Era of Large Language Models},
  author = {Kai Huang and Jian Zhang and Xiangxin Meng and Yang Liu},
  booktitle = {ICSE},
  year = {2025},
  doi = {10.1109/icse55347.2025.00030}
}