Introduction
Automatic Program Repair (APR) is a critical area of software engineering that aims to automatically generate patches for software bugs. While deep learning has significantly advanced this field, current models suffer from two primary limitations: "Language Silos" and "Catastrophic Forgetting." Most existing models are specialized for a single language, requiring separate training and maintenance for each. Furthermore, when these models are fine-tuned on new languages or bug types, they often lose the ability to fix bugs in previously learned languages—a phenomenon known as catastrophic forgetting.
This paper introduces CIRCLE (ContInual Repair aCross Programming LanguagEs), a novel framework based on the T5 (Text-to-Text Transfer Transformer) architecture. CIRCLE is designed to learn bug-fixing logic across multiple programming languages sequentially, capturing universal "latent knowledge" while maintaining performance on earlier tasks.
Methodology
CIRCLE integrates four key innovations to facilitate cross-lingual learning and memory retention:
1. Prompt-based Representation
To leverage the pre-trained knowledge of the T5 model, CIRCLE frames program repair as a "fill-in-the-blank" task. By using natural language prompts such as "Buggy line:", "Context:", and "The fixed code is:", the model bridges the gap between its natural language pre-training and the structured domain of source code. This approach significantly accelerates convergence during training.
2. Difficulty-based Rehearsal
To combat forgetting, CIRCLE utilizes a rehearsal strategy where it maintains a small buffer of data from previous tasks. Unlike random sampling, CIRCLE selects the "most difficult" examples—those with the highest loss values. These challenging cases are more informative for the model, allowing it to maintain a high level of performance with a minimal storage footprint.
3. Sampling-based Elastic Weight Consolidation (EWC)
CIRCLE employs EWC as a regularization technique. It identifies the specific neural network parameters (weights) that are most important for previously learned tasks. When the model learns a new language, EWC penalizes changes to these critical weights, effectively "protecting" the model's existing memories while allowing it to adapt to new data.
4. Cross-Language Re-repairing
Cross-lingual models occasionally suffer from "hallucinations," such as using Python-specific keywords in a Java patch. CIRCLE includes a post-processing step involving regex-based mapping to correct these format mismatches and ensure the generated patches are syntactically correct for the target language.
Experimental Evaluation
The authors evaluated CIRCLE across four major programming languages (C, Java, JavaScript, and Python) using several industry-standard benchmarks, including Defects4J, QuixBugs, BugAID, and ManyBugs. The training data was derived from a subset of the CoCoNut dataset, totaling approximately 0.4 million bug-fix pairs.
Key Findings
- State-of-the-Art Performance: CIRCLE successfully fixed 64 bugs in the Defects4J benchmark, matching or exceeding the performance of specialized, language-specific models like Recoder and CURE.
- Cross-Lingual Synergy: The research revealed that learning a new language can actually enhance performance on previously learned ones. For instance, the logic required to fix a loop in Python often transfers effectively to Java, suggesting a shared underlying logic for bug repair across languages.
- Efficiency: CIRCLE achieved its results using only 4.13% of the training data required by some of its competitors, highlighting the efficiency of the continual learning approach.
- Stability in Task Streaming: In sequential learning scenarios (e.g., JS → Python → Java → C), CIRCLE maintained stable performance across all languages, whereas standard fine-tuning models saw dramatic performance drops in earlier languages as new ones were introduced.
Conclusion and Future Work
CIRCLE demonstrates that a single, unified model can effectively manage program repair across multiple languages without succumbing to catastrophic forgetting. By combining prompt-based learning with intelligent rehearsal and regularization, CIRCLE provides a scalable and efficient path forward for APR.
Future research directions include automating the keyword mapping for the re-repairing mechanism to support a broader range of languages and addressing the context window limitations of the transformer architecture to handle bugs that require larger code contexts.
Summary updated