NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

INTERVENOR: Prompting the Coding Ability of Large Language Models with the Interactive Chain of Repair

Hanbin Wang, Zhenghao Liu, Shuo Wang, Ganqu Cui, Ning Ding, Zhiyuan Liu, Ge Yu

TL;DR

This paper introduces INTERVENOR, a novel system that enhances Large Language Models' (LLMs) code repair capabilities by simulating human-like interactive debugging. By employing a "Code Learner" and "Code Teacher" duo that leverages compiler feedback, INTERVENOR significantly improves code generation and translation accuracy, outperforming existing methods.

What Problem Does This Paper Address?

Large Language Models (LLMs) have shown impressive abilities in code generation, but they often struggle to produce entirely correct code, especially for complex tasks. While techniques like Chain-of-Thought (CoT) and self-correction have been explored, directly generating flawless code remains a significant challenge. Existing self-repair methods can also fall prey to the "Degeneration-of-Thought" (DoT) problem, where the LLM gets stuck in a loop of incorrect reasoning. This paper addresses the need for a more robust and interactive approach to code repair that can effectively diagnose and fix bugs, mimicking how human developers debug.

Methods

INTERVENOR introduces a two-agent system: a Code Learner and a Code Teacher.

  • Code Learner: This agent is responsible for generating or repairing code based on instructions. It's prompted to act as a student assistant with excellent code repair capabilities.
  • Code Teacher: This agent acts as an experienced programming instructor. It analyzes the buggy code and error messages from a compiler, then crafts a "Chain-of-Repair" (CoR). The CoR is a natural language explanation of the bug's cause and a step-by-step plan for fixing it.

The core innovation is the Interactive Chain-of-Repair (CoR) mechanism. Instead of relying solely on the LLM's internal reasoning (which can lead to DoT), INTERVENOR uses compiler feedback to guide the Code Teacher. The Code Teacher then translates this feedback into actionable, human-readable instructions for the Code Learner. This iterative process continues until the code passes all tests or a maximum number of repair turns is reached. This approach aims to alleviate the DoT problem by providing external, structured guidance.

Datasets

The paper evaluates INTERVENOR on several standard code generation and translation benchmarks:

  • HumanEval: A benchmark for evaluating functional correctness of synthesized Python programs.
  • MBPP (Mostly Basic Python Problems): Another benchmark for Python programming problems.
  • HumanEval-X: Used to assess multi-programming language generation and translation capabilities (covering C++, Java, JavaScript, and Go).
  • DS-1000: A benchmark for evaluating LLMs in data science code generation.

Additionally, the authors introduce a new benchmark called CodeError. This dataset is designed specifically to evaluate code repair capabilities and contains 4,463 examples with various error types (syntax, assertion, etc.) collected from basic programming problems, data analysis problems, and programming competition problems.

Key Insights and Ideas

  • Human-like Debugging: The core idea of emulating human interactive debugging, with distinct roles for diagnosis (Teacher) and repair (Learner), proves highly effective.
  • Compiler Feedback as a "Debugger's Assistant": Leveraging compiler error messages is crucial. INTERVENOR doesn't just feed these messages to the LLM; it uses them to inform a structured "Chain-of-Repair," guiding the LLM more effectively than direct error message usage.
  • Alleviating Degeneration-of-Thought (DoT): The CoR mechanism, informed by external compiler feedback, acts as a crucial safeguard against LLMs getting stuck in repetitive, incorrect reasoning loops.
  • The Power of Iteration: The multi-turn repair process, guided by the CoR, significantly boosts performance, especially for more complex bugs.

Key Results

  • Significant Performance Gains: INTERVENOR achieved approximately 18% improvement in code generation and 4.3% improvement in code translation over GPT-3.5.
  • Outperforms Baselines: The system surpasses other state-of-the-art models, including Self-Debug and Self-Collaboration, on various benchmarks.
  • Effective Code Repair: INTERVENOR demonstrated a twofold increase in the number of successfully repaired codes on the new CodeError dataset.
  • CoR's Value: The Chain-of-Repair mechanism was shown to be more effective than other prompting techniques like Self-Refine or simply using error messages directly.
  • Multi-Turn Advantage: The iterative nature of INTERVENOR, especially after three turns of repair, showed substantial performance gains, highlighting its effectiveness in tackling complex issues.

Limitations and Future Work

  • Foundation Model Dependency: INTERVENOR's performance is inherently tied to the capabilities of the underlying LLM. Using less proficient LLMs might limit its effectiveness.
  • Logical Errors and Test Cases: For purely logical errors, the system relies heavily on test cases for feedback. The quality and coverage of these test cases are critical; inadequate tests can hinder effective repair.
  • Future Work: The authors suggest exploring the use of less proficient LLMs and further investigating the impact of test case design on the system's performance. The potential for LLMs to evolve through interaction with environments or rule systems is also highlighted.

Summary updated

BibTeX
@inproceedings{wang2024intervenor,
  author = {Hanbin Wang and Zhenghao Liu and Shuo Wang and Ganqu Cui and Ning Ding and Zhiyuan Liu and Ge Yu},
  title = {{INTERVENOR: Prompting the Coding Ability of Large Language Models with the Interactive Chain of Repair}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.124},
}
Figure