Litcius/Paper detail

Contrastive Code Representation Learning

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

2021Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing11 citationsDOIOpen Access PDF

Abstract

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 Con-traCode: a contrastive pre-training task that learns code functionality, not form. Con-traCode 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 pretraining 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.

Topics & Concepts

Computer scienceSource codeAutomatic summarizationNatural language processingJavaScriptArtificial intelligenceProgramming languageTypeScriptContext (archaeology)Code (set theory)CompilerInferenceTask (project management)BiologyEconomicsPaleontologySet (abstract data type)ManagementSoftware Engineering ResearchAdvanced Malware Detection TechniquesSoftware Testing and Debugging Techniques
Contrastive Code Representation Learning | Litcius