一句话:提出 FLAMES,用语义引导最佳优先搜索替代束搜索,降低 LLM 程序修复内存消耗并提升修复效果。
基于大语言模型(LLM)的自动程序修复面临内存效率问题:补丁生成阶段常依赖束搜索,增大束宽会显著占用 GPU,甚至导致高达 80% 的内存过载崩溃;量化和串行化束搜索因 APR 需要大束宽而效果有限。本文提出 FLAMES,以贪心解码提升内存效率,并用语义引导的最佳优先搜索替代束搜索:在每个解码步,根据测试验证的语义反馈(通过/失败测试数量)选择最有潜力的 token 继续探索。在 Defects4J 上,FLAMES 相比现有 LLM-based APR 减少最多 83% 内存,同时修复 133 个 bug,比最佳基线多 10 个;在 HumanEval-Java 和 TransformedD4J 上也分别多生成 12% 和 36.5% 的正确补丁。
Fixing software bugs is crucial yet demands significant resources from developers. Automated Program Repair (APR) is a promising solution to address this challenging task. The emergence of Large Language Models (LLMs) has opened a new era of LLM-based APR, substantially advancing the APR field further. LLM-based APR methods face significant challenges regarding memory inefficiency, hindering their scalability and effectiveness. This is largely due to the beam search utilized in the patch generation phase of LLM-based APR, which requires large beam sizes to search for more potentially good repair candidates. In this paper, we first show that increases in beam size, even for small-sized LLMs (1B-7B params), require extensive GPU usage, leading to up to 80% of recurring crashes due to memory overloads in LLM-based APR. Seemingly simple solutions to reduce memory consumption are (1) to quantize LLM models, i.e., converting the weights of an LLM from high-precision values to lower-precision ones, and (2) to make beam search sequential, i.e., forwarding each beam through the model sequentially and then concatenating them back into a single output. However, we show that these approaches still do not work in APR due to the demand of large beam sizes. To address this, we introduce FLAMES, a novel LLM-based APR technique that employs semantic-guided patch generation to enhance repair effectiveness and memory efficiency. Unlike conventional methods that rely on beam search, FLAMES utilizes greedy decoding to enhance memory efficiency while steering the search towards more potentially good repair candidates via a semantic-guided best-first search algorithm. At each decoding step, FLAMES uses semantic feedback from test validation, such as the number of passing and failing test cases, to select the most promising token to explore further. Our empirical evaluation on Defects4J shows that FLAMES substantially reduces memory consumption by up to 83% compared to LLM-based APR without compromising time efficiency. Moreover, FLAMES correctly fixes 133 bugs on Defects4J, fixing 10 bugs more than the best baseline. Additionally, these improvements also generalize to the HumanEval-Java and TransformedD4J datasets, where FLAMES generates 12% and 36.5% more correct patches, respectively, than the best baseline.