arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2205.02029cs.PLcs.AIcs.CL
收藏

CODE-MVP:通过对比预训练学习从多个视图表示Source Code

CODE-MVP: Learning to Represent Source Code from Multiple Views with Contrastive Pre-Training

Wuhan University(武汉大学);Huawei Noah’s Ark Lab(华为诺亚方舟实验室);Huazhong University of Science and Technology(华中科技大学);Monash University(莫纳什大学);Yunnan University(云南大学)

Xin Wang, Yasheng Wang, Yao Wan, Jiawei Wang, Pingyi Zhou, Li Li, Hao Wu, Jin Liu

摘要:

近年来,代码表示学习引起了越来越多的关注,其目的是将源代码的语义表示成分布式向量。目前,已经提出了各种工作来从不同的角度表示源代码的复杂语义,包括纯文本、抽象树(AST)和几种代码图(例如,控制/数据流图)。然而,大多数方法只考虑源代码的单个视图,而忽略了不同视图之间的对应关系。在本文中,我们提出了集成不同的视图与自然语言描述的源代码到一个统一的框架与多视图对比预训练,我们的模型命名为CODE-MVP。具体来说,我们首先使用编译器工具提取多个代码视图,并在对比学习框架下学习它们之间的互补信息。受编译中类型检查的启发,我们还在预训练中设计了一个细粒度的类型推断目标。在五个数据集上的三个下游任务上的实验证明了CODE-MVP与几个最先进的基线相比的优越性。例如,我们在自然语言代码检索、代码相似性和代码缺陷检测任务的MRR/MAP/Accuracy指标方面分别实现了2.4/2.3/1.1的增益。

英文摘要:

Recent years have witnessed increasing interest in code representation learning, which aims to represent the semantics of source code into distributed vectors. Currently, various works have been proposed to represent the complex semantics of source code from different views, including plain text, Abstract Syntax Tree (AST), and several kinds of code graphs (e.g., Control/Data Flow Graph). However, most of them only consider a single view of source code independently, ignoring the correspondences among different views. In this paper, we propose to integrate different views with the natural-language description of source code into a unified framework with Multi-View contrastive Pre-training, and name our model as CODE-MVP. Specifically, we first extract multiple code views using compiler tools, and learn the complementary information among them under a contrastive learning framework. Inspired by the type checking in compilation, we also design a fine-grained type inference objective in the pre-training. Experiments on three downstream tasks over five datasets demonstrate the superiority of CODE-MVP when compared with several state-of-the-art baselines. For example, we achieve 2.4/2.3/1.1 gain in terms of MRR/MAP/Accuracy metrics on natural language code retrieval, code similarity, and code defect detection tasks, respectively.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑