Overview
Researchers from Microsoft and Yale have introduced MMAPR, an automated program repair (APR) system designed to assist students in introductory Python courses. MMAPR utilizes Large Language Models (LLMs), specifically OpenAI’s Codex, to address both syntactic and semantic errors in student submissions. By employing iterative querying, intelligent program chunking, and few-shot learning from peer examples, MMAPR achieves a state-of-the-art repair rate of 96.5%, significantly outperforming existing specialized tools while maintaining minimal code changes.
The Challenge of Student Code
Providing personalized feedback in large-scale introductory programming courses is a significant pedagogical hurdle. Student submissions often contain a mix of syntactic errors (e.g., indentation issues, missing colons) and semantic errors (logical flaws that pass compilation but fail test cases).
Traditional APR tools typically struggle with this dual challenge. Symbolic systems often require extensive manual engineering for specific languages, while neural systems demand vast amounts of training data. Furthermore, most existing tools are optimized for one type of error; when faced with a program containing both syntax and logic bugs, they frequently fail to produce a valid repair.
The MMAPR Framework
MMAPR addresses these limitations by treating the repair process as a multi-stage dialogue with an LLM. The system architecture is divided into two primary stages: the Syntax Phase and the Semantic Phase.
Key Methodological Innovations:
- Iterative Querying: The system first resolves all syntax errors. Once the code is syntactically valid, it proceeds to fix logical errors. This mimics a human developer's workflow.
- Program Chunking: To minimize unnecessary changes (spurious edits), MMAPR uses a "chunker" to isolate the specific control-flow block containing a syntax error. Only this relevant snippet is sent to the LLM for repair, ensuring the rest of the student's logic remains intact.
- Multi-modal Prompting: Prompts are enriched with context, including the buggy code, compiler error messages, natural language task descriptions, and test cases.
- Few-shot Peer Selection: When available, the system identifies "peer" programs from other students who failed similar test cases but eventually succeeded. These "buggy-to-fixed" examples are provided as few-shot prompts, helping the LLM understand the specific requirements of the assignment.
Evaluation and Results
The researchers evaluated MMAPR using a dataset of 286 real student programs across 15 different Python tasks. The system was compared against a baseline that combined BIFI (for syntax) and Refactory (for semantics).
The results demonstrate the clear superiority of the LLM-based approach:
- Repair Rate: MMAPR with few-shot learning achieved a 96.5% overall repair rate, compared to just 67.13% for the BIFI + Refactory baseline.
- Minimal Edits: In educational settings, repairs should ideally stay close to the student's original intent. MMAPR achieved a lower Mean Token Edit Distance (TED) of 31.29, indicating more concise and relevant fixes than the baseline's 42.50.
- Ablation Study: Even in a zero-shot setting (without peer examples), MMAPR maintained a high repair rate of 86.71%, showcasing the inherent power of the underlying LLM.
Conclusion
MMAPR demonstrates that LLMs can serve as unified, low-engineering engines for automated program repair in education. By combining general-purpose model capabilities with domain-specific techniques like chunking and peer-based few-shot learning, the system provides highly accurate and pedagogically useful feedback. Future work aims to extend this approach to other programming languages and explore the generation of natural language hints rather than direct code repairs.
Summary updated