We gratefully acknowledge support from
the Simons Foundation and member institutions.
Full-text links:

Download:

Current browse context:

cs.SE

Change to browse by:

References & Citations

DBLP - CS Bibliography

Bookmark

(what is this?)
CiteULike logo BibSonomy logo Mendeley logo del.icio.us logo Digg logo Reddit logo

Computer Science > Software Engineering

Title: GraphCodeBERT: Pre-training Code Representations with Data Flow

Abstract: 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.
Subjects: Software Engineering (cs.SE); Computation and Language (cs.CL)
Cite as: arXiv:2009.08366 [cs.SE]
  (or arXiv:2009.08366v1 [cs.SE] for this version)

Submission history

From: Daya Guo [view email]
[v1] Thu, 17 Sep 2020 15:25:56 GMT (1000kb,D)
[v2] Tue, 29 Sep 2020 02:37:30 GMT (902kb,D)
[v3] Wed, 24 Feb 2021 14:12:39 GMT (1680kb,D)
[v4] Mon, 13 Sep 2021 05:48:51 GMT (1683kb,D)

Link back to: arXiv, form interface, contact.