arXivDaily arXiv每日学术速递 周一至周五更新
北美退伍军人节(Veterans Day),12 日无更新
arXiv 2007.04973cs.LGcs.AIcs.PLcs.SEstat.ML
收藏

对比代码表示学习

Contrastive Code Representation Learning

UC Berkeley(加州大学伯克利分校)

Paras Jain, Ajay Jain, Tianjun Zhang, Pieter Abbeel, Joseph E. Gonzalez, Ion Stoica

摘要:

最近的工作是通过从上下文中重构令牌来学习源代码的上下文表示。对于下游的语义理解任务,如用英语总结代码,这些表示应该理想地捕捉程序功能。然而,我们表明,流行的重建为基础的BERT模型是敏感的源代码编辑,即使当编辑保留语义。我们提出了ContraCode:一个对比的预训练任务,学习代码功能,而不是形式。ContraCode预训练一个神经网络,以识别许多不等价的干扰项中功能相似的程序变体。我们可伸缩地生成这些变量使用自动源到源编译器作为数据增强的一种形式。对比预训练将JavaScript摘要和TypeScript类型推断准确率提高了2%到13%。我们还提出了一个新的zero-shot JavaScript代码克隆检测数据集,显示ContraCode是更强大和语义上有意义的。在它上面,我们在对抗环境中比Roberta高出39%的AUROC,在自然代码中高出5%。

英文摘要:

Recent work learns contextual representations of source code by reconstructing tokens from their context. For downstream semantic understanding tasks like summarizing code in English, these representations should ideally capture program functionality. However, we show that the popular reconstruction-based BERT model is sensitive to source code edits, even when the edits preserve semantics. We propose ContraCode: a contrastive pre-training task that learns code functionality, not form. ContraCode pre-trains a neural network to identify functionally similar variants of a program among many non-equivalent distractors. We scalably generate these variants using an automated source-to-source compiler as a form of data augmentation. Contrastive pre-training improves JavaScript summarization and TypeScript type inference accuracy by 2% to 13%. We also propose a new zero-shot JavaScript code clone detection dataset, showing that ContraCode is both more robust and semantically meaningful. On it, we outperform RoBERTa by 39% AUROC in an adversarial setting and up to 5% on natural code.

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

↑