TL;DR
Evaluating Large Language Models (LLMs) on older software engineering benchmarks risks data leakage, as the models may have memorized the solutions during pre-training. To address this, researchers created EvalGPTFix, a clean benchmark of 2023 competitive programming problems, to rigorously evaluate ChatGPT's automated program repair (APR) capabilities. The study reveals that while ChatGPT achieves outstanding repair accuracy and beats domain-specific models, its success heavily depends on prompt engineering, multi-round querying, and a surprising limitation: it struggles to fix its own generated code.
What Problem Does This Paper Address?
Automated Program Repair (APR) aims to fix software bugs automatically without human intervention. Recently, black-box LLMs like ChatGPT have shown incredible promise in this domain. However, standard APR benchmarks (like Defects4J or QuixBugs) consist of open-source code repositories that were likely crawled and included in the training data of these models.
As shown in Figure 1, ChatGPT explicitly acknowledges its familiarity with these benchmarks.
This creates a severe data leakage problem. It is impossible to tell whether ChatGPT is genuinely reasoning through a bug or simply retrieving a memorized patch from its training corpus. This paper addresses this evaluation bias by introducing a "clean" evaluation framework to measure the true generalization capabilities of LLMs in software engineering.
Methods
The authors evaluated ChatGPT (gpt-3.5-turbo) using several distinct experimental setups:
- Multi-Round Querying: Because LLMs are stochastic, a single query doesn't reflect their full capability. The authors repeatedly queried ChatGPT with the same bug until no new bugs were fixed for three consecutive rounds.
- Prompt Engineering: They tested how different contextual information impacts repair performance by designing three advanced prompt types:
- Problem Description: Adding the natural language description of the coding problem.
- Error Feedback: Providing specific compiler, runtime, or wrong-answer test output.
- Bug Localization: Explicitly marking the suspicious lines of code with a
//bugcomment. - Interactive Dialogue: Simulating a developer-in-the-loop workflow, they provided up to 5 rounds of conversational feedback to help ChatGPT iteratively refine its patches.
- Self-Repair Evaluation: They tasked ChatGPT with generating code for problems, identifying the bugs in its own code, and attempting to fix them over 30 conversational rounds.
Datasets
The authors introduced EvalGPTFix, a brand-new benchmark consisting of 151 pairs of buggy and fixed Java programs across 15 distinct problems. The data was crawled from AtCoder competitive programming contests held in 2023—well after ChatGPT’s September 2021 knowledge cutoff date.
To ensure high quality, the dataset was filtered based on the competent programmer hypothesis (keeping only submissions with a difference of less than 6 tokens from the correct solution) and validated against expert-crafted test suites averaging 38 test cases per problem to prevent overfitting.
Key Insights and Ideas
- The Randomness Trap: Evaluating an LLM only a handful of times yields an incomplete picture. Due to ChatGPT's stochastic nature, it took 35 independent rounds of querying to discover all 109 bugs it was capable of fixing with a basic prompt.
- Prompt Diversity Unlocks Unique Fixes: Providing different types of context (errors vs. problem descriptions) didn't just help fix more bugs; it helped fix different bugs. The overlap between what each advanced prompt solved was surprisingly small, meaning prompt engineering strategies are complementary rather than redundant.
- The Self-Repair Paradox: ChatGPT is excellent at fixing human-written code but remarkably poor at fixing its own generated code. When humans write buggy code, the logic is usually 95% correct, requiring minimal edits. When ChatGPT fails a coding task, its underlying logic is often fundamentally broken, requiring structural rewrites that it cannot easily diagnose or execute.
Key Results
- Baseline Comparison: With a basic prompt, ChatGPT successfully fixed 109 out of 151 bugs (72.19% accuracy), significantly outperforming domain-specific models CodeT5 (79 bugs) and PLBART (41 bugs).
- Impact of Query Rounds: The number of total fixed bugs steadily climbed across 35 rounds, showing a sharp drop-off in newly fixed bugs after the first three rounds.
- Prompt Engineering Gains: Applying advanced prompts to the remaining 42 unfixed bugs recovered an additional 34 fixes (Error feedback fixed 25, Problem descriptions fixed 18, and Bug localization fixed 10).
- Dialogue & Total Performance: Multi-round dialogue fixed 9 more difficult bugs. Across all strategies, ChatGPT resolved 143 out of 151 bugs (94.7%).
- Self-Repair Failure: Out of 13 buggy programs generated by ChatGPT itself, it managed to fix only 2 despite 30 rounds of detailed dialogue feedback.
Limitations and Future Work
The primary limitation is that EvalGPTFix relies on competitive programming problems. While these feature complex logic and rigorous test suites, they consist of small, single-file algorithms that do not fully mirror the architectural complexity, multi-file dependencies, or technical debt found in real-world enterprise software. Furthermore, because ChatGPT is a closed-source, black-box model, the exact mechanics behind its successes and failures remain speculative.
Future work includes integrating LLMs directly into IDEs to study how they assist developers in real-time, exploring more advanced prompt engineering frameworks, and investigating hybrid approaches that combine general-purpose LLMs with domain-specific code models.
Summary updated