Skip to main content
QUICK REVIEW

[论文解读] Is Self-Repair a Silver Bullet for Code Generation?

Theo Olausson, Jeevana Priya Inala|arXiv (Cornell University)|Jun 16, 2023
Model-Driven Software Engineering Techniques被引用 4
一句话总结

本文研究了自我修复——即大型语言模型自主调试并修复自身代码——是否能在代码生成中作为可扩展的性能提升手段。在 HumanEval 和 APPS 基准测试中,使用 CodeLlama、GPT-3.5 和 GPT-4 进行实验,发现考虑到计算成本后,自我修复仅带来适度的性能提升,且性能高度依赖于反馈质量。关键发现是,将模型生成的反馈替换为人类水平的反馈,可使修复成功率提升 1.58 倍,表明自我修复并非万能方案,其效果仍受限于模型自我反思的准确性。

ABSTRACT

Large language models have shown remarkable aptitude in code generation, but still struggle to perform complex tasks. Self-repair -- in which the model debugs and repairs its own code -- has recently become a popular way to boost performance in these settings. However, despite its increasing popularity, existing studies of self-repair have been limited in scope; in many settings, its efficacy thus remains poorly understood. In this paper, we analyze Code Llama, GPT-3.5 and GPT-4's ability to perform self-repair on problems taken from HumanEval and APPS. We find that when the cost of carrying out repair is taken into account, performance gains are often modest, vary a lot between subsets of the data, and are sometimes not present at all. We hypothesize that this is because self-repair is bottlenecked by the model's ability to provide feedback on its own code; using a stronger model to artificially boost the quality of the feedback, we observe substantially larger performance gains. Similarly, a small-scale study in which we provide GPT-4 with feedback from human participants suggests that even for the strongest models, self-repair still lags far behind what can be achieved with human-level debugging.

研究动机与目标

  • 在考虑计算成本的前提下,评估自我修复是否能显著提升 LLM 代码生成性能。
  • 探究反馈质量在自我修复有效性中的作用,尤其针对复杂编程任务。
  • 在相同计算预算下,将自我修复性能与简单的独立同分布(i.i.d.)采样进行对比。
  • 评估更强模型或人类反馈是否能克服自我修复的局限性。

提出的方法

  • 本研究采用三阶段自我修复流程(代码生成、测试执行、反馈驱动修复)在 HumanEval 和 APPS 基准上评估 CodeLlama-13b-instruct、GPT-3.5 和 GPT-4 的表现。
  • 反馈生成方面,模型可自行生成反馈,或接收来自更强模型(如 GPT-4)或人类参与者的反馈。
  • 在相同计算预算下,将自我修复性能与 i.i.d. 采样进行对比,通过多次试验测量通过率。
  • 消融研究通过改变初始样本数量和修复尝试次数,评估多样性与修复深度之间的权衡。
  • 从参与者处收集人类反馈,以评估其对修复成功率的影响,并与模型生成反馈的结果进行对比。
  • 定量评估采用 pass@k 指标,并统计每段错误程序在 25 次修复尝试中的修复成功率。
Figure 1: Self-repair with separate code and feedback models. First, a user gives a specification in the form of text and a suite of unit tests (1). Then, a code model (blue) generates a program (2). The program is checked against the unit tests using a symbolic execution engine, and an error messag
Figure 1: Self-repair with separate code and feedback models. First, a user gives a specification in the form of text and a suite of unit tests (1). Then, a code model (blue) generates a program (2). The program is checked against the unit tests using a symbolic execution engine, and an error messag

实验结果

研究问题

  • RQ1在考虑计算成本的前提下,自我修复是否能显著优于 i.i.d. 采样?
  • RQ2反馈质量如何影响代码生成中自我修复的成功率?
  • RQ3能否通过用更强模型反馈或人类反馈替代模型生成的反馈,显著提升自我修复结果?
  • RQ4在何种条件下自我修复优于简单采样?例如,初始样本的多样性是否比大量修复尝试更具价值?
  • RQ5模型自我反思和识别自身错误的能力在多大程度上限制了自我修复的有效性?

主要发现

  • 在考虑计算成本时,自我修复并未始终优于 i.i.d. 采样;在某些情况下,通过率甚至与基线采样持平或更低。
  • 对于 GPT-4 在 APPS 上的表现,使用 10 个初始样本和 10 次修复尝试(共 20 次)的通过率比 pass@20 基线高出 1.05 倍,但使用 2 个初始样本和 10 次修复尝试(共 22 次)的通过率仅为基线的 0.97 倍。
  • 通过使用 GPT-4 为 CodeLlama 或 GPT-3.5 生成反馈,人工提升反馈质量后,修复成功率显著提高,优于原始自我修复和 i.i.d. 采样,且在所有计算预算下均表现更优。
  • 将 GPT-4 自身的反馈替换为人类生成的反馈,可使成功修复程序的比例提升 1.58 倍,表明模型自我反思能力是主要瓶颈。
  • 自我修复的成功高度依赖于反馈质量,模型在识别自身代码中细微的逻辑错误方面表现不佳,尤其当错误源于概念性误解时。
  • 在计算影响因子或基于阶乘的公式等任务中,模型生成的反馈常错误诊断根本原因,导致尽管反馈推理过程正确,修复仍失败。
Figure 2: A repair tree begins with a specification $\psi$ (root node), then grows into initial programs $\{p_{i}\}$ , feedback $\{f_{ij}\}$ , and repairs $\{r_{ijk}\}$ .
Figure 2: A repair tree begins with a specification $\psi$ (root node), then grows into initial programs $\{p_{i}\}$ , feedback $\{f_{ij}\}$ , and repairs $\{r_{ijk}\}$ .

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。