一句话:将提交日志作为少样本解释,结合自一致性采样提升 LLM 程序修复补丁质量。
大语言模型可通过少样本提示、思维链和自一致性显著提升复杂问题求解能力,但自一致性依赖解释,而多数软件工程数据集缺少解释,限制了其在程序修复中的应用。本文提出在基于提示的程序修复中使用自一致性:仅在少样本示例里把修复对应的 commit log 当作解释,随后让 LLM 多次采样生成“解释-补丁”对,忽略解释并对候选补丁进行多数投票。在 MODIT 数据集上,该方法超过此前基于提示的程序修复方法,取得当前最优结果;进一步证据表明,正确的提交信息有助于 LLM 学会生成更好的补丁。
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” ($\mathcal{C}oT$) 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] ($\mathcal{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 $\mathcal{S}-C$ (or even $\mathcal{C}oT$) 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 $\mathcal{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.