paper-with-me

홈 › Papers

CoCoSoDa: Effective Contrastive Learning for Code Search

2022-04-07 · 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 14 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.

📄 PDF Abstract BibTeX arXiv:2204.03293

Code (0)

등록된 구현이 없습니다.

Tasks

Code SearchContrastive LearningData AugmentationRepresentation Learning

Methods 이 논문이 사용한 방법론

Attention 설명 없음
Linear Layer A Linear Layer is a projection $\mathbf{XW + b}$.
Contrastive Learning 설명 없음
Layer Normalization Unlike batch normalization, Layer Normalization directly estimates the normalization statistics from the summed inputs…
Adam 설명 없음
Residual Connection 설명 없음
Refunds@Expedia|||How do I get a full refund from Expedia? “How do I get a full refund from Expedia? How do I get a full refund from Expedia? – Call ☎️ +1-(888) 829 (0881) or +1-805-330-4056 or +1-805-330-4056 for Quick Help &…
Dense Connections Dense Connections, or Fully Connected Connections, are a type of layer in a deep neural network that use a linear operation where every input is connected to every output…

Similar Papers 제목 키워드 기반

Zero-Shot Cross-Domain Code Search without Fine-Tuning

2025-04-10 · Keyu Liang, Zhongxin Liu, Chao Liu, Zhiyuan Wan 외

Code search aims to retrieve semantically relevant code snippets for natural language queries. While pre-trained language models (PLMs) have shown remarkable performance in this task, they struggle in cross-domain scenar…

Code SearchNatural Language Queries

CodeRetriever: Unimodal and Bimodal Contrastive Learning for Code Search

2022-01-26 · Xiaonan Li, Yeyun Gong, Yelong Shen, Xipeng Qiu 외

In this paper, we propose the CodeRetriever model, which learns the function-level code semantic representations through large-scale code-text contrastive pre-training. We adopt two contrastive learning schemes in CodeRe…

Code SearchContrastive Learning

CodeRetriever: Unimodal and Bimodal Contrastive Learning for Code Search

2021-11-16 · ACL ARR November 2021 11 · Anonymous

In this paper, we propose the CodeRetriever model, which combines the unimodal and bimodal contrastive learning to train function-level code semantic representations, specifically for the code search task. For unimodal c…

Code SearchContrastive Learning

Contrastive Prompt Learning-based Code Search based on Interaction Matrix

2023-10-10 · Yubo Zhang, Yanfang Liu, Xinxin Fan, Yunfeng Lu

Code search aims to retrieve the code snippet that highly matches the given query described in natural language. Recently, many code pre-training approaches have demonstrated impressive performance on code search. Howeve…

Code SearchContrastive LearningPrompt Learning

Contrastive Learning of Natural Language and Code Representations for Semantic Code Search

2021-06-16 · ACL ARR Jun 2021 6 · Anonymous

Retrieving semantically relevant code functions given a natural language (NL) or programming language (PL) query is a task of great practical value towards building productivity enhancing tools for software developers. R…

Code SearchContrastive Learning