Lune

EMNLP2022Top-tier venue

Exploring Representation-level Augmentation for Code Search

Haochen Li, Chunyan Miao, Cyril Leung, Yanxian Huang, Yuan Huang, Hongyu Zhang, Yanlin Wang

Abstract

Code search, which aims at retrieving the most relevant code fragment for a given natural language query, is a common activity in software development practice. Recently, contrastive learning is widely used in code search research, where many data augmentation approaches for source code (e.g., semantic-preserving program transformation) are proposed to learn better representations. However, these augmentations are at the raw-data level, which requires additional code analysis in the preprocessing stage and additional training costs in the training stage. In this paper, we explore augmentation methods that augment data (both code and query) at representation level which does not require additional data processing and training, and based on this we propose a general format of representationlevel augmentation that unifies existing methods. Then, we propose three new augmentation methods (linear extrapolation, binary interpolation, and Gaussian scaling) based on the general format. Furthermore, we theoretically analyze the advantages of the proposed augmentation methods over traditional contrastive learning methods on code search. We experimentally evaluate the proposed representationlevel augmentation methods with state-of-theart code search models on a large-scale public dataset consisting of six programming languages. The experimental results show that our approach can consistently boost the performance of the studied code search models. Our source code is available at https://github. com/Alex-HaochenLi/RACS .

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

6 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • MGS3: A Multi-Granularity Self-Supervised Code Search Framework cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • MGS3: A Multi-Granularity Self-Supervised Code Search Framework cites GraphCodeBERT: Pre-training Code Representations with Data Flow
  • MGS3: A Multi-Granularity Self-Supervised Code Search Framework cites CONSIDER: Commonalities and Specialties Driven Multilingual Code Retrieval Framework
  • Towards Domain-Agnostic Contrastive Learning cites Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere
  • iSMELL: Assembling LLMs with Expert Toolsets for Code Smell Detection and Refactoring cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • CONSIDER: Commonalities and Specialties Driven Multilingual Code Retrieval Framework cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • CONSIDER: Commonalities and Specialties Driven Multilingual Code Retrieval Framework cites GraphCodeBERT: Pre-training Code Representations with Data Flow
  • SimCSE: Simple Contrastive Learning of Sentence Embeddings cites Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere
  • XSearch: Explainable Code Search via Concept-to-Code Alignment cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • XSearch: Explainable Code Search via Concept-to-Code Alignment cites GraphCodeBERT: Pre-training Code Representations with Data Flow
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers6

  1. iSMELL: Assembling LLMs with Expert Toolsets for Code Smell Detection and RefactoringDi Wu, Fangwen Mu, Lin Shi, Zhaoqiang Guo et al.ASE 2024 · 19 citations
  2. CONSIDER: Commonalities and Specialties Driven Multilingual Code Retrieval FrameworkRui Li, Liyang He, Qi Liu, Yuze Zhao et al.AAAI 2024 · 11 citations
  3. XSearch: Explainable Code Search via Concept-to-Code AlignmentYiming Liu, Ruofan Liu, Yun Lin, Zicong Zhang et al.ISSTA 2026 · 1 citation
  4. MGS3: A Multi-Granularity Self-Supervised Code Search FrameworkRui Li, Junfeng Kang, Qi Liu, Liyang He et al.KDD 2025
  5. GiFT: Gibbs Fine-Tuning for Code GenerationHaochen Li, Wanjin Feng, Xin Zhou, Zhiqi ShenACL 2025

Builds on13

  1. CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan et al.EMNLP Findings 2020 · 2,828 citations
  2. SimCSE: Simple Contrastive Learning of Sentence EmbeddingsTianyu Gao, Xingcheng Yao, Danqi ChenEMNLP 2021 · 2,496 citations
  3. Understanding Contrastive Representation Learning through Alignment and Uniformity on the HypersphereTongzhou Wang, Phillip IsolaICML 2020 · 2,360 citations
  4. GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng et al.ICLR 2021 · 1,644 citations
  5. Towards Domain-Agnostic Contrastive LearningVikas Verma, Thang Luong, Kenji Kawaguchi, Hieu Pham et al.ICML 2021 · 131 citations

Related papers

  1. Uncertainty-Aware Contrastive Learning with Hard Negative Sampling for Code Search TasksHan Liu, Jiaqing Zhan, Qin ZhangAAAI 2025 · 1 citation
  2. CoCoSoDa: Effective Contrastive Learning for Code SearchEnsheng Shi, Yanlin Wang, Wenchao Gu, Lun Du et al.ICSE 2023 · 45 citations
  3. CodeRetriever: A Large Scale Contrastive Pre-Training Method for Code SearchXiaonan Li, Yeyun Gong, Yelong Shen, Xipeng Qiu et al.EMNLP 2022 · 25 citations
  4. Code Representation Learning at ScaleDejiao Zhang, Wasi Uddin Ahmad, Ming Tan, Hantian Ding et al.ICLR 2024 · 32 citations
  5. ContraBERT: Enhancing Code Pre-trained Models via Contrastive LearningShangqing Liu, Bozhi Wu, Xiaofei Xie, Guozhu Meng et al.ICSE 2023 · 56 citations
Dusk over the sea between two cliffs drawn in fine vertical lines