Gamma: Revisiting Template-Based Automated Program Repair Via Mask Prediction
Quanjun Zhang, Chunrong Fang, Tongke Zhang, Bowen Yu, Weisong Sun, Zhenyu Chen
Abstract
Automated program repair (APR) aims to fix software bugs without manual debugging efforts and plays a crucial role in software development and maintenance. Template-based APR has been widely investigated and shown promising results. However, it is challenging for template-based APR to select the appropriate donor code, which is an important repair ingredient for generating candidate patches. Inappropriate donor code may cause plausible but incorrect patch generation even with correct fix patterns, limiting the repair performance. In this paper, we aim to revisit template-based APR, and propose Gamma, to directly leverage large pre-trained language models for donor code generation. Our main insight is that instead of retrieving donor code in the local buggy file, we can directly predict the correct code tokens based on the context code snippets and repair patterns by a cloze task. Specifically, (1) Gamma revises a variety of fix templates from state-of-the-art template-based APR techniques (i.e., TBar) and transforms them into mask patterns. (2) Gamma adopts a pre-trained language model to predict the correct code for masked code as a fill-in-the-blank task. Although our idea is general and can be built on various existing pre-trained language models, we have implemented Gamma as a practical APR tool based on the recent UniXcoder model. The experimental results demonstrate that Gamma correctly repairs 82 bugs on Defects4J-v1.2, which achieves 20.59% (14 bugs) and 26.15% (17 bugs) improvement over the previous state-of-the-art template-based approach TBar and learning-based one Recoder. Furthermore, Gamma repairs 45 bugs and 22 bugs from the additional Defects4J-v2.0 and QuixBugs, indicating the generalizability of Gamma in addressing the dataset overfitting issue. We also prove that adopting other pre-trained language models can provide substantial advancement, e.g., CodeBERT-based and ChatGPT-based Gamma is able to fix 80 and 67 bugs on Defects4J-v1.2, indicating the scalability of Gamma. Overall, our study highlights the promising future of adopting pre-trained models to generate correct patches on top of fix patterns in practice.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
12 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- A Large-Scale Empirical Study on Fine-Tuning Large Language Models for Unit Testing cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- One Size Does Not Fit All: Multi-granularity Patch Generation for Better Automated Program Repair cites CoCoNuT: combining context-aware neural translation models using ensemble for program repair
- One Size Does Not Fit All: Multi-granularity Patch Generation for Better Automated Program Repair cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- One Size Does Not Fit All: Multi-granularity Patch Generation for Better Automated Program Repair cites CURE: Code-Aware Neural Machine Translation for Automatic Program Repair
- CURE: Code-Aware Neural Machine Translation for Automatic Program Repair cites CoCoNuT: combining context-aware neural translation models using ensemble for program repair
- Template-Guided Program Repair in the Era of Large Language Models cites CoCoNuT: combining context-aware neural translation models using ensemble for program repair
- Template-Guided Program Repair in the Era of Large Language Models cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Template-Guided Program Repair in the Era of Large Language Models cites CURE: Code-Aware Neural Machine Translation for Automatic Program Repair
- Benchmarking Automated Program Repair: An Extensive Study on Both Real-World and Artificial Bugs cites CoCoNuT: combining context-aware neural translation models using ensemble for program repair
- Benchmarking Automated Program Repair: An Extensive Study on Both Real-World and Artificial Bugs cites CURE: Code-Aware Neural Machine Translation for Automatic Program Repair
- Benchmarking Automated Program Repair: An Extensive Study on Both Real-World and Artificial Bugs cites Automated Program Repair in the Era of Large Pre-trained Language Models
- Seeing is Fixing: Cross-Modal Reasoning with Multimodal LLMs for Visual Software Issue Repair cites CoCoNuT: combining context-aware neural translation models using ensemble for program repair
- Seeing is Fixing: Cross-Modal Reasoning with Multimodal LLMs for Visual Software Issue Repair cites CURE: Code-Aware Neural Machine Translation for Automatic Program Repair
- Seeing is Fixing: Cross-Modal Reasoning with Multimodal LLMs for Visual Software Issue Repair cites Template-Guided Program Repair in the Era of Large Language Models
- Seeing is Fixing: Cross-Modal Reasoning with Multimodal LLMs for Visual Software Issue Repair cites Automated Program Repair in the Era of Large Pre-trained Language Models
- Automated Program Repair in the Era of Large Pre-trained Language Models cites CoCoNuT: combining context-aware neural translation models using ensemble for program repair
- Automated Program Repair in the Era of Large Pre-trained Language Models cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Automated Program Repair in the Era of Large Pre-trained Language Models cites Language Models are Few-Shot Learners
- Automated Program Repair in the Era of Large Pre-trained Language Models cites CURE: Code-Aware Neural Machine Translation for Automatic Program Repair
Cited by top-tier papers12
- One Size Does Not Fit All: Multi-granularity Patch Generation for Better Automated Program RepairBo Lin, Shangwen Wang, Ming Wen, Liqian Chen et al.ISSTA 2024 · 10 citations
- Benchmarking Automated Program Repair: An Extensive Study on Both Real-World and Artificial BugsYicheng Ouyang, Jun Yang, Lingming ZhangISSTA 2024 · 8 citations
- A Large-Scale Empirical Study on Fine-Tuning Large Language Models for Unit TestingYe Shang, Quanjun Zhang, Chunrong Fang, Siqi Gu et al.ISSTA 2025 · 7 citations
- Template-Guided Program Repair in the Era of Large Language ModelsKai Huang, Jian Zhang, Xiangxin Meng, Yang LiuICSE 2025 · 7 citations
- Seeing is Fixing: Cross-Modal Reasoning with Multimodal LLMs for Visual Software Issue RepairKai Huang, Jian Zhang, Xiaofei Xie, Chunyang ChenASE 2025 · 5 citations
Builds on16
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan et al.EMNLP Findings 2020 · 2,828 citations
- CoCoNuT: combining context-aware neural translation models using ensemble for program repairThibaud Lutellier, Hung Viet Pham, Lawrence Pang, Yitong Li et al.ISSTA 2020 · 325 citations
- Automated Program Repair in the Era of Large Pre-trained Language ModelsChunqiu Steven Xia, Yuxiang Wei, Lingming ZhangICSE 2023 · 321 citations
- CURE: Code-Aware Neural Machine Translation for Automatic Program RepairNan Jiang, Thibaud Lutellier, Lin TanICSE 2021 · 267 citations
Related papers
- Aligning the Objective of LLM-Based Program RepairJunjielong Xu, Ying Fu, Shin Hwei Tan, Pinjia HeICSE 2025 · 5 citations
- An Empirical Study on Fine-Tuning Large Language Models of Code for Automated Program RepairKai Huang, Xiangxin Meng, Jian Zhang, Yang Liu et al.ASE 2023 · 91 citations
- The Plastic Surgery Hypothesis in the Era of Large Language ModelsChunqiu Steven Xia, Yifeng Ding, Lingming ZhangASE 2023 · 26 citations
- Automated Repair of Programs from Large Language ModelsZhiyu Fan, Xiang Gao, Martin Mirchev, Abhik Roychoudhury et al.ICSE 2023 · 213 citations
- Automated Program Repair via Conversation: Fixing 162 out of 337 Bugs for $0.42 Each using ChatGPTChunqiu Steven Xia, Lingming ZhangISSTA 2024 · 105 citations
