VarCLR: Variable Semantic Representation Pre-training via Contrastive Learning
Not on the map. Why?
Abstract (arXiv)
Variable names are critical for conveying intended program behavior. Machine learning-based program analysis methods use variable name representations for a wide range of tasks, such as suggesting new variable names and bug detection. Ideally, such methods could capture semantic relationships between names beyond syntactic similarity, e.g., the fact that the names average and mean are similar. Unfortunately, previous work has found that even the best of previous representation approaches primarily capture relatedness (whether two variables are linked at all), rather than similarity (whether they actually have the same meaning). We propose VarCLR, a new approach for learning semantic representations of variable names that effectively captures variable similarity in this stricter sense. We observe that this problem is an excellent fit for contrastive learning, which aims to minimize the distance between explicitly similar inputs, while maximizing the distance between dissimilar inputs. This requires labeled training data, and thus we construct a novel, weakly-supervised variable renaming dataset mined from GitHub edits. We show that VarCLR enables the effective application of sophisticated, general-purpose language models like BERT, to variable name representation and thus also to related downstream tasks like variable name similarity search or spelling correction. VarCLR produces models that significantly outperform the state-of-the-art on IdBench, an existing benchmark that explicitly captures variable similarity (as distinct from relatedness). Finally, we contribute a release of all data, code, and pre-trained models, aiming to provide a drop-in replacement for variable representations used in either existing or future program analyses that rely on variable names.
Key facts. Cited by 11 papers in the map (data through 7 Oct 2026). Builds on 52 of its 87 references that are in the map. First posted on arXiv 5 Dec 2021.
Builds on
52 of 87 references.
References · 52
- 2017Attention Is All You Needcited by 59,932
- 2015Deep Residual Learning for Image Recognitioncited by 51,809
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2014Adam: A Method for Stochastic Optimizationcited by 36,960
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,266
- 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 11,979
- 2016Semi-Supervised Classification with Graph Convolutional Networkscited by 11,282
- 2015Distilling the Knowledge in a Neural Networkcited by 10,076
- 2018Representation Learning with Contrastive Predictive Codingcited by 7,662
- 2019Momentum Contrast for Unsupervised Visual Representation Learningcited by 7,482
38 more
- 2019BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehensioncited by 5,874
- 2020Bootstrap your own latent: A new approach to self-supervised Learningcited by 4,712
- 2020Dense Passage Retrieval for Open-Domain Question Answeringcited by 3,779
- 2013Distributed Representations of Words and Phrases and their Compositionalitycited by 3,462
- 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,898
- 2020Exploring Simple Siamese Representation Learningcited by 2,853
- 2020Unsupervised Learning of Visual Features by Contrasting Cluster Assignmentscited by 2,845
- 2020Supervised Contrastive Learningcited by 2,803
- 2017Billion-scale similarity search with GPUscited by 2,477
- 2021SimCSE: Simple Contrastive Learning of Sentence Embeddingscited by 2,168
- 2018Unsupervised Feature Learning via Non-Parametric Instance-level Discriminationcited by 1,838
- 2021Align before Fuse: Vision and Language Representation Learning with Momentum Distillationcited by 1,612
- 2016Enriching Word Vectors with Subword Informationcited by 1,578
- 2019Contrastive Multiview Codingcited by 1,297
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2020What Makes for Good Views for Contrastive Learning?cited by 843
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2019Latent Retrieval for Weakly Supervised Open Domain Question Answeringcited by 691
- 2017Mean teachers are better role models: Weight-averaged consistency targets improve semi-supervised deep learning resultscited by 470
- 2020Towards a Human-like Open-Domain Chatbotcited by 467
- 2020GCC: Graph Contrastive Coding for Graph Neural Network Pre-Trainingcited by 461
- 2014SimLex-999: Evaluating Semantic Models with (Genuine) Similarity Estimationcited by 170
- 2020Self-training Improves Pre-training for Natural Language Understandingcited by 96
- 2020Spelling Error Correction with Soft-Masked BERTcited by 90
- 2020Contrastive Code Representation Learningcited by 76
- 2018DeepBugs: A Learning Approach to Name-based Bug Detectioncited by 65
- 2019A spelling correction model for end-to-end speech recognitioncited by 63
- 2015Towards Universal Paraphrastic Sentence Embeddingscited by 59
- 2019DIRE: A Neural Approach to Decompiled Identifier Namingcited by 36
- 2018Automated software vulnerability detection with machine learningcited by 34
- 2018Learning to Represent Editscited by 34
- 2020NeuSpell: A Neural Spelling Correction Toolkitcited by 31
- 2014Learning Natural Coding Conventionscited by 28
- 2017Sorting and Transforming Program Repair Ingredients via Deep Learning Code Similaritiescited by 26
- 2019GitHub Typo Corpus: A Large-Scale Multilingual Dataset of Misspellings and Grammatical Errorscited by 22
- 2021Paraphrastic Representations at Scalecited by 19
- 2019A Literature Study of Embeddings on Source Codecited by 18
- 2018Context2Name: A Deep Learning-Based Approach to Infer Natural Variable Names from Usage Contextscited by 11
50 most cited of 52 All 52 (JSON)
Built on by
Citing papers per year: 2022: 3; 2023: 4; 2024: 2; 2025: 1; 2026: 1.
11 papers.
- 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learningcited by 342
- 2023Is ChatGPT the Ultimate Programming Assistant -- How far is it?cited by 72
- 2023LExecutor: Learning-Guided Executioncited by 7
- 2024BLens: Contrastive Captioning of Binary Functions using Ensemble Embeddingcited by 3
- 2022CLAWSAT: Towards Both Robust and Accurate Code Modelscited by 2
- 2025Deep Learning-Based Identification of Inconsistent Method Names: How Far Are We?cited by 2
- 2024Beyond Self-learned Attention: Mitigating Attention Bias in Transformer-based Models Using Attention Guidancecited by 1
- 2022A Retrospective on ICSE 2022cited by 0
- 2023A Study of Variable-Role-based Feature Enrichment in Neural Models of Codecited by 0
- 2023Contrastive Learning for API Aspect Analysiscited by 0
- 2026Invariant Pretraining for Robust Code Representationscited by 0
- 2026Invariant Pretraining for Robust Code Representations15 Aug 2026
- 2025Deep Learning-Based Identification of Inconsistent Method Names: How Far Are We?22 Jan 2025
- 2024BLens: Contrastive Captioning of Binary Functions using Ensemble Embedding12 Sep 2024
- 2024Beyond Self-learned Attention: Mitigating Attention Bias in Transformer-based Models Using Attention Guidance26 Feb 2024
- 2023Contrastive Learning for API Aspect Analysis31 Jul 2023
- 2023Is ChatGPT the Ultimate Programming Assistant -- How far is it?24 Apr 2023
- 2023A Study of Variable-Role-based Feature Enrichment in Neural Models of Code8 Mar 2023
- 2023LExecutor: Learning-Guided Execution5 Feb 2023
- 2022CLAWSAT: Towards Both Robust and Accurate Code Models21 Nov 2022
- 2022A Retrospective on ICSE 202226 Jul 2022
- 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learning5 Jul 2022