Skip to main content
QUICK REVIEW

[Paper Review] A Controlled Experiment of Different Code Representations for Learning-Based Bug Repair

Marjane Namavar, Noor Nashid|arXiv (Cornell University)|Oct 26, 2021
Software Engineering ResearchComputer Science4 citations
TL;DR

This paper presents a controlled experiment evaluating 21 different code representations and embeddings for deep learning-based program repair, focusing on name-based bugs. It finds that while higher-level abstractions improve model accuracy, they reduce perceived usefulness of fixes for developers, and mixed (heterogeneous) representations outperform homogeneous ones, highlighting the need to consider developer usability in repair tool design.

ABSTRACT

Training a deep learning model on source code has gained significant traction recently. Since such models reason about vectors of numbers, source code needs to be converted to a code representation before vectorization. Numerous approaches have been proposed to represent source code, from sequences of tokens to abstract syntax trees. However, there is no systematic study to understand the effect of code representation on learning performance. Through a controlled experiment, we examine the impact of various code representations on model accuracy and usefulness in deep learning-based program repair. We train 21 different generative models that suggest fixes for name-based bugs, including 14 different homogeneous code representations, four mixed representations for the buggy and fixed code, and three different embeddings. We assess if fix suggestions produced by the model in various code representations are automatically patchable, meaning they can be transformed to a valid code that is ready to be applied to the buggy code to fix it. We also conduct a developer study to qualitatively evaluate the usefulness of inferred fixes in different code representations. Our results highlight the importance of code representation and its impact on learning and usefulness. Our findings indicate that (1) while code abstractions help the learning process, they can adversely impact the usefulness of inferred fixes from a developer's point of view; this emphasizes the need to look at the patches generated from the practitioner's perspective, which is often neglected in the literature, (2) mixed representations can outperform homogeneous code representations, (3) bug type can affect the effectiveness of different code representations; although current techniques use a single code representation for all bug types, there is no single best code representation applicable to all bug types.

Motivation & Objective

  • To systematically evaluate the impact of diverse code representations and embeddings on learning-based program repair accuracy and fix usefulness.
  • To investigate whether higher-level abstractions improve model performance at the cost of reduced developer usability.
  • To explore the effectiveness of mixed representations—using different representations for buggy and fixed code—compared to homogeneous representations.
  • To assess the perceived usefulness of generated fixes through a developer study, addressing a gap in existing literature that often neglects practitioner perspectives.
  • To provide a reusable benchmark framework, Reptory, for future comparative studies on code representations in deep learning-based repair.

Proposed method

  • The study trains 21 distinct generative models using 14 homogeneous code representations, four mixed representations (for buggy and fixed code), and three embedding methods.
  • Code representations include token sequences, AST traversals, and abstract syntax tree (AST) path-based encodings, with both raw and abstracted forms.
  • The models are trained on a real-world dataset of name-based bugs (e.g., swapped arguments, wrong operators), with over 120k data points per bug type.
  • Model performance is evaluated via automatic patchability—whether generated fixes can be automatically transformed into valid, compilable code.
  • A qualitative developer study is conducted to assess the perceived usefulness of generated fixes across different representations.
  • A framework called Reptory is developed to support reproducible, comparative experiments on code representations in program repair.

Experimental results

Research questions

  • RQ1How do different code representations affect the accuracy and patchability of generated fixes in learning-based program repair?
  • RQ2To what extent does using heterogeneous code representations (different representations for buggy and fixed code) improve repair performance compared to homogeneous representations?
  • RQ3How does the level of abstraction in code representations influence the perceived usefulness of fixes from a developer’s perspective?
  • RQ4Does the choice of embedding method significantly impact the quality of generated fixes across different bug types?
  • RQ5Are there bug-type-specific optimal code representations, or is there a universally best representation?

Key findings

  • The highest model accuracy achieved was 99.996% for fixing wrong binary operands, 99.977% for wrong binary operators, and 99.964% for swapped arguments, all using the EID(Opnd)-20, EID(Oprt)-20, and EID(SA)-20 representations, respectively.
  • Higher-level abstractions improved model accuracy but reduced the perceived usefulness of fixes in developer evaluations, indicating a trade-off between performance and practical utility.
  • Mixed representations—where different representations are used for buggy and fixed code—consistently outperformed homogeneous representations, suggesting improved modeling of repair transformations.
  • The study found no single best code representation applicable to all bug types, as effectiveness varied significantly by bug category.
  • Lossy or abstract representations, while less accurate in patch generation, still provided useful debugging hints to developers, indicating value beyond automatic patchability.
  • The Reptory framework enables reproducible comparative experiments and is released as a benchmark for future research on code representations in program repair.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.