paper-with-me

홈 › Papers

Rethinking Negative Pairs in Code Search

2023-10-12 · Haochen Li, Xin Zhou, Luu Anh Tuan, Chunyan Miao

Recently, contrastive learning has become a key component in fine-tuning code search models for software development efficiency and effectiveness. It pulls together positive code snippets while pushing negative samples away given search queries. Among contrastive learning, InfoNCE is the most widely used loss function due to its better performance. However, the following problems in negative samples of InfoNCE may deteriorate its representation learning: 1) The existence of false negative samples in large code corpora due to duplications. 2). The failure to explicitly differentiate between the potential relevance of negative samples. As an example, a bubble sorting algorithm example is less ``negative'' than a file saving function for the quick sorting algorithm query. In this paper, we tackle the above problems by proposing a simple yet effective Soft-InfoNCE loss that inserts weight terms into InfoNCE. In our proposed loss function, we apply three methods to estimate the weights of negative pairs and show that the vanilla InfoNCE loss is a special case of Soft-InfoNCE. Theoretically, we analyze the effects of Soft-InfoNCE on controlling the distribution of learnt code representations and on deducing a more precise mutual information estimation. We furthermore discuss the superiority of proposed loss functions with other design alternatives. Extensive experiments demonstrate the effectiveness of Soft-InfoNCE and weights estimation methods under state-of-the-art code search models on a large-scale public dataset consisting of six programming languages. Source code is available at \url{https://github.com/Alex-HaochenLi/Soft-InfoNCE}.

📄 PDF Abstract BibTeX arXiv:2310.08069

Code (1)

Alex-HaochenLi/Soft-InfoNCE 공식 구현 pytorch

Tasks

Code SearchContrastive LearningMutual Information EstimationRepresentation Learning

Methods 이 논문이 사용한 방법론

InfoNCE 설명 없음
Contrastive Learning 설명 없음

Similar Papers 제목 키워드 기반

OASIS: Order-Augmented Strategy for Improved Code Search

2025-03-11 · Zuchen Gao, Zizheng Zhan, Xianming Li, Erxin Yu 외

Code embeddings capture the semantic representations of code and are crucial for various code-related large language model (LLM) applications, such as code search. Previous training primarily relies on optimizing the Inf…

Code SearchLanguage ModelingLanguage ModellingLarge Language Model

Rethinking Prompting Strategies for Multi-Label Recognition with Partial Annotations

2024-09-12 · Samyak Rawlekar, Shubhang Bhatnagar, Narendra Ahuja

Vision-language models (VLMs) like CLIP have been adapted for Multi-Label Recognition (MLR) with partial annotations by leveraging prompt-learning, where positive and negative prompts are learned for each class to associ…

Missing LabelsPrompt Learning

Rethinking Rotation in Self-Supervised Contrastive Learning: Adaptive Positive or Negative Data Augmentation

2022-10-23 · Atsuyuki Miyai, Qing Yu, Daiki Ikami, Go Irie 외

Rotation is frequently listed as a candidate for data augmentation in contrastive learning but seldom provides satisfactory improvements. We argue that this is because the rotated image is always treated as either positi…

Contrastive LearningData Augmentation

Rethinking and Simplifying Bootstrapped Graph Latents

2023-12-05 · Wangbin Sun, Jintang Li, Liang Chen, Bingzhe Wu 외

Graph contrastive learning (GCL) has emerged as a representative paradigm in graph self-supervised learning, where negative samples are commonly regarded as the key to preventing model collapse and producing distinguisha…

Contrastive LearningSelf-Supervised Learning

Boosting Contrastive Self-Supervised Learning with False Negative Cancellation

2020-11-23 · Tri Huynh, Simon Kornblith, Matthew R. Walter, Michael Maire 외

Self-supervised representation learning has made significant leaps fueled by progress in contrastive learning, which seeks to learn transformations that embed positive input pairs nearby, while pushing negative pairs far…

Contrastive LearningRepresentation LearningSelf-Supervised Image ClassificationSelf-Supervised Learning+1