Learning to Represent Programs with Graphs

By Miltiadis Allamanis, Marc Brockschmidt, Mahmoud Khademi. 2017

919 citations recorded by the source corpus.

Learning tasks on source code (i.e., formal languages) have been considered recently, but most work has tried to transfer natural language methods and does not capitalize on the unique opportunities offered by code's known syntax. For example, long-range dependencies induced by using the same variable or function in distant locations are often not considered. We propose to use graphs to represent both the syntactic and semantic structure of code and use graph-based deep learning methods to learn to reason over program structures. In this work, we present how to construct graphs from source code and how to scale Gated Graph Neural Networks training to such large graphs. We evaluate our method on two tasks: VarNaming, in which a network attempts to predict the name of a variable given its usage, and VarMisuse, in which the network learns to reason about selecting the correct variable that should be used at a given program location. Our comparison to methods that use less structured program representations shows the advantages of modeling known structure, and suggests that our models learn to infer meaningful names and to solve the VarMisuse task in many cases. Additionally, our testing showed that VarMisuse identifies a number of bugs in mature open-source projects.

Subfields: Artificial Intelligence, Computer Networks and Communications, Information Systems, Graph Learning

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Artificial Intelligence

  1. Yoshua Bengio
  2. Percy Liang
  3. Mohit Bansal
  4. Quoc V. Le
  5. Jianfeng Gao
  6. Graham Neubig
  7. Luke S. Zettlemoyer
  8. Sergey Levine

In Computer Networks and Communications

  1. Uri Alon
  2. Eran Yahav
  3. Percy Liang
  4. Michihiro Yasunaga
  5. Shaked Brody
  6. Earl T. Barr
  7. Michael Pradel
  8. Miltiadis Allamanis

In Information Systems

  1. Miltiadis Allamanis
  2. Charles Sutton
  3. Prem Devanbu
  4. Michael Pradel
  5. Uri Alon
  6. Eran Yahav
  7. Rishabh Singh
  8. Koushik Sen

In Graph Learning

  1. William L. Hamilton
  2. Jure Leskovec
  3. Stephan Günnemann
  4. Matthias Fey
  5. Marinka Zitnik
  6. Eran Yahav
  7. Uri Alon
  8. Miltiadis Allamanis

Citations in the corpus