GraphCodeBERT: Pre-training Code Representations with Data Flow

计算机科学 代码段 冗余代码 程序设计语言 抽象语法树 系统代码 无法访问的代码 代码生成 编码(集合论) 树形结构 自动汇总 源代码 无效代码 人工智能 理论计算机科学 数据结构 算法 解析 编码速率 解码方法 计算机安全 集合(抽象数据类型) 钥匙(锁)
作者
Daya Guo,Shuo Ren,Shuai Lu,Zhangyin Feng,Duyu Tang,Shujie Liu,Long Zhou,Nan Duan,A. Svyatkovskiy,Sheng‐Yu Fu,Michele Tufano,Shao Kun Deng,Colin B. Clement,Dawn Drain,Neel Sundaresan,Jian Yin,Daxin Jiang,Ming Zhou
摘要

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.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
zypazyp发布了新的文献求助10
刚刚
hanjresearch发布了新的文献求助10
刚刚
科研通AI6.2应助傲娇若南采纳,获得10
刚刚
1秒前
1秒前
轩一发布了新的文献求助10
1秒前
1秒前
JZAUA完成签到,获得积分10
2秒前
安静寒风完成签到 ,获得积分10
2秒前
lieomey发布了新的文献求助10
2秒前
3秒前
3秒前
酷波er应助RNNNLL采纳,获得10
3秒前
科研通AI6.1应助xx采纳,获得10
3秒前
4秒前
今后应助gm采纳,获得10
4秒前
4秒前
4秒前
4秒前
风车完成签到,获得积分10
4秒前
4秒前
5秒前
5秒前
5秒前
5秒前
5秒前
CC发布了新的文献求助10
5秒前
5秒前
佟鹭其发布了新的文献求助10
5秒前
ChenXinde发布了新的文献求助10
5秒前
Liuping完成签到,获得积分10
5秒前
5秒前
大头头发布了新的文献求助10
5秒前
5秒前
5秒前
MiyaGuo完成签到,获得积分10
6秒前
6秒前
June完成签到 ,获得积分10
6秒前
6秒前
6秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
晶种分解过程与铝酸钠溶液混合强度关系的探讨 8888
Chemistry and Physics of Carbon Volume 18 800
The Organometallic Chemistry of the Transition Metals 800
Leading Academic-Practice Partnerships in Nursing and Healthcare: A Paradigm for Change 800
The formation of Australian attitudes towards China, 1918-1941 640
Signals, Systems, and Signal Processing 610
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 工程类 有机化学 化学工程 生物化学 计算机科学 物理 内科学 复合材料 催化作用 物理化学 光电子学 电极 细胞生物学 基因 无机化学
热门帖子
关注 科研通微信公众号,转发送积分 6429243
求助须知:如何正确求助?哪些是违规求助? 8245534
关于积分的说明 17533162
捐赠科研通 5485055
什么是DOI,文献DOI怎么找? 2895496
邀请新用户注册赠送积分活动 1871925
关于科研通互助平台的介绍 1711209