PLUR: A Unifying, Graph-Based View of Program Learning, Understanding, and Repair

Zimin Chen, Vincent Josua Hellendoorn, Pascal Lamblin, Petros Maniatis, Pierre-Antoine Manzagol, Daniel Tarlow, Subhodeep MoitraNeurIPS 2021

In the world of Natural Language Processing (NLP), the "text-to-text" abstraction (popularized by models like T5) revolutionized the field. By treating every task—from translation to summarization—as a string-to-string problem, researchers could stop building custom architectures for every niche and focus on scaling a single, powerful model.

But source code isn't just text. It’s a complex web of syntax trees, data flows, and control loops. Until recently, the field of Machine Learning for Source Code (ML4Code) was a fragmented landscape of custom models: one for bug detection, another for variable naming, and a third for program repair.

A team from Google Research and several universities recently published PLUR (Program Learning, Understanding, and Repair), a framework that aims to be the "T5 for code."

TL;DR

PLUR introduces a unifying "graph-to-sequence-with-pointers" abstraction that can handle 16 different programming tasks—ranging from bug fixing to code summarization—using a single model architecture. By treating code as a graph and the output as a "script" of tokens and pointers, PLUR matches or beats state-of-the-art custom models while enabling powerful multi-task learning.

What Problem Does This Paper Address?

The ML4Code community has suffered from "architectural sprawl." Because code is inherently structural, researchers often felt compelled to design bespoke models (like code2seq or Hoppity) to handle specific representations like Abstract Syntax Trees (ASTs).

Furthermore, code has unique challenges:

  1. Structure: It is machine-readable and follows strict logic (graphs).
  2. The "Rare Token" Problem: Code is full of unique variable names that a model might never see in training.
  3. Localization: Many tasks require "pointing" to a specific line or node to fix a bug, rather than just generating new text.

PLUR addresses this by asking: Is there a single, standardized abstraction that can represent almost any code-related task?

Methods

The core of PLUR is the GRAPH2TOCOPO formulation. It maps an input Graph to a sequence of TOkens, COpies, and POinters.

The Graph2ToCoPo abstraction mapping an input graph to a sequence of tokens, copies, and pointers.
  • The Encoder: Instead of a standard Transformer, PLUR uses GREAT (Graph-Relational Embedding Attention Transformer). This model treats code as a graph where nodes (tokens or AST elements) are connected by edges (data flow, syntax, etc.). It uses "relational attention" to let the model learn from these specific connections.
  • The Decoder: The decoder is an autoregressive Transformer augmented with two critical features:
  • Pointers: The model can output a pointer to a specific node in the input graph (essential for bug localization).
  • Copy Mechanism: The model can "copy" a literal string from the input to the output, solving the rare token problem.
  • The "Script" Output: Every task is converted into a sequence. For example, a repair task might output: REPLACE [Pointer to Node 5] WITH [Token: "x"] DONE.

Datasets

The authors didn't just test on one dataset; they integrated 16 tasks from 9 different papers into the PLUR format:

  • Bug Detection/Repair: ManySStuBs4J, VarMisuseH, Hoppity, and several CuBERT tasks.
  • Naming & Summarization: code2seq (small, med, large), funcom, convattn, and ogb-code.
  • Code Completion: Retrieve & Edit.
  • Classification: Various CuBERT classification tasks (e.g., identifying the wrong binary operator).

Key Insights and Ideas

  • Generality is a Feature, Not a Bug: The most surprising finding is that a general-purpose model (PLUR) often outperforms models specifically designed for a single task. For instance, PLUR significantly outperformed Hoppity on program repair, despite Hoppity having a much more complex, task-specific decoding process.
  • Pointers are Non-Negotiable: Ablation studies showed that for repair and localization tasks, the ability to "point" is far more effective than trying to represent locations with special tokens.
  • Multi-Task Synergy: Because all tasks share the same input/output format, the authors could train one model on multiple tasks simultaneously. This was particularly helpful for small datasets; a model trained on several tasks learned better "code intuition" than one trained on a single small dataset.
  • The Power of GREAT: While vanilla Transformers are strong, the relational attention in the GREAT encoder consistently provided an edge by explicitly leveraging the graph structure of the code.

Key Results

PLUR establishes a new standard by achieving near or above state-of-the-art results on nearly all evaluated tasks.

Performance of PLUR compared to original state-of-the-art models across 16 tasks.
  • Program Repair: On the Hoppity task, PLUR achieved 26.6% sequence accuracy, nearly doubling the original paper's 14.2%.
  • Variable Misuse: On VarMisuseH, PLUR reached 82.8% accuracy, surpassing the previous SOTA of 80.4%.
  • Variable Naming: On the code2seq large dataset, PLUR achieved an F1 score of 62.1, beating the original custom model's 59.2.
  • Multi-Tasking: In the CuBERT-VM task, multi-task training boosted performance from 75.0% (single task) to 89.6%.

Limitations and Future Work

  • Supervised Only: This version of PLUR relies on supervised learning. The authors note that incorporating large-scale self-supervised pre-training (like BERT or GPT for code) is a logical next step.
  • Retrieval: PLUR struggled with the "Retrieve & Edit" task. The framework isn't currently designed to search through a massive external database of code snippets to find examples to copy from.
  • Computational Cost: Training these graph-based Transformers is expensive, requiring significant GPU/TPU time (the authors spent ~14,000 accelerator hours on their experiments).

By providing a "common vernacular" for ML4Code, PLUR allows the community to stop reinventing the wheel and start building more powerful, general-purpose AI for software engineering.

Summary updated

BibTeX
@inproceedings{chen2021plur,
  author = {Zimin Chen and Vincent Josua Hellendoorn and Pascal Lamblin and Petros Maniatis and Pierre-Antoine Manzagol and Daniel Tarlow and Subhodeep Moitra},
  title = {{PLUR: A Unifying, Graph-Based View of Program Learning, Understanding, and Repair}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=GEm4o9A6Jfb},
}
Figure