Code Prediction by Feeding Trees to Transformers

By Seohyun Kim, Jinman Zhao, Yuchi Tian, Satish Chandra. 2020

241 citations recorded by the source corpus.

Code prediction, more specifically autocomplete, has become an essential feature in modern IDEs. Autocomplete is more effective when the desired next token is at (or close to) the top of the list of potential completions offered by the IDE at cursor position. This is where the strength of the underlying machine learning system that produces a ranked order of potential completions comes into play. We advance the state-of-the-art in the accuracy of code prediction (next token prediction) used in autocomplete systems. Our work uses Transformers as the base neural architecture. We show that by making the Transformer architecture aware of the syntactic structure of code, we increase the margin by which a Transformer-based system outperforms previous systems. With this, it outperforms the accuracy of several state-of-the-art next token prediction systems by margins ranging from 14% to 18%. We present in the paper several ways of communicating the code structure to the Transformer, which is fundamentally built for processing sequence data. We provide a comprehensive experimental evaluation of our proposal, along with alternative design choices, on a standard Python dataset, as well as on Facebook internal Python corpus. Our code and data preparation pipeline will be available in open source.

Subfields: Artificial Intelligence, Information Systems, Software, Natural Language Processing, Code Generation & Program Synthesis

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. Mohit Bansal
  2. Luke S. Zettlemoyer
  3. Nan Duan
  4. Jianfeng Gao
  5. Graham Neubig
  6. Percy Liang
  7. Quoc V. Le
  8. Miltiadis Allamanis

In Information Systems

  1. Miltiadis Allamanis
  2. Nan Duan
  3. Daya Guo
  4. Baptiste Rozière
  5. Charles Sutton
  6. Ge Li
  7. Jian Yin
  8. Prem Devanbu

In Software

  1. Nan Duan
  2. Daya Guo
  3. Alexey Svyatkovskiy
  4. Georgios Gousios
  5. Jian Yin
  6. Neel Sundaresan
  7. Maliheh Izadi
  8. Roberta Gismondi

In Natural Language Processing

  1. Nan Duan
  2. Baptiste Rozière
  3. Graham Neubig
  4. Guillaume Lample
  5. Charles Sutton
  6. Mohit Bansal
  7. Miltiadis Allamanis
  8. Ge Li

In Code Generation & Program Synthesis

  1. Charles Sutton
  2. Ge Li
  3. Miltiadis Allamanis
  4. Baptiste Rozière
  5. Marc Szafraniec
  6. Marc Brockschmidt
  7. Zhi Jin
  8. Guillaume Lample

Citations in the corpus