TL;DR
ENCORE is a novel automated program repair (APR) framework that uses an ensemble of convolutional neural machine translation (NMT) models to fix software bugs. By moving away from brittle, hard-coded rules and standard sequential models like LSTMs, ENCORE successfully fixed 67 bugs across four different programming languages, including 16 bugs that had never been fixed by previous state-of-the-art tools.
What Problem Does This Paper Address?
Fixing software bugs automatically is a "holy grail" of software engineering. Most current approaches fall into the Generate-and-Validate (G&V) category: they generate many potential code patches and run them against a test suite to see if any work.
However, traditional G&V tools rely on human-written templates or hard-coded rules. This makes them "brittle"—they can only fix bugs that fit a specific, pre-defined pattern—and difficult to port to new programming languages. Recent attempts to use Deep Learning (specifically LSTMs) have struggled because code is complex; LSTMs often fail to capture the long-distance relationships between tokens in a line of code and struggle with the massive vocabularies found in large software projects.
Methods
The authors introduce ENCORE, which shifts the paradigm in three key ways:
- Convolutional NMT (fconv): Instead of using Recurrent Neural Networks (like LSTMs), ENCORE uses a convolutional architecture. CNNs are excellent at capturing local context (nearby tokens), while a multi-step attention mechanism allows the model to keep track of long-term dependencies across the buggy statement.
- Ensemble Learning: Recognizing that no single model can fix every type of bug, the researchers trained multiple models with different hyperparameters (like learning rates and layer dimensions). By combining these models into an ensemble, ENCORE can leverage diverse "repair strategies." Interestingly, they use the likelihood scores of the generated patches to rank them, rather than simple majority voting, allowing a model that is highly "confident" about a specific niche fix to prevail.
- Smart Tokenization: To handle the "large vocabulary" problem, ENCORE uses a custom tokenizer that splits code by underscores and camelCase (marking splits with a special
<CAMEL>tag). It also abstracts strings and infrequent numbers. This reduced the vocabulary from over 500,000 tokens in previous work to a manageable 64,044, while keeping the "out-of-vocabulary" rate below 2%.
As shown in the overview above, the process moves from a training stage on open-source commits to an inference stage where a buggy line is fed into the ensemble, followed by a validation stage that compiles and tests the candidate patches.
Datasets
The authors trained and evaluated ENCORE across a massive breadth of data:
- Training: They extracted over 1.1 million pairs of buggy and fixed lines from 1,000 GitHub projects for each of the four target languages (Java, Python, C++, and JavaScript).
- Evaluation: They used industry-standard benchmarks: Defects4J and QuixBugs for Java, the Python version of QuixBugs, a C++ dataset of 69 real-world defects, and a set of 12 common JavaScript bug patterns.
Key Insights and Ideas
- Diversity is a Strength: The "randomness" in hyperparameter tuning, usually seen as a hurdle, was turned into a feature. Different models naturally "overfit" to different types of bug fixes. The ensemble captures this collective intelligence, fixing 47% more bugs than any single model could alone.
- Local Context Matters: The success of the convolutional approach suggests that for many bugs, the immediate surrounding tokens (captured by the convolution kernel) provide the most critical information for a fix.
- Language Agnosticism: Because ENCORE learns fix patterns directly from data rather than human-defined rules, it is highly portable. The authors demonstrated this by applying it to four different languages with minimal manual effort.
Key Results
ENCORE significantly outperformed previous NMT-based repair tools:
- Java Performance: It fixed 42 Java bugs in total. Notably, 16 of these were "unique fixes"—bugs that no other existing APR tool had successfully repaired.
- Top-1 Accuracy: In 33 cases, the very first patch ENCORE suggested was the correct one.
- Cross-Language Success: Beyond Java, it fixed 17 bugs in Python, 5 in C++, and 3 in JavaScript.
- Complexity: ENCORE was found to perform more complex repairs than its predecessors, averaging 1.8 repair actions per bug compared to 1.2 for the previous state-of-the-art (SequenceR).
Limitations and Future Work
While powerful, ENCORE has clear boundaries:
- Single-Line Focus: The current model is designed to fix bugs that occur within a single statement. Multi-line bugs remain a challenge for future iterations.
- Contextual Blindness: To keep sequences short and models scalable, ENCORE currently ignores the broader context (the rest of the function or file) outside the buggy line. While this worked well for many bugs, the authors acknowledge that incorporating relevant context without bloating the input is a key area for improvement.
- Fault Localization: The study assumes "perfect localization"—meaning it knows exactly which line is buggy. In a real-world scenario, it would need to be paired with a separate tool to find the bug first.
Summary updated