Skip to main content
QUICK REVIEW

[论文解读] Better patching using LLM prompting, via Self-Consistency

Toufique Ahmed, Prémkumar Dévanbu|arXiv (Cornell University)|May 31, 2023
Software Engineering ResearchComputer Science被引用 3
一句话总结

本文提出在少样本提示(few-shot prompting)中使用自一致性(self-consistency, SC)并以提交日志(commit log)消息作为推理路径,用于基于大语言模型(LLM)的程序修复。通过从LLM中采样多个解释-修复对,并选择最频繁的修复结果,该方法在MODIT数据集上实现了最先进(SOTA)的性能,相较于贪婪解码和基线提示方法具有统计上显著的提升,尤其是在少样本示例中使用正确提交日志时效果更佳。

ABSTRACT

Large Language models (LLMs) can be induced to solve non-trivial problems with "few-shot" prompts including illustrative problem-solution examples. Now if the few-shots also include "chain of thought" (CoT) explanations, which are of the form problem-explanation-solution, LLMs will generate a "explained" solution, and perform even better. Recently an exciting, substantially better technique, self-consistency [1] (S-C) has emerged, based on the intuition that there are many plausible explanations for the right solution; when the LLM is sampled repeatedly to generate a pool of explanation-solution pairs, for a given problem, the most frequently occurring solutions in the pool (ignoring the explanations) tend to be even more likely to be correct! Unfortunately, the use of this highly-performant S-C (or even CoT) approach in software engineering settings is hampered by the lack of explanations; most software datasets lack explanations. In this paper, we describe an application of the S-C approach to program repair, using the commit log on the fix as the explanation, only in the illustrative few-shots. We achieve state-of-the art results, beating previous approaches to prompting-based program repair, on the MODIT dataset; we also find evidence suggesting that the correct commit messages are helping the LLM learn to produce better patches.

研究动机与目标

  • 通过应用自一致性(SC)减少幻觉并提高解决方案可靠性,以改进基于LLM的程序修复。
  • 探究在软件工程中常见的提交日志消息是否可作为少样本提示中代码修复的有效推理路径。
  • 评估在少样本示例中使用真实提交日志与随机提交日志对修复准确率的影响。
  • 确定SC的最优采样数量,以在性能与计算成本之间取得平衡。
  • 证明使用真实提交日志的SC相较于基线提示方法能带来统计上显著的性能提升。

提出的方法

  • 通过包含输入代码、提交日志消息(作为推理路径)和正确修复结果的少样本示例,向LLM提示,应用自一致性(SC)于程序修复。
  • 使用较高温度采样多个解释-修复对,以鼓励生成多样化的推理路径。
  • 将所有采样对中出现最频繁的修复结果作为最终输出,实现对推理路径的边际化处理。
  • 使用BM25根据与测试输入的语义相似度,检索最相关的少样本示例。
  • 比较在少样本示例中使用真实提交日志与随机打乱的提交日志时的性能表现。
  • 以贪婪解码作为基线,并应用McNemar检验评估性能提升的统计显著性。

实验结果

研究问题

  • RQ1RQ1:与贪婪解码相比,使用提交日志消息作为推理路径的自一致性是否能提升程序修复的准确率?
  • RQ2RQ2:在自一致性中,需要多少个采样的解释-修复对才能实现最优性能?
  • RQ3RQ3:在少样本示例中使用真实提交日志是否比使用随机提交日志带来更高的性能提升?
  • RQ4RQ4:基于BM25的少样本检索方法与固定样本基线相比,在修复准确率方面表现如何?

主要发现

  • 与贪婪解码相比,自一致性在B2F_s上提升了42.10%(p < 0.01),在B2F_m上提升了38.39%(p < 0.01),表明具有统计显著性。
  • 使用BM25检索少样本示例进一步提升了准确率,相较于贪婪解码,分别提升了9.65%和13.08%。
  • 在少样本示例中使用真实提交日志,相较于基线,在B2F_s上提升了3.44%,在B2F_m上提升了4.18%,但统计显著性未达标准(p = 0.30)。
  • 在少样本示例中使用随机提交日志并未带来显著性能提升,表明模型无法从任意推理路径中获益。
  • 使用SC结合真实提交日志,模型在B2F_s上达到31.80%的准确率,在B2F_m上达到21.60%,优于先前方法如NatGen。
  • 在B2F_m上,性能在10个样本后趋于平稳;而在B2F_s上,性能继续提升(尽管收益递减),因此30个样本被认定为实用的默认采样数量。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。