[Paper Review] Can we learn from developer mistakes? Learning to localize and repair real bugs from real bug fixes
This paper proposes RealiT, a pre-train-and-fine-tune framework that combines large-scale code mutants with real-world bug fixes to improve neural models for localizing and repairing real bugs in Python. By pre-training on 20x more mutants than prior work and fine-tuning on 33k real bug fixes, RealiT nearly doubles localization performance on real bugs while maintaining or improving repair accuracy.
Real bug fixes found in open source repositories seem to be the perfect source for learning to localize and repair real bugs. However, the absence of large scale bug fix collections has made it difficult to effectively exploit real bug fixes in the training of larger neural models in the past. In contrast, artificial bugs -- produced by mutating existing source code -- can be easily obtained at a sufficient scale and are therefore often preferred in the training of existing approaches. Still, localization and repair models that are trained on artificial bugs usually underperform when faced with real bugs. This raises the question whether bug localization and repair models trained on real bug fixes are more effective in localizing and repairing real bugs. We address this question by introducing RealiT, a pre-train-and-fine-tune approach for effectively learning to localize and repair real bugs from real bug fixes. RealiT is first pre-trained on a large number of artificial bugs produced by traditional mutation operators and then fine-tuned on a smaller set of real bug fixes. Fine-tuning does not require any modifications of the learning algorithm and hence can be easily adopted in various training scenarios for bug localization or repair (even when real training data is scarce). In addition, we found that training on real bug fixes with RealiT is empirically powerful by nearly doubling the localization performance of an existing model on real bugs while maintaining or even improving the repair performance.
Motivation & Objective
- To investigate whether training on real bug fixes improves the performance of neural models for localizing and repairing real software bugs.
- To address the scarcity of real bug fix datasets by proposing a pre-train-and-fine-tune approach that combines synthetic mutants with real fixes.
- To evaluate whether real bug fixes can enhance generalization beyond artificial mutants, especially in real-world scenarios.
- To demonstrate that data quality and quantity of real fixes significantly impact model performance in bug localization and repair.
Proposed method
- RealiT uses a two-stage training pipeline: first pre-training on a large corpus of code mutants generated via traditional mutation operators.
- The model is then fine-tuned on a smaller, high-quality dataset of 33,000 real bug fixes extracted from public Python repositories.
- Fine-tuning does not require architectural changes, enabling easy integration into existing training pipelines for bug localization and repair.
- The approach supports individual evaluation of pre-training on mutants and fine-tuning on real fixes, allowing ablation studies.
- The method is evaluated on the PyPIBugs benchmark, which contains over 2,000 real single-token bugs in Python.
- The model is trained to localize and repair four common single-token bug types: variable misuse, operator misuse, comparison misuse, and function misuse.
Experimental results
Research questions
- RQ1Does training on real bug fixes significantly improve the localization and repair performance of neural models on real-world bugs compared to models trained only on artificial mutants?
- RQ2Can a pre-train-and-fine-tune strategy effectively combine the scale of artificial mutants with the realism of real bug fixes to improve model generalization?
- RQ3How does the quantity of real bug fixes affect the performance of the final model in localizing and repairing real bugs?
- RQ4Is pre-training on mutants necessary for achieving high performance, or can fine-tuning on real fixes alone suffice?
Key findings
- RealiT nearly doubles the number of successfully localized real bugs compared to models trained solely on mutants, achieving a significant improvement in localization performance.
- Fine-tuning on real bug fixes maintains or improves repair performance, even when pre-training is done on a large number of mutants.
- Models pre-trained on a large number of mutants (up to 20x more than prior work) show substantially better performance on both mutants and real bugs, highlighting the importance of training data scale.
- The performance gain from real bug fixes is quantitatively significant: more real fixes lead to better results, with even small subsets improving performance over mutant-only training.
- RealiT is the first model to successfully repair a significant portion of the PyPIBugs benchmark, demonstrating its effectiveness on real-world single-token bugs.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.