Lune

ICSE2023顶会

CoCoSoDa: Effective Contrastive Learning for Code Search

Ensheng Shi, Yanlin Wang, Wenchao Gu, Lun Du, Hongyu Zhang, Shi Han, Dongmei Zhang, Hongbin Sun

摘要

Code search aims to retrieve semantically relevant code snippets for a given natural language query. Recently, many approaches employing contrastive learning have shown promising results on code representation learning and greatly improved the performance of code search. However, there is still a lot of room for improvement in using contrastive learning for code search. In this paper, we propose CoCoSoDa to effectively utilize contrastive learning for code search via two key factors in contrastive learning: data augmentation and negative samples. Specifically, soft data augmentation is to dynamically masking or replacing some tokens with their types for input sequences to generate positive samples. Momentum mechanism is used to generate large and consistent representations of negative samples in a mini-batch through maintaining a queue and a momentum encoder. In addition, multimodal contrastive learning is used to pull together representations of code-query pairs and push apart the unpaired code snippets and queries. We conduct extensive experiments to evaluate the effectiveness of our approach on a large-scale dataset with six programming languages. Experimental results show that: (1) CoCoSoDa outperforms 18 baselines and especially exceeds CodeBERT, GraphCodeBERT, and UniXcoder by 13.3%, 10.5%, and 5.9% on average MRR scores, respectively. (2) The ablation studies show the effectiveness of each component of our approach. (3) We adapt our techniques to several different pre-trained models such as RoBERTa, CodeBERT, and GraphCodeBERT and observe a significant boost in their performance in code search. (4) Our model performs robustly under different hyper-parameters. Furthermore, we perform qualitative and quantitative analyses to explore reasons behind the good performance of our model.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 21 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • Instructive Code Retriever: Learn from Large Language Model's Feedback for Code Intelligence Tasks 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Instructive Code Retriever: Learn from Large Language Model's Feedback for Code Intelligence Tasks 引用了 Language Models are Few-Shot Learners
  • Instructive Code Retriever: Learn from Large Language Model's Feedback for Code Intelligence Tasks 引用了 What Makes Good In-Context Demonstrations for Code Intelligence Tasks with LLMs?
  • Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere 引用了 A Simple Framework for Contrastive Learning of Visual Representations
  • SECRET: Towards Scalable and Efficient Code Retrieval via Segmented Deep Hashing 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • SimCSE: Simple Contrastive Learning of Sentence Embeddings 引用了 Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere
  • SimCSE: Simple Contrastive Learning of Sentence Embeddings 引用了 A Simple Framework for Contrastive Learning of Visual Representations
  • What Makes Good In-Context Demonstrations for Code Intelligence Tasks with LLMs? 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • What Makes Good In-Context Demonstrations for Code Intelligence Tasks with LLMs? 引用了 Language Models are Few-Shot Learners
  • Learning in the Wild: Towards Leveraging Unlabeled Data for Effectively Tuning Pre-trained Code Models 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Learning in the Wild: Towards Leveraging Unlabeled Data for Effectively Tuning Pre-trained Code Models 引用了 What Makes Good In-Context Demonstrations for Code Intelligence Tasks with LLMs?
  • Two Birds with One Stone: Boosting Code Generation and Code Search via a Generative Adversarial Network 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper21

  1. What Makes Good In-Context Demonstrations for Code Intelligence Tasks with LLMs?Shuzheng Gao, Xin-Cheng Wen, Cuiyun Gao, Wenxuan Wang 等ASE 2023 · 80 次引用
  2. Two Birds with One Stone: Boosting Code Generation and Code Search via a Generative Adversarial NetworkShangwen Wang, Bo Lin, Zhensu Sun, Ming Wen 等OOPSLA 2023 · 21 次引用
  3. Learning in the Wild: Towards Leveraging Unlabeled Data for Effectively Tuning Pre-trained Code ModelsShuzheng Gao, Wenxin Mao, Cuiyun Gao, Li Li 等ICSE 2024 · 15 次引用
  4. Instructive Code Retriever: Learn from Large Language Model's Feedback for Code Intelligence TasksJiawei Lu, Haoye Wang, Zhongxin Liu, Keyu Liang 等ASE 2024 · 3 次引用
  5. SECRET: Towards Scalable and Efficient Code Retrieval via Segmented Deep HashingWenchao Gu, Ensheng Shi, Yanlin Wang, Lun Du 等ICSE 2025 · 3 次引用

它引用的 Paper26

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
  2. A Simple Framework for Contrastive Learning of Visual RepresentationsTing Chen, Simon Kornblith, Mohammad Norouzi, Geoffrey E. HintonICML 2020 · 24,064 次引用
  3. CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan 等EMNLP Findings 2020 · 2,828 次引用
  4. SimCSE: Simple Contrastive Learning of Sentence EmbeddingsTianyu Gao, Xingcheng Yao, Danqi ChenEMNLP 2021 · 2,496 次引用
  5. Understanding Contrastive Representation Learning through Alignment and Uniformity on the HypersphereTongzhou Wang, Phillip IsolaICML 2020 · 2,360 次引用

相关 Paper

  1. Exploring Representation-level Augmentation for Code SearchHaochen Li, Chunyan Miao, Cyril Leung, Yanxian Huang 等EMNLP 2022 · 17 次引用
  2. Uncertainty-Aware Contrastive Learning with Hard Negative Sampling for Code Search TasksHan Liu, Jiaqing Zhan, Qin ZhangAAAI 2025 · 1 次引用
  3. ContraBERT: Enhancing Code Pre-trained Models via Contrastive LearningShangqing Liu, Bozhi Wu, Xiaofei Xie, Guozhu Meng 等ICSE 2023 · 56 次引用
  4. CodeRetriever: A Large Scale Contrastive Pre-Training Method for Code SearchXiaonan Li, Yeyun Gong, Yelong Shen, Xipeng Qiu 等EMNLP 2022 · 25 次引用
  5. Self-Supervised Contrastive Learning for Code Retrieval and Summarization via Semantic-Preserving TransformationsNghi D. Q. Bui, Yijun Yu, Lingxiao JiangSIGIR 2021 · 98 次引用
黄昏的海面,两侧是细线勾勒的悬崖