Skip to main content
QUICK REVIEW

[Paper 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 TechniquesComputer Science4 citations
TL;DR

This paper investigates whether self-repair—where large language models debug and fix their own code—serves as a scalable performance booster in code generation. Using CodeLlama, GPT-3.5, and GPT-4 on HumanEval and APPS benchmarks, it finds that self-repair offers only modest gains when computational cost is considered, and performance heavily depends on feedback quality. Crucially, replacing model-generated feedback with human-level feedback boosts repair success by 1.58×, indicating self-repair is not a silver bullet and remains limited by the model’s introspective accuracy.

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.

Motivation & Objective

  • To evaluate whether self-repair significantly improves code generation performance in LLMs when accounting for computational cost.
  • To investigate the role of feedback quality in self-repair efficacy, especially for complex coding tasks.
  • To compare self-repair performance against simple i.i.d. sampling under equivalent compute budgets.
  • To assess whether stronger models or human feedback can overcome the limitations of self-repair.

Proposed method

  • The study evaluates CodeLlama-13b-instruct, GPT-3.5, and GPT-4 on HumanEval and APPS benchmarks using a three-stage self-repair pipeline: code generation, test execution, and feedback-driven repair.
  • For feedback generation, the model either produces its own feedback or is given feedback from stronger models (e.g., GPT-4) or human participants.
  • The performance of self-repair is compared against i.i.d. sampling at equivalent compute budgets, measuring pass rates across multiple trials.
  • Ablation studies vary the number of initial samples and repair attempts to assess trade-offs between diversity and repair depth.
  • Human feedback is collected from participants to evaluate its impact on repair success, with results compared to model-generated feedback.
  • Quantitative evaluation uses pass@k metrics and repair success rates across 25 repair attempts per faulty program.
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

Experimental results

Research questions

  • RQ1Does self-repair provide a significant performance boost over i.i.d. sampling when compute cost is factored in?
  • RQ2How does the quality of feedback affect the success rate of self-repair in code generation?
  • RQ3Can replacing model-generated feedback with stronger model feedback or human feedback substantially improve self-repair outcomes?
  • RQ4Under what conditions is self-repair more effective than simple sampling—e.g., when is diversity of initial samples more valuable than extensive repair attempts?
  • RQ5To what extent does the model’s ability to introspect and identify its own errors limit the efficacy of self-repair?

Key findings

  • Self-repair does not consistently outperform i.i.d. sampling when compute cost is considered; in some cases, pass rates are equal or lower than baseline sampling.
  • For GPT-4 on APPS, using 10 initial samples and 10 repair attempts (20 total) yields a 1.05× higher pass rate than pass@20 baseline, but using 2 initial samples and 10 repair attempts (22 total) yields only 0.97× the baseline.
  • Artificially boosting feedback quality by using GPT-4 to generate feedback for CodeLlama or GPT-3.5 results in significantly higher repair success, outperforming both the original self-repair and i.i.d. sampling at all budgets.
  • Replacing GPT-4’s own feedback with human-generated feedback increases the fraction of successfully repaired programs by 1.58×, demonstrating that model introspection is a key bottleneck.
  • The success of self-repair is highly sensitive to feedback quality, and models struggle to identify subtle logical errors in their own code, especially when the error stems from conceptual misunderstandings.
  • In tasks like calculating impact factor or factorial-based formulas, model-generated feedback often misdiagnoses the root cause, leading to failed repairs despite correct reasoning in feedback.
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}\}$ .

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.