arrow
Return

TransformCode: A Contrastive Learning Framework for Code Embedding via Subtree Transformation

delete2024-06-01
delete1
delete
OA
AI
Z
Zixiang Xian
R
Rubing Huang *
D
Dave Towey
房
房春荣 (Chunrong Fang) *
陈
陈振宇 (Zhenyu Chen)
DOI:10.1109/TSE.2024.3393419delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
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.
Keywords:
Codes
Task analysis
Self-supervised learning
Syntactics
Semantics
Vectors
Training
Code embedding
transformer
abstract syntax tree
contrastive learning

Journal

IEEE Transactions on Software Engineering cover
IEEE Transactions on Software Engineering
IF:
5.6
Papers:
2.9K
Citations:
1.1W

Organization

U
University of Nottingham Ningbo China
Scholars:
2.9K
Papers: 3.1K
Citations: 0
N
nanjing university
Scholars:
7.8W
Papers: 5.6W
Citations: 87
Cited Papers

Cited Papers

Gene Expression Studies Using Affymetrix Microarrays
err
IF0
err2009-07-15
err0
PREAI
errHinrich Gohlmann; Willem Talloen
errShare
errSave
Prostate-derived Ets factor, an oncogenic driver in breast cancer
err2017-05-04
err0
errOAAI
errAshwani K Sood; Joseph Geradts; Jessica Young
errShare
errSave
errShare
errSave
Modeling Functional Similarity in Source Code With Graph-Based Siamese Networks
err2022-10-01
err17
errOAAI
errMehrotra, Nikita; Agarwal, Navdha; Gupta, Piyush; Anand, Saket; Lo, David; Purandare, Rahul
errShare
errSave
Lys63/Met1-hybrid ubiquitin chains are commonly formed during the activation of innate immune signalling
err2016-06-01
err0
errOAAI
errChristoph H. Emmerich; Siddharth Bakshi; Ian R. Kelsall; Juanma Ortiz-Guerrero; Natalia Shpiro; Philip Cohen
errShare
errSave
Caveolin-1 and -2 regulate cell motility in castration-resistant prostate cancer
err2018-10-01
err0
errOAAI
errToyoharu Kamibeppu; Koji Yamasaki; Kozue Nakahara; Takahiro Nagai; Naoki Terada; Hiromasa Tsukino; Shoichiro Mukai; Toshiyuki Kamoto
errShare
errSave
researcher View more