Skip to main content
QUICK REVIEW

[Paper Review] Repairing Bugs in Python Assignments Using Large Language Models

Jialu Zhang, José Cambronero|arXiv (Cornell University)|Sep 29, 2022
Software Engineering ResearchComputer Science30 citations
TL;DR

MMAPR uses a large language model trained on code to repair both syntactic and semantic bugs in Python student assignments, outperforming a state-of-the-art syntax+semantic baseline, especially with few-shot learning.

ABSTRACT

Students often make mistakes on their introductory programming assignments as part of their learning process. Unfortunately, providing custom repairs for these mistakes can require a substantial amount of time and effort from class instructors. Automated program repair (APR) techniques can be used to synthesize such fixes. Prior work has explored the use of symbolic and neural techniques for APR in the education domain. Both types of approaches require either substantial engineering efforts or large amounts of data and training. We propose to use a large language model trained on code, such as Codex, to build an APR system -- MMAPR -- for introductory Python programming assignments. Our system can fix both syntactic and semantic mistakes by combining multi-modal prompts, iterative querying, test-case-based selection of few-shots, and program chunking. We evaluate MMAPR on 286 real student programs and compare to a baseline built by combining a state-of-the-art Python syntax repair engine, BIFI, and state-of-the-art Python semantic repair engine for student assignments, Refactory. We find that MMAPR can fix more programs and produce smaller patches on average.

Motivation & Objective

  • Motivate scalable automated feedback in programming education by reducing instructor and TA workload.
  • Develop a unified system that can repair both syntactic and semantic errors in introductory Python assignments.
  • Leverage large language models trained on code with multimodal prompts and weak supervision to improve repair quality.
  • Evaluate MMAPR against a strong baseline and analyze design choices such as program chunking and few-shot learning.

Proposed method

  • Use a multimodal LLMC (Codex) as core repair engine for both syntax and semantics.
  • Apply a syntax phase with a program chunker to isolate actionable chunks for prompting.
  • Generate and validate multiple syntax prompts; accept patches passing the syntax oracle.
  • Apply a semantic phase using natural language task description and test cases to guide repairs; optionally use peers’ solutions as few-shot examples via test-suite similarity.
  • Incorporate few-shot learning by retrieving similar past pairs of buggy/correct programs based on test-suite vectors.
  • Prefer repairs with minimal token edit distance to the original buggy program when multiple valid candidates exist.

Experimental results

Research questions

  • RQ1Can MMAPR repair a higher fraction of buggy Python submissions than a state-of-the-art baseline that combines syntax and semantic repair tools?
  • RQ2What is the impact of MMAPR design decisions (program chunking, iterative querying, few-shot learning, multimodal prompts) on repair rate and patch size?
  • RQ3Does using an LLMC trained on code enable unified handling of syntax and semantic errors in student assignments?
  • RQ4How close are MMAPR repairs to the original student submissions compared to instructor reference solutions?

Key findings

  • MMAPR repairs 86.71% of programs without few-shot learning, outperforming the baseline’s 67.13%.
  • With few-shot learning, MMAPR repairs rise to 96.50%.
  • MMAPR patches have smaller average token edit distance to the buggy program (31.29–31.40) than the baseline (42.50).
  • Iterative syntax querying increases repair rate from 82.87% to 86.71%.
  • Removing the program chunker increases average token edit distance from 5.46 to 9.38, showing chunking stabilizes minimal changes.
  • Combining multiple multi-modal prompts yields best performance; few-shot examples from peers further boost repair rates.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.