TransformCode: A Contrastive Learning Framework for Code Embedding via Subtree Transformation
Not on the map. Why?
Abstract (arXiv)
Artificial intelligence (AI) has revolutionized software engineering (SE) by enhancing software development efficiency. The advent of pre-trained models (PTMs) leveraging transfer learning has significantly advanced AI for SE. However, existing PTMs that operate on individual code tokens suffer from several limitations: They are costly to train and fine-tune; and they rely heavily on labeled data for fine-tuning on task-specific datasets. In this paper, we present TransformCode, a novel framework that learns code embeddings in a contrastive learning manner. Our framework is encoder-agnostic and language-agnostic, which means that it can leverage any encoder model and handle any programming language. We also propose a novel data-augmentation technique called abstract syntax tree (AST) transformation, which applies syntactic and semantic transformations to the original code snippets, to generate more diverse and robust samples for contrastive learning. Our framework has several advantages over existing methods: (1) It is flexible and adaptable, because it can easily be extended to other downstream tasks that require code representation (such as code-clone detection and classification); (2) it is efficient and scalable, because it does not require a large model or a large amount of training data, and it can support any programming language; (3) it is not limited to unsupervised learning, but can also be applied to some supervised learning tasks by incorporating task-specific labels or objectives; and (4) it can also adjust the number of encoder parameters based on computing resources. We evaluate our framework on several code-related tasks, and demonstrate its effectiveness and superiority over the state-of-the-art methods such as SourcererCC, Code2vec, and InferCode.
Key facts. Cited by 4 papers in the map (data through 7 Oct 2026). Builds on 53 of its 102 references that are in the map. First posted on arXiv 10 Nov 2023.
Builds on
53 of 102 references.
References · 53
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,084
- 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
- 2018Representation Learning with Contrastive Predictive Codingcited by 7,662
- 2019Momentum Contrast for Unsupervised Visual Representation Learningcited by 7,482
- 2016XGBoost: A Scalable Tree Boosting Systemcited by 5,120
- 2020Bootstrap your own latent: A new approach to self-supervised Learningcited by 4,712
- 2022Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedbackcited by 3,634
38 more
- 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,898
- 2020Exploring Simple Siamese Representation Learningcited by 2,853
- 2020Improved Baselines with Momentum Contrastive Learningcited by 2,282
- 2021SimCSE: Simple Contrastive Learning of Sentence Embeddingscited by 2,168
- 2016Convolutional Neural Networks on Graphs with Fast Localized Spectral Filteringcited by 2,085
- 2018Unsupervised Feature Learning via Non-Parametric Instance-level Discriminationcited by 1,838
- 2020Big Self-Supervised Models are Strong Semi-Supervised Learnerscited by 1,375
- 2019Contrastive Multiview Codingcited by 1,297
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2014Convolutional Neural Networks for Sentence Classificationcited by 1,124
- 2018Self-Attention with Relative Position Representationscited by 1,112
- 2015Gated Graph Sequence Neural Networkscited by 792
- 2018Subword Regularization: Improving Neural Network Translation Models with Multiple Subword Candidatescited by 632
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
- 2021Unified Pre-training for Program Understanding and Generationcited by 361
- 2022Text and Code Embeddings by Contrastive Pre-Trainingcited by 358
- 2019A Multiscale Visualization of Attention in the Transformer Modelcited by 292
- 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 266
- 2018code2vec: Learning Distributed Representations of Codecited by 249
- 2019Unsupervised Embedding Learning via Invariant and Spreading Instance Featurecited by 231
- 2017Learning to Represent Programs with Graphscited by 219
- 2020Data Augmentation for Graph Neural Networkscited by 200
- 2018code2seq: Generating Sequences from Structured Representations of Codecited by 177
- 2020Deep Learning based Vulnerability Detection: Are We There Yet?cited by 142
- 2020A Transformer-based Approach for Source Code Summarizationcited by 129
- 2014Learning to Executecited by 105
- 2020Retrieval-Augmented Generation for Code Summarization via Hybrid GNNcited by 89
- 2020Contrastive Code Representation Learningcited by 76
- 2020Detecting Code Clones with Graph Neural Networkand Flow-Augmented Abstract Syntax Treecited by 68
- 2020Self-Supervised Contrastive Learning for Code Retrieval and Summarization via Semantic-Preserving Transformationscited by 49
- 2015SourcererCC: Scaling Code Clone Detection to Big Codecited by 40
- 2021Code Structure Guided Transformer for Source Code Summarizationcited by 29
- 2020InferCode: Self-Supervised Learning of Code Representations by Predicting Subtreescited by 23
- 2023CodeTF: One-stop Transformer Library for State-of-the-art Code LLMscited by 21
- 2018Oreo: Detection of Clones in the Twilight Zonecited by 19
- 2019A Literature Study of Embeddings on Source Codecited by 18
- 2020TreeCaps: Tree-Based Capsule Networks for Source Code Processingcited by 16
- 2020Modeling Functional Similarity in Source Code with Graph-Based Siamese Networkscited by 10
50 most cited of 53 All 53 (JSON)
Built on by
Citing papers per year: 2024: 1; 2025: 2; 2026: 1.
4 papers.
- 2026TraceCoder: A Trace-Driven Multi-Agent Framework for Automated Debugging of LLM-Generated Codecited by 6
- 2025On The Role of Pretrained Language Models in General-Purpose Text Embeddings: A Surveycited by 3
- 2024LSem2Vec: A Simple yet Effective Two-Stage Approach for Source Code Embeddingcited by 0
- 2025From Illusion to Insight: Change-Aware File-Level Software Defect Prediction Using Agentic AIcited by 0
- 2026TraceCoder: A Trace-Driven Multi-Agent Framework for Automated Debugging of LLM-Generated Code6 Feb 2026
- 2025From Illusion to Insight: Change-Aware File-Level Software Defect Prediction Using Agentic AI29 Dec 2025
- 2025On The Role of Pretrained Language Models in General-Purpose Text Embeddings: A Survey28 Jul 2025
- 2024LSem2Vec: A Simple yet Effective Two-Stage Approach for Source Code Embedding23 Sep 2024