Skip to main content
QUICK REVIEW

[Paper Review] Less Training, More Repairing Please: Revisiting Automated Program Repair via Zero-shot Learning

Chunqiu Steven Xia, Lingming Zhang|arXiv (Cornell University)|Jul 17, 2022
Software Engineering ResearchComputer Science10 citations
TL;DR

This paper proposes AlphaRepair, a zero-shot, cloze-style automated program repair technique that leverages large pre-trained code models like CodeBERT without any fine-tuning on bug-fix datasets. By directly predicting correct code lines from contextual code snippets, AlphaRepair achieves state-of-the-art results on Defects4J and QuixBugs, fixing 3.3× more bugs than the best baseline on Defects4J 2.0 and demonstrating strong multilingual repair capability for both Java and Python.

ABSTRACT

Due to the promising future of Automated Program Repair (APR), researchers have proposed various APR techniques, including heuristic-based, template-based, and constraint-based techniques. Among such classic APR techniques, template-based techniques have been widely recognized as state of the art. However, such template-based techniques require predefined templates to perform repair, and their effectiveness is thus limited. To this end, researchers leveraged the recent advances in Deep Learning to further improve APR. Such learning-based techniques view APR as a Neural Machine Translation problem, using the buggy/fixed code snippets as the source/target languages for translation. In this way, such techniques heavily rely on large numbers of high-quality bug-fixing commits, which can be extremely costly and challenging to construct. Furthermore, the edit variety of these learning-based techniques are limited to the available bug-fixes within their training datasets. Therefore, in this paper, we aim to revisit the learning-based APR problem, and propose AlphaRepair, to leverage zero-shot learning directly using large pre-trained code models for APR. Our main insight is instead of modeling what a repair edit should look like, we can directly predict what the correct code is based on the context information. We have implemented AlphaRepair as a practical multilingual APR tool based on the recent CodeBERT model. Our results on the widely used Defects4J benchmark show that AlphaRepair can substantially outperform state-of-the-art APR tools. We also studied the impact of different design choices and show that AlphaRepair performs even better on a newer version of Defects4J (2.0) with 3.3X more fixes than best performing baseline, indicating that AlphaRepair can potentially avoid the dataset-overfitting issue of existing learning-based techniques.

Motivation & Objective

  • To address the limitations of existing learning-based APR techniques that require large, high-quality bug-fix datasets for fine-tuning.
  • To explore whether pre-trained code models can be directly leveraged for program repair in a zero-shot setting without any task-specific training.
  • To evaluate the effectiveness and generalization of such an approach on standard benchmarks like Defects4J and QuixBugs.
  • To investigate whether the approach can support multilingual program repair without retraining or separate models per language.

Proposed method

  • AlphaRepair frames program repair as a cloze task, where the model predicts the correct code line based on the surrounding context, rather than modeling repair as a sequence-to-sequence translation task.
  • It leverages the pre-training objective of CodeBERT—masked language modeling—by masking the buggy line and prompting the model to predict the correct fix.
  • The input is constructed by replacing the buggy line with a [MASK] token while preserving the surrounding code context, enabling direct inference using the pre-trained model.
  • The model is not fine-tuned on any historical bug-fix pairs; instead, it directly uses the frozen weights of CodeBERT for inference on repair tasks.
  • The approach is implemented as a multilingual APR tool, exploiting CodeBERT’s joint pre-training on six programming languages (Java, Python, Go, PHP, JavaScript, Ruby).
  • Correctness of generated patches is validated via compilation and test suite execution, with manual inspection used to confirm semantic correctness.

Experimental results

Research questions

  • RQ1Can a pre-trained code model be directly used for automated program repair without any fine-tuning on bug-fix datasets?
  • RQ2Does a cloze-style repair approach outperform traditional sequence-to-sequence NMT-based learning-based APR techniques?
  • RQ3Can the zero-shot approach generalize across different programming languages, enabling multilingual repair without retraining?
  • RQ4Does the approach avoid dataset overfitting, especially when evaluated on newer, larger benchmarks like Defects4J 2.0?

Key findings

  • AlphaRepair achieved the highest number of correct patches on Defects4J 1.2 (28) and Defects4J 2.0 (27), outperforming all baselines.
  • On Defects4J 2.0, AlphaRepair fixed 3.3× more bugs than the best-performing baseline, demonstrating strong generalization and reduced overfitting.
  • AlphaRepair achieved state-of-the-art results on both Java and Python versions of QuixBugs, confirming its multilingual repair capability.
  • Even when excluding 15 overlapping bugs from CodeBERT’s training data, AlphaRepair still outperformed baselines, indicating robustness beyond data leakage.
  • Manual perturbation of overlapping buggy code snippets confirmed that AlphaRepair generalizes beyond memorized fixes, not relying on exact dataset matches.
  • The zero-shot approach using cloze-style prediction via masked code modeling significantly outperforms NMT-based learning-based APR, which requires extensive fine-tuning on historical fixes.

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.