一句话:提出自导向 LLM 修复框架 ThinkRepair,通过自动收集思维链与少样本交互来修复缺陷。
自动化程序修复虽已取得进展,但修复需要理解程序逻辑的缺陷仍有困难;LLM 方法又依赖高质量提示,人工构建成本高。本文提出自导向的 LLM 修复方法 ThinkRepair,包含收集与修复两阶段:收集阶段用思维链提示让 LLM 自动生成多种修复思路作为先验知识;修复阶段先为少样本学习选择示例,再自动与 LLM 交互,并可加入测试反馈。在 Defects4J 与 QuixBugs 上对比 12 个 SOTA APR:Defects4J V1.2 修复 98 个缺陷,较基线提升 27%~344.4%;V2.0 比 SOTA 多修 12~65 个;QuixBugs 上 Java 最多 31 个、Python 最多 21 个。
Though many approaches have been proposed for Automated Program Repair (APR) and indeed achieved remarkable performance, they still have limitations in fixing bugs that require analyzing and reasoning about the logic of the buggy program. Recently, large language models (LLMs) instructed by prompt engineering have attracted much attention for their powerful ability to address many kinds of tasks including bug-fixing. However, the quality of the prompt will highly affect the ability of LLMs and manually constructing high-quality prompts is a costly endeavor. To address this limitation, we propose a self-directed LLM-based automated program repair, ThinkRepair, with two main phases: collection phase and fixing phase. The former phase automatically collects various chains of thoughts that constitute pre-fixed knowledge by instructing LLMs with the Chain-of-Thought (CoT) prompt. The latter phase targets fixing a bug by first selecting examples for few-shot learning and second automatically interacting with LLMs, optionally appending with feedback of testing information. Evaluations on two widely studied datasets (Defects4J and QuixBugs) by comparing ThinkRepair with 12 SOTA APRs indicate the priority of ThinkRepair in fixing bugs. Notably, ThinkRepair fixes 98 bugs and improves baselines by 27%∼344.4% on Defects4J V1.2. On Defects4J V2.0, ThinkRepair fixes 12∼65 more bugs than the SOTA APRs. Additionally, ThinkRepair also makes a considerable improvement on QuixBugs (31 for Java and 21 for Python at most).
DOI 原文 ·
@inproceedings{paperbot8506,
title = {ThinkRepair: Self-Directed Automated Program Repair},
author = {Xin Yin and Chao Ni and Shaohua Wang and Zhenhao Li and Limin Zeng and Xiaohu Yang},
booktitle = {ISSTA},
year = {2024},
doi = {10.1145/3650212.3680359}
}