Table of Contents
Fetching ...

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

This work tackles Learner-Tailored Program Repair (LPR) by introducing LSGen, a retrieval-enhanced framework that not only fixes buggy learner code but also generates explicit bug descriptions. LSGen operates in two stages: Stage I builds a high-quality Repair Solution Retrieval Database and uses edit-driven retrieval to surface relevant repair references; Stage II uses a Reference-Inspired Solution Generation process, augmented with an Iterative Retrieval Enhancement loop that optimizes repair strategies based on evaluation feedback. The authors formalize the task, develop automatic metrics for bug descriptions, and show substantial gains over baselines across multiple models and retrievers on the LPR-Bench benchmark. The approach advances personalized programming coaching by pairing corrective patches with interpretable bug explanations and demonstrates strong practical impact for educational settings. The framework’s reliance on retrieval signals and automated bug-description evaluation indicates strong potential for scalable, learner-aware tutoring systems.

Abstract

With the development of large language models (LLMs) in the field of programming, intelligent programming coaching systems have gained widespread attention. However, most research focuses on repairing the buggy code of programming learners without providing the underlying causes of the bugs. To address this gap, we introduce a novel task, namely \textbf{LPR} (\textbf{L}earner-Tailored \textbf{P}rogram \textbf{R}epair). We then propose a novel and effective framework, \textbf{\textsc{\MethodName{}}} (\textbf{L}earner-Tailored \textbf{S}olution \textbf{G}enerator), to enhance program repair while offering the bug descriptions for the buggy code. In the first stage, we utilize a repair solution retrieval framework to construct a solution retrieval database and then employ an edit-driven code retrieval approach to retrieve valuable solutions, guiding LLMs in identifying and fixing the bugs in buggy code. In the second stage, we propose a solution-guided program repair method, which fixes the code and provides explanations under the guidance of retrieval solutions. Moreover, we propose an Iterative Retrieval Enhancement method that utilizes evaluation results of the generated code to iteratively optimize the retrieval direction and explore more suitable repair strategies, improving performance in practical programming coaching scenarios. The experimental results show that our approach outperforms a set of baselines by a large margin, validating the effectiveness of our framework for the newly proposed LPR task.

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

TL;DR

This work tackles Learner-Tailored Program Repair (LPR) by introducing LSGen, a retrieval-enhanced framework that not only fixes buggy learner code but also generates explicit bug descriptions. LSGen operates in two stages: Stage I builds a high-quality Repair Solution Retrieval Database and uses edit-driven retrieval to surface relevant repair references; Stage II uses a Reference-Inspired Solution Generation process, augmented with an Iterative Retrieval Enhancement loop that optimizes repair strategies based on evaluation feedback. The authors formalize the task, develop automatic metrics for bug descriptions, and show substantial gains over baselines across multiple models and retrievers on the LPR-Bench benchmark. The approach advances personalized programming coaching by pairing corrective patches with interpretable bug explanations and demonstrates strong practical impact for educational settings. The framework’s reliance on retrieval signals and automated bug-description evaluation indicates strong potential for scalable, learner-aware tutoring systems.

Abstract

With the development of large language models (LLMs) in the field of programming, intelligent programming coaching systems have gained widespread attention. However, most research focuses on repairing the buggy code of programming learners without providing the underlying causes of the bugs. To address this gap, we introduce a novel task, namely \textbf{LPR} (\textbf{L}earner-Tailored \textbf{P}rogram \textbf{R}epair). We then propose a novel and effective framework, \textbf{\textsc{\MethodName{}}} (\textbf{L}earner-Tailored \textbf{S}olution \textbf{G}enerator), to enhance program repair while offering the bug descriptions for the buggy code. In the first stage, we utilize a repair solution retrieval framework to construct a solution retrieval database and then employ an edit-driven code retrieval approach to retrieve valuable solutions, guiding LLMs in identifying and fixing the bugs in buggy code. In the second stage, we propose a solution-guided program repair method, which fixes the code and provides explanations under the guidance of retrieval solutions. Moreover, we propose an Iterative Retrieval Enhancement method that utilizes evaluation results of the generated code to iteratively optimize the retrieval direction and explore more suitable repair strategies, improving performance in practical programming coaching scenarios. The experimental results show that our approach outperforms a set of baselines by a large margin, validating the effectiveness of our framework for the newly proposed LPR task.
Paper Structure (42 sections, 16 equations, 12 figures, 5 tables)

This paper contains 42 sections, 16 equations, 12 figures, 5 tables.

Figures (12)

  • Figure 1: Example of LPR. The generated solution contains the repaired code and the corresponding bug description.
  • 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.
  • Figure 3: (a) illustrates the results of different retrieval methods on GPT‑4o and Qwen2.5‑Coder‑7B.(b) shows the effect of varying iteration counts using different retrieval models on GPT‑4o. All results in the table are reported in percentage (%).
  • Figure 4: The prompt of automated annotation.
  • Figure 5: The prompt of NoRef.
  • ...and 7 more figures