atlas

Research map / Label-efficient and robust learning / Recognition and long-tail

Uncertainty-Aware Contrastive Learning with Hard Negative Sampling for Code Search Tasks

AAAI 2025 · Label-efficient and robust learning › Recognition and long-tail · approach: Multilingual language representation pretraining · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes uncertainty-aware contrastive learning (Gaussian reparameterized query/code embeddings) plus BM25-filtered hard negative sampling, initialized from CoCoSoDa, for code search on CodeSearchNet.

Problem

Code search with contrastive learning treats query and code embeddings as deterministic, although the same semantics can be expressed in diverse language styles; hard negatives are also underused.

Approach

Map query and code embeddings to Gaussian distributions (learned mean and variance) with reparameterization to produce diverse embeddings, add a KL regularizer, and construct hard negative query-code pairs by selecting similar queries and filtering false negatives with BM25.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Add hard negative sampling to in-batch negatives (ablation)Our code search method · CodeSearchNet AVG.MRR: 0.796 -> 0.800Helped
Replace hard negative sampling with random sampling (ablation)Our code search method · CodeSearchNet AVG.MRR: 0.800 -> 0.796Hurt
Add unimodal contrastive learning (ablation)Our code search method · CodeSearchNet AVG.MRR: 0.793 -> 0.800Helped
Add candidate sorting (ablation)Our code search method · CodeSearchNet AVG.MRR: 0.794 -> 0.796Helped
Use uncertainty-aware embedding (ablation)Our code search method · CodeSearchNetMRRHelped

Surprising findings

Limitations

Experimental setup

Datasets: CodeSearchNet CodeSearchNet expanded candidate set (Guo et al.)

Benchmarks: CodeSearchNet

Metrics: MRR R@1 R@5 R@10

Baselines: RoBERTa (code) CodeBERT GraphCodeBERT SynCoBERT UniXcoder CodeRetriever Soft-InfoNCE TOSS CoCoSoDa SEA

Builds on: CoCoSoDa UniXcoder InfoNCE BM25

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy