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.


翻译:最近的工作通过从上下文中重建符号来学习源代码的背景描述。 对于下游语义理解任务, 比如用英语总结代码, 这些表达应该最理想地捕捉程序功能 。 然而, 我们显示流行的基于重建的 BERT 模型对源代码编辑十分敏感, 即使编辑保存语义 。 我们提议 ContraCode: 对比式的训练前任务, 学习代码功能, 而不是形式 。 ContraCode 之前的线性网络可以识别许多非等值分散器中程序功能相似的变体。 我们使用自动源到源的编译器生成这些变体, 作为一种数据增强形式。 对比性培训前模型将 JavaScript 的拼写和类型Script 类型推导精度提高2%到13% 。 我们还提出一个新的零弹射 JavaScript 代码克隆探测数据集, 显示 ContraCode 既更强大, 也具有语义意义。 在它上, 我们将 RoBERTA 39% 以 AM AM ABUROC 。

2
下载
关闭预览

相关内容

【MIT】反偏差对比学习,Debiased Contrastive Learning
专知会员服务
90+阅读 · 2020年7月4日
零样本文本分类,Zero-Shot Learning for Text Classification
专知会员服务
95+阅读 · 2020年5月31日
【google】监督对比学习,Supervised Contrastive Learning
专知会员服务
30+阅读 · 2020年4月23日
Stabilizing Transformers for Reinforcement Learning
专知会员服务
57+阅读 · 2019年10月17日
Transferring Knowledge across Learning Processes
CreateAMind
25+阅读 · 2019年5月18日
强化学习的Unsupervised Meta-Learning
CreateAMind
17+阅读 · 2019年1月7日
无监督元学习表示学习
CreateAMind
25+阅读 · 2019年1月4日
Unsupervised Learning via Meta-Learning
CreateAMind
41+阅读 · 2019年1月3日
meta learning 17年:MAML SNAIL
CreateAMind
11+阅读 · 2019年1月2日
Facebook PyText 在 Github 上开源了
AINLP
7+阅读 · 2018年12月14日
Disentangled的假设的探讨
CreateAMind
9+阅读 · 2018年12月10日
disentangled-representation-papers
CreateAMind
26+阅读 · 2018年9月12日
Hierarchical Imitation - Reinforcement Learning
CreateAMind
19+阅读 · 2018年5月25日
Hierarchical Disentangled Representations
CreateAMind
4+阅读 · 2018年4月15日
Continual Unsupervised Representation Learning
Arxiv
7+阅读 · 2019年10月31日
Contrastive Representation Distillation
Arxiv
5+阅读 · 2019年10月23日
VIP会员
相关资讯
Transferring Knowledge across Learning Processes
CreateAMind
25+阅读 · 2019年5月18日
强化学习的Unsupervised Meta-Learning
CreateAMind
17+阅读 · 2019年1月7日
无监督元学习表示学习
CreateAMind
25+阅读 · 2019年1月4日
Unsupervised Learning via Meta-Learning
CreateAMind
41+阅读 · 2019年1月3日
meta learning 17年:MAML SNAIL
CreateAMind
11+阅读 · 2019年1月2日
Facebook PyText 在 Github 上开源了
AINLP
7+阅读 · 2018年12月14日
Disentangled的假设的探讨
CreateAMind
9+阅读 · 2018年12月10日
disentangled-representation-papers
CreateAMind
26+阅读 · 2018年9月12日
Hierarchical Imitation - Reinforcement Learning
CreateAMind
19+阅读 · 2018年5月25日
Hierarchical Disentangled Representations
CreateAMind
4+阅读 · 2018年4月15日
Top
微信扫码咨询专知VIP会员