Contrastive Code Representation Learning

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

179 citations recorded by the source corpus.

Recent work learns contextual representations of source code by reconstructing tokens from their context. For downstream semantic understanding tasks like code clone detection, these representations should ideally capture program functionality. However, we show that the popular reconstruction-based RoBERTa 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 outperforms RoBERTa on an adversarial code clone detection benchmark by 39% AUROC. Surprisingly, improved adversarial robustness translates to better accuracy over natural code; ContraCode improves summarization and TypeScript type inference accuracy by 2 to 13 percentage points over competitive baselines. All source is available at https://github.com/parasj/contracode.

Subfields: Information Systems, Software, Representation & Self-Supervised Learning, Signal Processing

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Information Systems

  1. Yanqiao Zhu
  2. Yichen Xu
  3. Marc Szafraniec
  4. Baptiste Rozière
  5. Guillaume Lample
  6. Marie-Anne Lachaux
  7. Harrison Edwards
  8. Scott Gray

In Software

  1. Yanqiao Zhu
  2. Yichen Xu
  3. Baptiste Rozière
  4. Marie-Anne Lachaux
  5. Ilya Sutskever
  6. Guillaume Lample
  7. Marc Szafraniec
  8. Lukasz Kaiser

In Representation & Self-Supervised Learning

  1. Alex Nichol
  2. Guillaume Lample
  3. Alec Radford
  4. Marie-Anne Lachaux
  5. Lei Lyu
  6. Harrison Edwards
  7. Girish Sastry
  8. Zhuoran Zheng

In Signal Processing

  1. Heewoo Jun
  2. Ilya Sutskever
  3. Wojciech Zaremba
  4. Mark Chen
  5. Pamela Mishkin
  6. Marie-Anne Lachaux
  7. Harrison Edwards
  8. Scott Gray

Citations in the corpus