Generating Bug-Fixes Using Pretrained Transformers

Dawn Drain, Chen Wu, Alexey Svyatkovskiy, Neel Sundaresan · DOI

Abstract

Automated Program Repair (APR) has traditionally struggled with producing "constructive" fixes, often resorting to trivial code deletions to pass test suites. This paper introduces DeepDebug, a system that frames bug-patching as a sequence-to-sequence learning task using pretrained Transformers. By employing a three-stage pipeline—natural language pretraining, domain-adaptive pretraining on Java, and supervised finetuning—DeepDebug achieves a 75% improvement in non-deletion fixes over prior state-of-the-art. A significant finding is that large-scale models benefit more from raw, concrete code than from abstracted representations, as they can leverage the semantic intent captured in variable and method names.

Introduction

The manual effort required for debugging remains a primary bottleneck in software engineering. While static analysis tools excel at identifying potential bugs, the task of generating correct, human-like patches is complex. Early APR systems frequently generated "test-suite adequate" patches that, while passing tests, often broke program logic by simply removing buggy lines. DeepDebug addresses this by treating code repair as a translation problem, aiming to generate precise, constructive patches that preserve and correct program logic.

Methods

DeepDebug utilizes a Transformer-based architecture, specifically a model with up to 400 million parameters. The training process follows a three-stage pipeline:

  1. Natural Language Pretraining: Initializing with a model pretrained on English (BART) to capture general linguistic patterns.
  2. Domain-Adaptive Pretraining: Further training on a massive corpus of 1.3 billion lines of Java code using a span-masking objective.
  3. Supervised Finetuning: Final training on the "Patches in the Wild" dataset, consisting of real-world buggy vs. fixed method pairs.

A key technical departure from prior work is the use of raw, concrete code. While previous researchers often abstracted code by replacing variable names with generic placeholders to simplify the task, DeepDebug demonstrates that high-capacity models perform better when they can access the original developer-chosen names.

Comparison of raw (concrete) code and various levels of abstraction used in bug-fixing tasks.

Results and Key Insights

DeepDebug achieved state-of-the-art performance, generating 75% more non-deletion fixes than previous leading models. On the "Patches in the Wild" benchmark, the best model achieved an overall top-1 accuracy of 14.9%, rising to 18.7% for small methods.

The Value of Concrete Code

One of the most striking findings is that "English is a prerequisite for code." Because modern code is often self-documenting, method names like getMinElement carry semantic meaning that helps the model understand intent better than a generic placeholder would. Empirical results show that concrete code representations consistently outperform abstracted ones for these large Transformers.

Performance comparison between models trained on concrete code versus abstracted code with idioms.

Avoiding the Deletion Trap

The researchers emphasize "non-deletion fixes" as the true benchmark for helpful AI assistants. A model that simply deletes a buggy line might pass a test but destroys functionality. DeepDebug's ability to infer logic—such as changing an increment to a decrement based on a method name like backward()—marks a significant step toward human-like repair.

Limitations and Future Work

Despite its success, DeepDebug faces challenges. The model currently evaluates buggy methods in isolation, lacking context from the broader class or external libraries. Additionally, without formal specifications or test cases, some bugs remain ambiguous. Future research will focus on expanding context windows and supporting multiple programming languages.

Summary updated

BibTeX
@inproceedings{drain2021generating,
  author = {Dawn Drain and Chen Wu and Alexey Svyatkovskiy and Neel Sundaresan},
  title = {{Generating Bug-Fixes Using Pretrained Transformers}},
  booktitle = {MAPS@PLDI},
  year = {2021},
  doi = {10.1145/3460945.3464951},
}
Figure