{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/approximate-nearest-neighbor-negative","title":"Approximate Nearest Neighbor Negative Contrastive Learning for Dense Text Retrieval","arxiv_id":"2007.00808","date":"2020-07-01","proceeding":"ICLR 2021 1","authors":["Lee Xiong","Chenyan Xiong","Ye Li","Kwok-Fung Tang","Jialin Liu","Paul Bennett","Junaid Ahmed","Arnold Overwijk"],"abstract":"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.","url_abs":"https://arxiv.org/abs/2007.00808v2","url_pdf":"https://arxiv.org/pdf/2007.00808v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"approximate-nearest-neighbor-negative","repo_url":"https://github.com/microsoft/ANCE","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"approximate-nearest-neighbor-negative","repo_url":"https://github.com/grill-lab/codec","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}},{"paper_slug":"approximate-nearest-neighbor-negative","repo_url":"https://github.com/microsoft/seed-encoder","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"approximate-nearest-neighbor-negative","repo_url":"https://github.com/terrierteam/pyterrier_ance","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"approximate-nearest-neighbor-negative","repo_url":"https://github.com/terrierteam/pyterrier_dr","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":"passage-retrieval","task_name":"Passage Retrieval"},{"task_slug":"reranking","task_name":"Reranking"},{"task_slug":"retrieval","task_name":"Retrieval"},{"task_slug":"text-retrieval","task_name":"Text Retrieval"},{"task_slug":"zero-shot-text-search","task_name":"Zero-shot Text Search"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/passage-retrieval-on-natural-questions","task":"Passage Retrieval","dataset":"Natural Questions","model":"ANCE","rank_in_archive_order":7,"of":10,"metrics":{"Precision@100":"87.5","Precision@20":"81.9"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2007.00808","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2007.00808"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/grill-lab/codec","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/terrierteam/pyterrier_ance","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/microsoft/ANCE","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/terrierteam/pyterrier_dr","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/microsoft/seed-encoder","reach":null}],"summary":{"ran_draft_wrong":1,"ran_honours":1,"ran":1,"unverified":9},"by_repo_kind":{"official":{"samples":11,"ran":2,"repositories":1},"listed":{"samples":1,"ran":1,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"4ccfcf15369dfbea","entry":"GetProcessingFn","repo":"microsoft/seed-encoder","repo_kind":"listed","path":"data/msmarco_data.py","file_url":"https://github.com/microsoft/seed-encoder/blob/HEAD/data/msmarco_data.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4ccfcf15369dfbea"}},{"code_sha256_prefix":"8f266b9d616de9b9","entry":"fill_with_neg_inf","repo":"microsoft/ANCE","repo_kind":"official","path":"model/SEED_Encoder/transformer_sentence_encoder.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/model/SEED_Encoder/transformer_sentence_encoder.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8f266b9d616de9b9"}},{"code_sha256_prefix":"538cfaef12b25b54","entry":"get_encoder_params_state","repo":"microsoft/ANCE","repo_kind":"official","path":"utils/dpr_utils.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/utils/dpr_utils.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"538cfaef12b25b54"}},{"code_sha256_prefix":"932bcadd912b1422","entry":"LayerNorm","repo":"microsoft/ANCE","repo_kind":"official","path":"model/SEED_Encoder/modules.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/model/SEED_Encoder/modules.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"932bcadd912b1422"}},{"code_sha256_prefix":"e8a98cc72991f258","entry":"convert_to_unicode","repo":"microsoft/ANCE","repo_kind":"official","path":"model/SEED_Encoder/tokenization_seed_encoder.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/model/SEED_Encoder/tokenization_seed_encoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e8a98cc72991f258"}},{"code_sha256_prefix":"59da6f907f4e84f2","entry":"get_model_obj","repo":"microsoft/ANCE","repo_kind":"official","path":"utils/dpr_utils.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/utils/dpr_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"59da6f907f4e84f2"}},{"code_sha256_prefix":"07179da1319d3649","entry":"item","repo":"microsoft/ANCE","repo_kind":"official","path":"model/SEED_Encoder/transformer_sentence_encoder.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/model/SEED_Encoder/transformer_sentence_encoder.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"07179da1319d3649"}},{"code_sha256_prefix":"8340872a93ffe88f","entry":"load_positive_ids","repo":"microsoft/ANCE","repo_kind":"official","path":"drivers/run_ann_data_gen.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/drivers/run_ann_data_gen.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8340872a93ffe88f"}},{"code_sha256_prefix":"6ad0e0ed0c9a7ee4","entry":"log_softmax","repo":"microsoft/ANCE","repo_kind":"official","path":"model/SEED_Encoder/modules.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/model/SEED_Encoder/modules.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6ad0e0ed0c9a7ee4"}},{"code_sha256_prefix":"e44c1974fb9752d3","entry":"set_encoder_params_from_state","repo":"microsoft/ANCE","repo_kind":"official","path":"utils/dpr_utils.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/utils/dpr_utils.py","link_basis":"plan_row","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e44c1974fb9752d3"}},{"code_sha256_prefix":"f4d9cafead3a750e","entry":"softmax","repo":"microsoft/ANCE","repo_kind":"official","path":"model/SEED_Encoder/modules.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/model/SEED_Encoder/modules.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f4d9cafead3a750e"}},{"code_sha256_prefix":"06aa628bdeb1eed9","entry":"triplet_fwd_pass","repo":"microsoft/ANCE","repo_kind":"official","path":"drivers/run_ann_dpr.py","file_url":"https://github.com/microsoft/ANCE/blob/HEAD/drivers/run_ann_dpr.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"06aa628bdeb1eed9"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}