GraphCodeBERT: Pre-training Code Representations with Data Flow

By Daya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng, Duyu Tang, Shujie Liu, Shujie Liu, Long Zhou, Nan Duan, Jian Yin and 9 more. 2020

1,778 citations recorded by the source corpus.

Pre-trained models for programming language have achieved dramatic empirical improvements on a variety of code-related tasks such as code search, code completion, code summarization, etc. However, existing pre-trained models regard a code snippet as a sequence of tokens, while ignoring the inherent structure of code, which provides crucial code semantics and would enhance the code understanding process. We present GraphCodeBERT, a pre-trained model for programming language that considers the inherent structure of code. Instead of taking syntactic-level structure of code like abstract syntax tree (AST), we use data flow in the pre-training stage, which is a semantic-level structure of code that encodes the relation of "where-the-value-comes-from" between variables. Such a semantic-level structure is neat and does not bring an unnecessarily deep hierarchy of AST, the property of which makes the model more efficient. We develop GraphCodeBERT based on Transformer. In addition to using the task of masked language modeling, we introduce two structure-aware pre-training tasks. One is to predict code structure edges, and the other is to align representations between source code and code structure. We implement the model in an efficient way with a graph-guided masked attention function to incorporate the code structure. We evaluate our model on four tasks, including code search, clone detection, code translation, and code refinement. Results show that code structure and newly introduced pre-training tasks can improve GraphCodeBERT and achieves state-of-the-art performance on the four downstream tasks. We further show that the model prefers structure-level attentions over token-level attentions in the task of code search.

Subfields: Artificial Intelligence, Information Systems, Software, Natural Language Processing, 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. Jianfeng Gao
  2. Mohit Bansal
  3. Yoshua Bengio
  4. Graham Neubig
  5. Luke S. Zettlemoyer
  6. Percy Liang
  7. Furu Wei
  8. Caiming Xiong

In Information Systems

  1. Chun Xia
  2. Lingming Zhang
  3. Yanqiao Zhu
  4. Yichen Xu
  5. Prem Devanbu
  6. Daya Guo
  7. Nan Duan
  8. Baptiste Rozière

In Software

  1. Yanqiao Zhu
  2. Yichen Xu
  3. Neel Sundaresan
  4. Daya Guo
  5. Nan Duan
  6. Alexey Svyatkovskiy
  7. Chun Xia
  8. Lingming Zhang

In Natural Language Processing

  1. Prem Devanbu
  2. Baptiste Rozière
  3. Lingming Zhang
  4. Chun Xia
  5. Nan Duan
  6. Yanqiao Zhu
  7. Yichen Xu
  8. Toufique Ahmed

In Graph Learning

  1. Petros Maniatis
  2. Wenhan Xiong
  3. Prem Devanbu
  4. Ge Li
  5. Daniel Tarlow
  6. Steven C. H. Hoi
  7. Nicolas Usunier
  8. Vincent J. Hellendoorn

Citations in the corpus