# Unsupervised Dense Information Retrieval with Contrastive Learning

Gautier Izacard, Mathilde Caron, Lucas Hosseini, Sebastian Riedel, Piotr Bojanowski, Armand Joulin and 1 more · arXiv · 2021-12-16

- **Problem** Dense retrievers trained on labelled data transfer poorly to new domains and languages, and label-free alternatives have so far trailed BM25.
- **Method** Trains a bi-encoder without labels by contrastive learning, forming positive pairs from two cropped spans of one document and using a MoCo queue of negatives.
- **Results** Reaches Recall@100 of 82.1 on the NaturalQuestions test set, against 78.3 for BM25 quoted from Ma et al. (2021).

![Figure 1: Unsupervised retrieval. We compare our pre-training without usingany annotated data to REALM (Guu et al., 2020), SimCSE (Gao et al., 2021) and BM25.…](https://refivu.com/papers/2fbce187-1a33-4d74-941c-36d004c9a79b/figures/figure-7155088e03c26a948681ec1bc5ada27f.png?thumb=512)

**Figure 1** : Unsupervised retrieval. We compare our pre-training without usingany annotated data to REALM (Guu et al., 2020), SimCSE (Gao et al., 2021) and BM25. For SimCSE we report results of the model using RoBERTa large. REALM uses annotated entity recognition data for training. We highlight that our unsupervised pre-training is on par with BM25 but on 2 datasets.

[Original paper](https://arxiv.org/abs/2112.09118v4) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Gautier Izacard, Mathilde Caron, Lucas Hosseini, Sebastian Riedel, Piotr Bojanowski, Armand Joulin, Edouard Grave · Unsupervised Dense Information Retrieval with Contrastive Learning · Original paper figure · Extracted the figure area from page 5 of the original PDF.

## Why dense retrievers need labels

Dense retrievers that encode queries and documents into vectors reach state-of-the-art results on tasks where large training sets exist. Building such training sets means matching queries to relevant documents by hand, which is hard to scale when a collection holds millions of items. A retriever trained on MS MARCO and then applied to new domains, the zero-shot setting, often ends up behind classical term-frequency methods that need no supervision.

Annotated data is also scarce in languages other than English, so supervised training does not extend easily to multilingual retrieval.

The open question is whether a dense retriever can be trained without supervision and still match BM25. The inverse Cloze task supplies a self-generated training signal by treating a sentence as the query and predicting the context around it. That signal helps as pre-training, but used alone as a zero-shot retriever it still trails BM25.

## Contrastive pre-training of a bi-encoder

The model is a bi-encoder: a query and a document are encoded separately by the same BERT base uncased transformer, and the score is the dot product of the two vectors. Because a document is encoded without the query, each document can be encoded once and reused for every query. The score is \\(s(q,d)=\\langle f\_\\theta(q), f\_\\theta(d)\\rangle\\), where the same \\(f\_\\theta\\) embeds both sides and each representation is the average of the last layer's hidden states.

Training needs no labels because two views of the same document form a positive pair, while views of other documents serve as negatives. The loss is InfoNCE, which scores the positive key against a pool of negatives through a softmax over similarities scaled by a temperature. It raises the score of the positive key and lowers the scores of the negatives, which mirrors the search step where a query must pick out one document from many.

Independent cropping samples two spans from one document, and because both spans follow the same distribution the two views are symmetric. The spans can overlap, which pushes the encoder toward exact matches in a way that resembles BM25. The inverse Cloze task differs: its two views are mutually exclusive, with the span as query and the remaining tokens as key.

In-batch negatives take the other examples in the batch as negatives, so the number of negatives equals the batch size. MoCo instead keeps keys from earlier batches in a queue, and its keys come from a second encoder updated by a moving average, \\(\\theta\_k\\leftarrow m\\theta\_k+(1-m)\\theta\_q\\). This lets the number of negatives grow without increasing the batch size.

Contriever combines random cropping, MoCo with a queue, and deletion of tokens from each element of a pair with probability 10%. Its pre-training data mixes Wikipedia and CCNet, with half the batches drawn from each source.

## Zero-shot results against BM25

On the NaturalQuestions test set, unsupervised Contriever reaches Recall@100 of 82.1, while the BM25 value is 78.3. On TriviaQA the two tie at 83.2 Recall@100. The BM25 numbers are quoted from Ma et al. (2021), so this comparison spans two sources rather than one run.

On the BEIR benchmark, measured with Recall@100, the unsupervised model beats BM25 on 11 of 15 datasets. It is competitive with BM25 on the remaining datasets except TREC-COVID and Touche-2020. Earlier unsupervised dense retrievers generally scored below BM25, and Contriever is ahead of them.

For nDCG@10, which rewards the first few ranked documents, the gap narrows but BM25 still leads. BM25 is clearly stronger on TREC-COVID and Touche-2020, and the authors link those gaps to properties of the datasets. Figure 1 shows the per-dataset Recall@100 for Contriever, BM25, REALM and SimCSE.

## Few-shot and MS MARCO fine-tuning

With small in-domain training sets of 729, 2,590 and 5,500 queries for SciFact, NFCorpus and FiQA, Contriever without MS MARCO reaches nDCG@10 of 84.0 on SciFact. BERT trained on the same SciFact set, without an intermediate step, reaches 75.2. Across the three datasets, Contriever scores 84.0, 33.6 and 36.4, against 66.5, 32.5 and 23.6 for BM25.

Used as pre-training before MS MARCO fine-tuning, Contriever raises the average Recall@100 over 14 BEIR datasets from 65.0 to 67.1, which the paper reports as state-of-the-art for Recall@100. The text does not name the system behind the 65.0 figure. Three datasets are left out of that average for licence reasons. The MS MARCO fine-tuning uses a simple negative mining strategy and no distillation.

On nDCG@10, Contriever after MS MARCO fine-tuning is the best of the dense bi-encoder methods. With a cross-encoder re-ranker, ms-marco-MiniLM-L-6-v2, it is state-of-the-art on 8 datasets for nDCG@10 and on average. The authors expect that borrowing improvements from other retrievers would help, but leave that outside this study.

## Which pre-training choices matter

Random cropping beats the inverse Cloze task here, with overall nDCG@10 of 32.2 against 25.9 without MS MARCO fine-tuning. The gap is largest on Quora, where cropping reaches 75.4 and the inverse Cloze task 27.6. The authors attribute part of the difference to cropping giving queries and keys the same distribution, which may make MoCo training more stable.

Adding random word deletion to cropping raises the overall score to 33.8.

With in-batch negatives and MoCo matched on the number of negatives, the AVG column gives 30.1 for MoCo and 31.9 for in-batch negatives. In-batch negatives are higher on NQ and Quora in that table, and the authors describe the difference as small. They keep MoCo because it allows more negatives without raising the batch size.

Varying the MoCo queue from 2,048 to 131,072 entries, more negatives generally improve BEIR retrieval, most clearly in the unsupervised setting. The effect is uneven across datasets. Figure 2 plots nDCG@10 against queue size for each dataset, with and without MS MARCO fine-tuning.

Pre-training on CCNet gives overall nDCG@10 of 34.9, Wikipedia gives 33.0, and the 50/50 mix gives 34.7. The authors see no clear winner between the sources: CCNet is stronger on FiQA and Quora, while Wikipedia is stronger on FEVER.

The authors conclude that most of the improvement over prior retrievers comes from contrastive pre-training rather than from the fine-tuning recipe.

## Multilingual and cross-lingual retrieval

mContriever is pre-trained on 29 languages from CCNet and starts from mBERT, which was trained on 104 languages. During pre-training, examples are sampled uniformly across languages, and the queue holds 32768 keys. Fine-tuning then uses MS MARCO, which is English-only supervision.

On Mr. TyDi, with MS MARCO fine-tuning, mContriever reaches average Recall@100 of 87.0, against 74.3 for BM25. The unsupervised mContriever alone reaches 77.2 average Recall@100, above BM25. On MRR@100, the unsupervised model averages 25.0 against 33.3 for BM25, and MS MARCO fine-tuning raises it to 38.4.

mBERT with the same MS MARCO recipe reaches 76.8 average Recall@100 on Mr. TyDi. Table 4 gives the per-language MRR@100 and Recall@100 values behind these averages.

The cross-lingual setting is derived from MKQA, which offers the same questions in 26 languages, and retrieval runs over English Wikipedia. The derived evaluation set has 6619 queries. With only English supervised data, mContriever fine-tuned on MS MARCO reaches average Recall@100 of 65.6 on this setting, against 59.8 for CORA. CORA is trained on different data, including NaturalQuestions and XOR-TyDi with translation-based augmentation, so this comparison mixes data and method.

Its unsupervised average Recall@100 is 49.2, and mBERT with MS MARCO fine-tuning reaches 57.9. Evaluation lowercases both queries and documents, which the authors observed to improve results.

## Limitations

On TREC-COVID, the authors link the gap to training data collected before the COVID outbreak. On Touche-2020, which contains long documents, dense retrievers lag behind BM25 even after supervised training. On MRR@100 for Mr. TyDi, unsupervised mContriever stays behind BM25, which the authors attribute to MRR@100 weighting the quality of the first retrieved documents.

The MKQA evaluation drops unanswerable, yes/no and long-answer questions, so it covers a narrower question set. The English retriever uses BERT base uncased, and larger backbones are not tested.

The unsupervised BEIR comparison in the text is given in Recall@100, while the unsupervised model still trails BM25 on nDCG@10. The main results rely on BM25 numbers quoted from other papers in the NaturalQuestions comparison.

## Paper info

- **Authors**: Gautier Izacard, Mathilde Caron, Lucas Hosseini, Sebastian Riedel, Piotr Bojanowski, Armand Joulin, Edouard Grave
- **Venue**: arXiv · Preprint
- **First published**: 2021-12-16
- **Added**: 2026-11-5
- **Updated**: 2022-8-29
- **Version**: v4
- **arXiv**: 2112.09118
- **Category**: cs.IR · cs.AI · cs.CL
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2112.09118v4) · [PDF ↗](https://arxiv.org/pdf/2112.09118v4)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

Recently, information retrieval has seen the emergence of dense retrievers, using neural networks, as an alternative to classical sparse methods based on term-frequency. These models have obtained state-of-the-art results on datasets and tasks where large training sets are available. However, they do not transfer well to new applications with no training data, and are outperformed by unsupervised term-frequency methods such as BM25. In this work, we explore the limits of contrastive learning as a way to train unsupervised dense retrievers and show that it leads to strong performance in various retrieval settings. On the BEIR benchmark our unsupervised model outperforms BM25 on 11 out of 15 datasets for the Recall@100. When used as pre-training before fine-tuning, either on a few thousands in-domain examples or on the large MS~MARCO dataset, our contrastive model leads to improvements on the BEIR benchmark. Finally, we evaluate our approach for multi-lingual retrieval, where training data is even scarcer than for English, and show that our approach leads to strong unsupervised performance. Our model also exhibits strong cross-lingual transfer when fine-tuned on supervised English data only and evaluated on low resources language such as Swahili. We show that our unsupervised models can perform cross-lingual retrieval between different scripts, such as retrieving English documents from Arabic queries, which would not be possible with term matching methods.

## Quote from the paper

Gautier Izacard, Mathilde Caron, Lucas Hosseini, Sebastian Riedel, Piotr Bojanowski, Armand Joulin, Edouard Grave (2021). Unsupervised Dense Information Retrieval with Contrastive Learning. arXiv:2112.09118v4. https://arxiv.org/abs/2112.09118v4

**BibTeX**

```
@misc{izacard2021unsupervised,
  title = {{Unsupervised Dense Information Retrieval with Contrastive Learning}},
  author = {Gautier Izacard and Mathilde Caron and Lucas Hosseini and Sebastian Riedel and Piotr Bojanowski and Armand Joulin and Edouard Grave},
  year = {2021},
  eprint = {2112.09118},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.09118v4}
}
```

## Other paper commentary

- [Dense Passage Retrieval for Open-Domain Question Answering](https://refivu.com/en/papers/c44c51e1-e59a-4cb6-8e94-20a4b572abc0-dense-passage-retrieval-for-open-domain-question-answering.md)
- [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://refivu.com/en/papers/569bb9ab-8345-4766-a539-e7ffb7b1754e-retrieval-augmented-generation-for-knowledge-intensive-nlp.md)
- [Adaptive-Elbow Graph Traversal for Schema Retrieval in Text-to-SQL](https://refivu.com/en/papers/1d3e708c-277f-497f-9bbf-8b12de718d99-adaptive-elbow-graph-traversal-for-schema-retrieval-in.md)
- [EchoSpec: Training Search Agents to Weigh Evidence Above Echoes](https://refivu.com/en/papers/22f39cf0-d41a-4695-8d6b-0d26df622012-echospec-training-search-agents-to-weigh-evidence-above.md)
- [UniGraph: A Unified Graph-based Index for Dynamic Hybrid Dense-Sparse Vector Retrieval](https://refivu.com/en/papers/a5ee1bb8-7883-49ee-91f4-322d407f8039-unigraph-a-unified-graph-based-index-for-dynamic.md)
- [CLEAR: Legible and Steerable Recommendation via Grounded Natural-Language Interests](https://refivu.com/en/papers/2fa163bb-6806-45fb-bf55-7e557d1f4855-clear-legible-and-steerable-recommendation-via-grounded.md)
- [InstructBLIP: Towards General-purpose Vision-Language Models with Instruction Tuning](https://refivu.com/en/papers/a16f8bfe-f6f1-4e2b-a409-c76d2ed97fc3-instructblip-towards-general-purpose-vision-language-models.md)
- [PandaLM: An Automatic Evaluation Benchmark for LLM Instruction Tuning Optimization](https://refivu.com/en/papers/2832dfcd-bd57-482f-9d55-f5bae8d2c8d2-pandalm-an-automatic-evaluation-benchmark-for-llm.md)
- [Chain-of-Thought Reasoning Without Prompting](https://refivu.com/en/papers/177d9294-679d-436b-897e-3ec239de41b5-chain-of-thought-reasoning-without-prompting.md)
- [Robotic Control via Embodied Chain-of-Thought Reasoning](https://refivu.com/en/papers/e0916502-601d-428e-90b1-cb59f1252a20-robotic-control-via-embodied-chain-of-thought-reasoning.md)
- [Neural Articulated Radiance Field](https://refivu.com/en/papers/aa604c2f-5450-4fe1-b81c-ff26130ee0b1-neural-articulated-radiance-field.md)
- [MERF: Memory-Efficient Radiance Fields for Real-time View Synthesis in Unbounded Scenes](https://refivu.com/en/papers/b88df5f3-e59a-4fcd-9cfd-d031cf876738-merf-memory-efficient-radiance-fields-for-real-time.md)

## Terms in this paper

- [contrastive learning](https://refivu.com/en/terms/180d2c06550d-contrastive-learning)
- [BM25](https://refivu.com/en/terms/64437f95755a-bm25)
- [InfoNCE](https://refivu.com/en/terms/9909993ddc7f-infonce)
- [in-batch negatives](https://refivu.com/en/terms/a4ee4e02506f-in-batch-negatives)
- [nDCG@10](https://refivu.com/en/terms/2d8a23b2a2b1-ndcg-10)
- [MoCo](https://refivu.com/en/terms/48667b2992b6-moco)
- [Contriever](https://refivu.com/en/terms/d8eaa624847e-contriever)
- [DPR](https://refivu.com/en/terms/f295583cf0b4-dpr)
- [MS MARCO](https://refivu.com/en/terms/ab0f27c3dce9-ms-marco)
- [BEIR benchmark](https://refivu.com/en/terms/e6ee1e396182-beir-benchmark)
- [CCNet](https://refivu.com/en/terms/a70c7050204f-ccnet)
- [Inverse Cloze Task](https://refivu.com/en/terms/6171a6819583-inverse-cloze-task)
- [mContriever](https://refivu.com/en/terms/41c5d6dc85e4-mcontriever)
- [MKQA](https://refivu.com/en/terms/0a2520c0a747-mkqa)
- [Recall@100](https://refivu.com/en/terms/e29b7411e648-recall-100)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/2fbce187-1a33-4d74-941c-36d004c9a79b-unsupervised-dense-information-retrieval-with-contrastive)
