arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2210.09597cs.CLcs.PLcs.SE
收藏

功能级代码表示的软标签对比预训练

Soft-Labeled Contrastive Pre-training for Function-level Code Representation

Fudan University(复旦大学);Microsoft(微软);National University of Singapore(新加坡国立大学)

Xiaonan Li, Daya Guo, Yeyun Gong, Yun Lin, Yelong Shen, Xipeng Qiu, Daxin Jiang, Weizhu Chen, Nan Duan

摘要:

代码对比预培训最近在代码相关任务上取得了重大进展。在本文中,我们提出了\textbf{SCodeR},一个\textbf{S}经常标记的对比预训练框架与两个积极的样本构造方法学习功能级\textbf{Code} \textbf{R}的表现。考虑到大规模代码语料库中代码之间的相关性,软标签对比预训练可以通过迭代对抗的方式获得细粒度的软标签,并使用它们来学习更好的代码表示。正样本的构建是对比预训练的另一个关键。以前的作品使用基于转换的方法,如变量重命名,以生成语义相等的正代码。然而,它们通常导致生成的代码具有高度相似的表面形式,从而误导模型关注表面代码结构而不是代码语义。为了鼓励SCodeR从代码中捕获语义信息,我们利用代码注释和代码的抽象语法子树来构建阳性样本。我们在七个数据集上对四个与代码相关的任务进行了实验。大量的实验结果表明,SCodeR实现了新的国家的最先进的性能,这说明了所提出的预训练方法的有效性。

英文摘要:

Code contrastive pre-training has recently achieved significant progress on code-related tasks. In this paper, we present \textbf{SCodeR}, a \textbf{S}oft-labeled contrastive pre-training framework with two positive sample construction methods to learn functional-level \textbf{Code} \textbf{R}epresentation. Considering the relevance between codes in a large-scale code corpus, the soft-labeled contrastive pre-training can obtain fine-grained soft-labels through an iterative adversarial manner and use them to learn better code representation. The positive sample construction is another key for contrastive pre-training. Previous works use transformation-based methods like variable renaming to generate semantically equal positive codes. However, they usually result in the generated code with a highly similar surface form, and thus mislead the model to focus on superficial code structure instead of code semantics. To encourage SCodeR to capture semantic information from the code, we utilize code comments and abstract syntax sub-trees of the code to build positive samples. We conduct experiments on four code-related tasks over seven datasets. Extensive experimental results show that SCodeR achieves new state-of-the-art performance on all of them, which illustrates the effectiveness of the proposed pre-training method.

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

↑