Papers › Approximate Nearest Neighbor Negative Contrastive Learning for Dense Text Retrieval

Approximate Nearest Neighbor Negative Contrastive Learning for Dense Text Retrieval

1 Jul 2020ICLR 2021 1arXiv:2007.00808archive 2025-07-28

Lee Xiong, Chenyan Xiong, Ye Li, Kwok-Fung Tang, Jialin Liu, Paul Bennett, Junaid Ahmed, Arnold Overwijk

Conducting text retrieval in a dense learned representation space has many intriguing advantages over sparse retrieval. Yet the effectiveness of dense retrieval (DR) often requires combination with sparse retrieval. In this paper, we identify that the main bottleneck is in the training mechanisms, where the negative instances used in training are not representative of the irrelevant documents in testing. This paper presents Approximate nearest neighbor Negative Contrastive Estimation (ANCE), a training mechanism that constructs negatives from an Approximate Nearest Neighbor (ANN) index of the corpus, which is parallelly updated with the learning process to select more realistic negative training instances. This fundamentally resolves the discrepancy between the data distribution used in the training and testing of DR. In our experiments, ANCE boosts the BERT-Siamese DR model to outperform all competitive dense and sparse retrieval baselines. It nearly matches the accuracy of sparse-retrieval-and-BERT-reranking using dot-product in the ANCE-learned representation space and provides almost 100x speed-up.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2007.00808")

Code

Syntology Ran 3 of 12 code samples harvested from 2 repositories linked to this paper; 9 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · our draft was wrong; 1 ran with no contract checked.

By repository: official repository: 11 samples from 1 repository, 2 ran; community (archive-listed): 1 sample from 1 repository, 1 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

microsoft/ANCE officialmentioned in papermentioned on GitHubpytorchMIT report
grill-lab/codec mentioned on GitHub report
microsoft/seed-encoder mentioned on GitHubpytorch report
terrierteam/pyterrier_ance mentioned on GitHubpytorch report
terrierteam/pyterrier_dr mentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

12 samples harvested; 3 ran; 1 honoured the contract we drafted; 9 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
1ran · our draft was wrong
1ran
9unverified

Licence: 0 of the 12 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

fill_with_neg_inf microsoft/ANCE/model/SEED_Encoder/transformer_sentence_encoder.py official repository ran · honoured contract fingerprinted MIT (permissive) · 8f266b9d616de9b9 · report
get_encoder_params_state microsoft/ANCE/utils/dpr_utils.py official repository ran MIT (permissive) · 538cfaef12b25b54 · report
LayerNorm microsoft/ANCE/model/SEED_Encoder/modules.py official repository unverified MIT (permissive) · 932bcadd912b1422 · report
convert_to_unicode microsoft/ANCE/model/SEED_Encoder/tokenization_seed_encoder.py official repository unverified MIT (permissive) · e8a98cc72991f258 · report
get_model_obj microsoft/ANCE/utils/dpr_utils.py official repository unverified MIT (permissive) · 59da6f907f4e84f2 · report
item microsoft/ANCE/model/SEED_Encoder/transformer_sentence_encoder.py official repository unverified MIT (permissive) · 07179da1319d3649 · report
load_positive_ids microsoft/ANCE/drivers/run_ann_data_gen.py official repository unverified MIT (permissive) · 8340872a93ffe88f · report
log_softmax microsoft/ANCE/model/SEED_Encoder/modules.py official repository unverified MIT (permissive) · 6ad0e0ed0c9a7ee4 · report
set_encoder_params_from_state microsoft/ANCE/utils/dpr_utils.py official repository unverified MIT (permissive) · e44c1974fb9752d3 · report
softmax microsoft/ANCE/model/SEED_Encoder/modules.py official repository unverified MIT (permissive) · f4d9cafead3a750e · report
triplet_fwd_pass microsoft/ANCE/drivers/run_ann_dpr.py official repository unverified MIT (permissive) · 06aa628bdeb1eed9 · report
GetProcessingFn microsoft/seed-encoder/data/msmarco_data.py community (archive-listed) ran · our draft was wrong MIT (permissive) · 4ccfcf15369dfbea · report

Tasks

Contrastive LearningPassage RetrievalRerankingRetrievalText RetrievalZero-shot Text Search

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Passage Retrieval Natural Questions ANCE Precision@100 87.5 #7 of 10 Archive leaderboard report
Passage Retrieval Natural Questions ANCE Precision@20 81.9 #7 of 10 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections