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
更新
PDF的下载单位、IP信息已删除 (2025-6-4)

科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
刚刚
CHEN完成签到 ,获得积分10
刚刚
杨桃发布了新的文献求助10
刚刚
1秒前
gone发布了新的文献求助10
1秒前
西瓜大王完成签到,获得积分20
1秒前
一一发布了新的文献求助10
1秒前
long发布了新的文献求助10
1秒前
zhengyuci完成签到,获得积分10
2秒前
2秒前
hjq完成签到,获得积分20
2秒前
Naomi完成签到,获得积分10
2秒前
cheryl发布了新的文献求助10
3秒前
3秒前
柠檬泡芙发布了新的文献求助10
4秒前
4秒前
4秒前
5秒前
范德华气体完成签到,获得积分10
5秒前
5秒前
5秒前
5秒前
小吴发布了新的文献求助20
6秒前
水瓶完成签到,获得积分10
6秒前
无情干饭崽完成签到,获得积分10
6秒前
MrIShelter发布了新的文献求助30
6秒前
bjyx发布了新的文献求助10
7秒前
小小sci发布了新的文献求助10
7秒前
中杯西瓜冰完成签到,获得积分10
8秒前
8秒前
lyl发布了新的文献求助10
9秒前
JIAN完成签到,获得积分10
9秒前
左孤容完成签到,获得积分0
9秒前
9秒前
热心的弼发布了新的文献求助10
9秒前
哒哒哒发布了新的文献求助10
9秒前
科研通AI6应助夏花_秋叶采纳,获得10
10秒前
10秒前
11秒前
小蘑菇应助樊星采纳,获得10
11秒前
高分求助中
Encyclopedia of Quaternary Science Third edition 2025 12000
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
The Social Work Ethics Casebook: Cases and Commentary (revised 2nd ed.). Frederic G. Reamer 800
Beyond the sentence : discourse and sentential form / edited by Jessica R. Wirth 600
Holistic Discourse Analysis 600
Vertébrés continentaux du Crétacé supérieur de Provence (Sud-Est de la France) 600
Vertebrate Palaeontology, 5th Edition 500
热门求助领域 (近24小时)
化学 材料科学 医学 生物 工程类 有机化学 生物化学 物理 纳米技术 计算机科学 内科学 化学工程 复合材料 物理化学 基因 遗传学 催化作用 冶金 量子力学 光电子学
热门帖子
关注 科研通微信公众号,转发送积分 5338438
求助须知:如何正确求助?哪些是违规求助? 4475552
关于积分的说明 13928668
捐赠科研通 4370833
什么是DOI,文献DOI怎么找? 2401451
邀请新用户注册赠送积分活动 1394568
关于科研通互助平台的介绍 1366401