NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

DeepDebug: Fixing Python Bugs Using Stack Traces, Backtranslation, and Code Skeletons

Dawn Drain, Colin Clement, Guillermo Serrato Castilla, Neel SundaresanICLR 2021

Abstract

DeepDebug is a novel automated program repair (APR) framework designed specifically for the Python ecosystem. By leveraging large-scale Transformer models and a multi-stage training pipeline, DeepDebug addresses the critical challenges of bug localization, contextual awareness, and the "oracle problem." Through the integration of synthetic data generation via backtranslation, the use of "code skeletons" for global context, and the incorporation of real-world execution traces, the framework achieves a 50% improvement over existing state-of-the-art methods on the QuixBugs benchmark while significantly reducing false positives.

Introduction

Automated program repair (APR) represents a fundamental goal in software engineering: the creation of systems capable of autonomously identifying and patching software defects. Traditional approaches typically rely on a "generate-and-validate" loop, which faces three primary hurdles. First, localization—pinpointing the exact line of code responsible for a failure—remains notoriously difficult. Second, contextual limitations often force models to analyze functions in isolation, ignoring critical global variables or class structures. Third, the oracle problem leads to "plausible" patches that pass test suites but fail to address the underlying logic, resulting in high false-positive rates.

DeepDebug tackles these issues by providing the model with the same rich information available to human developers: the surrounding codebase and the diagnostic error messages provided by the interpreter.

The DeepDebug Methodology

The authors developed DeepDebug using a sophisticated training pipeline centered on a 406M-parameter sequence-to-sequence Transformer. The process moves beyond simple pattern matching toward a deeper understanding of program execution.

Backtranslation and Synthetic Data

To overcome the scarcity of high-quality bug-fix pairs, the researchers employed "backtranslation." They trained a specialized "bug-creator" model on reversed GitHub commits, effectively teaching the model to turn functional code into buggy code. This approach allowed for the generation of 18 million synthetic bug-fix pairs, providing a massive dataset for the primary repair model to learn from.

Contextual Awareness via Code Skeletons

Rather than feeding the model isolated functions, DeepDebug utilizes "code skeletons." These skeletons include imports, class definitions, and method signatures from the surrounding file. This provides the model with the necessary "big picture" context, reducing the likelihood of the model "hallucinating" non-existent variables or functions. This technique alone reduced the model's cross-entropy loss by 25%.

The multi-stage training pipeline of DeepDebug, illustrating the progression from pretraining on English and Python to specialized 'bug-creator' and 'backtranslation' stages.

Execution-Informed Debugging

For a subset of the training data, the researchers executed the code using pytest to capture stack traces. These traces—containing error messages and local variable values at the time of failure—were fed directly into the Transformer. To manage the resulting increase in input length, the team utilized axial positional embeddings, allowing the model to process large context windows efficiently.

Experimental Evaluation

The framework was evaluated using several datasets:

  • Pretraining: 200,000 public Python repositories.
  • Commit Data: 1.1 million nontrivial edits mined from GitHub.
  • QuixBugs: A standard benchmark of 40 algorithmic bugs used for cross-tool comparison.
  • Executable Benchmark: A new set of 523 neural bugs across 100 repositories where execution traces could be generated.

Key Results and Insights

DeepDebug demonstrated significant performance gains across all metrics. On the QuixBugs benchmark, it fixed 21 out of 40 bugs, a 50% increase over the previous state-of-the-art (13/40). Furthermore, the framework reduced the false positive rate from 35% to just 5%, indicating that the patches generated are much more likely to be semantically correct rather than just "test-passing hacks."

A representative bug fix generated by DeepDebug, where the model correctly identifies that a dictionary 'get' operation should be a 'pop' to maintain the intended state.

One of the most striking findings was the impact of execution data. Incorporating stack traces increased the first-attempt success rate from 68% to 75%. On the executable benchmark, the model achieved a 97% success rate within its top 10 suggestions when provided with traces. Additionally, DeepDebug is remarkably efficient; while prior non-neural tools often required 6-hour timeouts, DeepDebug identifies superior fixes in approximately one minute.

Conclusion and Future Work

DeepDebug represents a significant step forward in APR by treating patching as a debugging task informed by execution context. While the model still occasionally struggles with variable hallucinations and specific types of simple typos, its ability to generate human-like, verbatim fixes is unprecedented. Future work will focus on iterative fixing—where the model observes the results of its own patches to refine its next attempt—and the development of a production-ready command-line tool for developers.

Summary updated

BibTeX
@misc{drain2021deepdebug,
  author = {Dawn Drain and Colin Clement and Guillermo Serrato Castilla and Neel Sundaresan},
  title = {{DeepDebug: Fixing Python Bugs Using Stack Traces, Backtranslation, and Code Skeletons}},
  year = {2021},
  eprint = {2105.09352},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.09352},
}
Figure