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

Learner-Tailored Program Repair: A Solution Generator with Iterative Edit-Driven Retrieval Enhancement

Zhenlong Dai, Zhuoluo Zhao, Hengning Wang, Xiu Tang, Sai Wu, Chang Yao, Zhipeng Gao, Jingyuan Chen

TL;DR

Traditional automated program repair tools focus solely on fixing broken code, often leaving students confused about why their original logic failed. This paper introduces Learner-Tailored Program Repair (LPR) and proposes LSGEN, a framework that generates minimal, personalized code patches alongside point-by-point bug explanations. By leveraging edit-driven retrieval and iterative execution feedback, LSGEN significantly outperforms existing baselines in helping programming learners understand and correct their mistakes.

What Problem Does This Paper Address?

When learning to code, students often turn to automated tools or official solutions when they get stuck. However, official solutions frequently use entirely different algorithms or coding styles than what the student wrote (for example, providing a dynamic programming solution to a student who attempted a greedy approach with binary search). This mismatch makes it incredibly difficult for learners to understand where their own logic went wrong.

Figure 1: Example of LPR. The generated solution contains the repaired code and the corresponding bug description.

While standard Automated Program Repair (APR) tools excel at generating correct patches, they ignore the educational need for explanations. To bridge this gap, the authors define the LPR task. LPR requires a system to not only fix the code while preserving the student's original structure as much as possible but also provide a clear, natural-language description of the underlying bugs.

Methods

The authors introduce LSGEN (Learner-Tailored Solution Generator), a two-stage framework designed to tackle the LPR task:

Figure 2: Overview of LSGEN. (a) Illustration of the Solution Retrieval Database Construction process. (b) Illustration of Edit- driven Solution Retrieval process. (c) Illustration of the Reference-Inspired Solution Generation process. (d) Illustration of the Iterative Retrieval Enhancement process.
  1. Repair Solution Retrieval Framework: Instead of searching for generic correct code, LSGEN constructs a database of historical student submission pairs (buggy code and its subsequent successful fix). It uses Edit-driven Solution Retrieval, which vectorizes the difference (the edit/diff) between the broken and fixed code. This allows the system to find historical pairs that suffered from similar logical missteps, regardless of overall coding style variations.
  2. Solution-Guided Program Repair: The retrieved code pairs are reformatted into diff files, and an LLM generates textual bug descriptions for them. This combined context (diffs + explanations) serves as a reference prompt to guide the final LLM in repairing the student's code and explaining the bug.
  3. Iterative Retrieval Enhancement: If the generated code fails the platform's test cases, LSGEN calculates a "deviation measure" of the failed attempt. It uses this execution feedback as a signal to dynamically adjust the search direction in the vector space, re-retrieving more accurate reference solutions over multiple iterations.

Additionally, because evaluating natural language bug descriptions is notoriously difficult and time-consuming, the authors propose an automated LLM-based evaluation metric that assesses the logical consistency of generated descriptions against a human-annotated ground truth.

Datasets

The paper introduces LPR-Bench, a benchmark specifically curated for evaluating learner-tailored repairs:

  • Source Data: Collected from the test set of ACPR and historical user submissions from CodeNet.
  • Composition: Contains 407 challenging samples from 306 users across 65 programming problems, with an average of 89 test cases per problem.
  • Filtering & Annotation: Overly simple bugs and short code snippets (<10 lines) were filtered out. Ground-truth bug descriptions were initially generated by GPT-4o and then meticulously reviewed, corrected, and refined point-by-point by three programmers with five years of experience.

Key Insights and Ideas

  • Edits Over Semantics: Standard code retrieval looks for semantic similarity between entire programs. LSGEN’s core insight is that vectorizing the code editing process (the delta between broken and fixed states) is far more effective at capturing identical logical bugs across diverse student implementations.
  • Execution Feedback as a Vector Guide: Test-case failures are typically used just as a stopping criterion. LSGEN uniquely transforms execution failures into a directional vector to re-steer the retrieval mechanism, creating a continuous optimization loop.
  • Preserving Student Intent: By providing localized diffs and explanations tailored to the student's chosen algorithm, the framework respects the learner's mental model rather than forcing a complete rewrite.

Key Results

LSGEN was evaluated against mainstream baselines (including PAR, PyDex, and PyFiXV) across multiple backbone models (GPT-4o, Claude-4, and Qwen2.5-Coder-7B).

  • Code Accuracy: On GPT-4o, the full iterative model (LSGEN_iter3) achieved a 91.40% Code Accuracy Rate, outperforming the best non-LSGEN baseline (PAR at 40.54%) by a massive margin.
  • Explanation Quality: For bug descriptions, LSGEN_iter3 achieved a B-F1 score of 38.46% on GPT-4o, compared to baselines which maxed out around 22%.
  • Metric Validity: A human study of 1,390 description pairs confirmed that the proposed automated evaluation metric aligns closely with human judgment, achieving a high Pearson correlation coefficient of $r = 0.848$.

Limitations and Future Work

  • Database Dependency: The framework relies heavily on a large, high-quality historical database of user submissions for the specific programming problems to extract meaningful edit vectors.
  • Complex Multi-Bug Scenarios: While the automated metric correlates well with human evaluators, evaluating natural language explanations for highly complex, multi-layered bugs remains an open challenge.
  • Future Directions: The authors suggest extending this approach to multi-file projects and exploring its deployment in live, interactive classroom environments to study real-world student engagement.

Summary updated

BibTeX
@inproceedings{dai2026learner,
  author = {Zhenlong Dai and Zhuoluo Zhao and Hengning Wang and Xiu Tang and Sai Wu and Chang Yao and Zhipeng Gao and Jingyuan Chen},
  title = {{Learner-Tailored Program Repair: A Solution Generator with Iterative Edit-Driven Retrieval Enhancement}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2026},
  doi = {10.1609/aaai.v40i36.40300},
}
Figure