# Dense Passage Retrieval for Open-Domain Question Answering

Karpukhin, Vladimir, Oğuz, Barlas, Min, Sewon, Lewis, Patrick, Wu, Ledell, Edunov, Sergey and 2 more · arXiv · 2020-4-10

- **Problem** Term-matching retrievers such as BM25 miss paraphrases, and earlier dense retrievers for open-domain QA needed an extra pretraining stage before they could beat BM25.
- **Method** Trains a question encoder and a passage encoder, both BERT-based, on question-passage pairs alone, scoring pairs by dot product and sharing gold passages within each mini-batch as negatives, with one BM25 negative per question.
- **Results** Reached 78.4 top-20 retrieval accuracy on the Natural Questions test set for single-dataset DPR, against 59.1 for BM25.

## Why term matching limits open-domain QA

Open-domain QA is usually built as two stages: a retriever narrows a large corpus to a small set of passages, and a reader extracts the answer from that set. Accuracy suffers when the setting moves from a given paragraph to an open corpus. In one cited case, SQuAD v1.1 exact match falls from over 80% to under 40% in the open setting, which the authors take as a reason to improve retrieval.

Term-matching rankers such as BM25 score passages by shared keywords, so a question asking about the bad guy can miss a passage that calls the same character the villain.

Dense encoders can match such paraphrases, can be trained for the task, and can be searched at scale with maximum inner product search. The obstacle the authors point to is data: learning a good dense representation is widely believed to need a large number of labeled question-context pairs. ORQA was the first dense retriever shown to beat BM25 for open-domain QA, but it relied on an inverse cloze task pretraining stage before fine-tuning on question-answer pairs.

The authors name two weaknesses in that design: the pretraining is computationally heavy, and ordinary sentences may be poor stand-ins for questions; the context encoder also never sees question-answer pairs during training, so its representations may be suboptimal. This raises the study's question: can a stronger dense model be trained from question-passage pairs alone, starting from standard BERT and a dual-encoder design, with no extra pretraining?

The authors answer yes. Fine-tuning both encoders on existing pairs is enough to greatly outperform BM25, and a higher retrieval precision carries over to higher end-to-end QA accuracy.

## How questions and passages become vectors

Each Wikipedia article is cut into disjoint blocks of 100 words, and each block is prefixed with its article title and a \[SEP\] token, which gives 21,015,324 passages. A retriever maps a question and the collection of M passages to a much smaller set CF, where k is far below the corpus size, and k is usually 20 to 100 in this work.

DPR uses two encoders: EP maps each passage to a d-dimensional real vector, and EQ maps the question to a vector of the same dimension. The passage encoder runs over the whole corpus ahead of time, while the question encoder runs only when a question arrives. The score is the dot product of the two vectors, \\(\\mathrm{sim}(q,p)=E\_Q(q)^{\\top}E\_P(p)\\), and the authors keep the score decomposable so that passage vectors can be precomputed; cross-attention scorers are excluded from first-stage retrieval for the same reason.

Both encoders are separate BERT base uncased networks, and each vector is the \[CLS\] representation, so d is 768. At query time the question vector is matched against the passage vectors in an offline FAISS index, and the top k passages go to the reader.

## Training with in-batch negatives

Training is framed as metric learning: a question should be closer to its relevant passage than to the irrelevant ones. Each instance has one question, one positive passage and n negative passages. The loss is the negative log of the softmax probability of the positive score among all scores, \\\[L = -\\log \\frac{e^{\\mathrm{sim}(q\_i,p\_i^{+})}}{e^{\\mathrm{sim}(q\_i,p\_i^{+})}+\\sum\_{j=1}^{n}e^{\\mathrm{sim}(q\_i,p\_{i,j}^{-})}}\\\] and minimizing it raises the positive score relative to the negatives.

Positives are given by the dataset, but the negatives must be chosen from a very large pool, so the choice of negatives matters. Three sources are compared: random passages, BM25 passages that lack the answer but match many question tokens, and gold passages that belong to other questions. The best model uses the gold passages from the same mini-batch plus one BM25 negative per question, because reusing batch passages keeps the computation cheap.

With B questions in a batch, the question matrix Q and passage matrix P (each B by d) give a B by B score matrix \\(S = QP^{\\top}\\), where each row is a question scored against all B passages. The diagonal pairs are positives and the rest are negatives, so each batch yields B training instances with B-1 negatives per question while covering B squared pairs.

Sharing the batch this way has precedent in full-batch training (Yih et al., 2011) and in mini-batch training (Henderson et al., 2017; Gillick et al., 2019).

## Datasets and how positive passages are chosen

Five QA datasets are used: Natural Questions, TriviaQA, WebQuestions, CuratedTREC and SQuAD v1.1, following the same splits as earlier work. The datasets differ in origin: Natural Questions uses real search queries with answers as spans in Wikipedia, while TriviaQA answers come from the Web, WebQuestions answers are Freebase entities, and CuratedTREC draws on TREC tracks and Web sources.

SQuAD is kept for comparison but is a weaker fit, because annotators wrote questions after reading a paragraph, so many questions lack context without it.

TREC, WebQuestions and TriviaQA give only question-answer pairs, so the highest-ranked BM25 passage that contains the answer becomes the positive, and a question is discarded when none of the top 100 passages contains the answer. For SQuAD and Natural Questions, the gold passage is matched to the corresponding passage in the candidate pool, and questions whose match fails because of different Wikipedia versions or preprocessing are dropped.

Using gold contexts instead of answer-containing passages gives only a small improvement, according to the authors' note.

Table 1 lists training, development and test counts for each dataset, along with the training questions that remain after filtering.

## Top-k accuracy against BM25

Multi-dataset DPR pools all datasets except SQuAD, and the hybrid rescoring combines BM25 and DPR scores as \\(\\mathrm{BM25}(q,p)+\\lambda\\cdot\\mathrm{sim}(q,p)\\) with \\(\\lambda = 1.1\\) tuned on development data.

On Natural Questions, top-20 accuracy goes from 59.1 for BM25 to 78.4 for single DPR, and top-100 from 73.7 to 85.4. The same pattern holds on TriviaQA (66.9 to 79.4 at top-20), WebQuestions (55.0 to 73.2) and CuratedTREC (70.9 to 79.8).

Multi-dataset training changes these numbers unevenly: CuratedTREC top-20 rises from 79.8 to 89.1, while TriviaQA drops slightly from 79.4 to 78.8 for multi-dataset DPR, and Natural Questions moves from 78.4 to 79.4. Combining with BM25 helps on SQuAD (71.5 against 63.2 for single DPR at top-20) and lowers Natural Questions top-20 from 78.4 to 76.6.

SQuAD is the exception: single DPR reaches 63.2 at top-20 against 68.8 for BM25, and multi-dataset DPR reaches 51.6. The authors attribute this to high lexical overlap between SQuAD questions and passages, which favors BM25, and to training questions drawn from a small set of Wikipedia articles, which they say makes the training distribution biased.

## Sample size and negative choices

Figure 1 shows top-k accuracy on the Natural Questions development set for DPR trained with 1k, 10k, 20k, 40k and all 59k examples, against BM25 across k from 20 to 100. DPR trained on 1,000 examples already outperforms BM25, and accuracy keeps improving as training grows to 59k examples. The authors read this as evidence that a general pretrained language model makes a small set of question-passage pairs enough.

Table 3 compares training schemes on the Natural Questions development set at top-5, top-20 and top-100. In the standard 1-of-N setting, the choice of negatives (random, BM25 or gold) changes top-k accuracy little once k is 20 or more, with top-20 at 64.3, 63.3 and 63.1.

The batch size matters too: with gold in-batch negatives top-20 is 70.8 at 31 negatives and 73.0 at 127. Adding one BM25 negative shared across the batch raises top-20 accuracy to 77.3 at 31 gold negatives, and two BM25 negatives give 76.4, so the authors find that a second one does not help. With 127 gold negatives and one BM25 negative, top-20 reaches 78.0.

## Similarity functions and transfer to other datasets

Euclidean L2 distance was tested as an alternative similarity along with cosine similarity, and triplet loss was tested in place of negative log likelihood. L2 performs comparably to dot product, and both beat cosine; triplet loss does not change the results much.

To test transfer, DPR was trained on Natural Questions only and applied directly to WebQuestions and CuratedTREC without further fine-tuning. Top-20 accuracy is 69.9 on WebQuestions and 86.3 on CuratedTREC, against 75.0 and 89.1 for the best fine-tuned models, a loss of 3 to 5 points. Even so, these transferred scores remain above BM25's 55.0 and 70.9 on the same two sets.

## Query speed against index build cost

On a single server with an Intel Xeon CPU E5-2698 v4 at 2.20GHz and 512GB of memory, DPR with an in-memory FAISS index processes 995.0 questions per second and returns the top 100 passages for each. BM25 with Lucene, implemented in Java with a file index, processes 23.7 questions per second per CPU thread. The two setups differ in index type and in how throughput is counted, so the gap is indicative rather than a controlled comparison.

Embedding the 21 million passages takes about 8.8 hours on 8 GPUs, and building the FAISS index on one server takes 8.5 hours. Building a Lucene inverted index for the same collection takes about 30 minutes in total. The FAISS index is an HNSW index on CPU with 512 neighbors per node, a construction-time search depth of 200 and a search depth of 128.

## The neural reader and its training

Each passage is encoded by BERT base uncased as \\(P\_i \\in \\mathbb{R}^{L\\times h}\\), where L is the maximum passage length and h the hidden dimension.

Start and end probabilities are computed as \\\[P\_{\\mathrm{start},i}(s)=\\mathrm{softmax}(P\_i w\_{\\mathrm{start}})\_s\\\] and \\\[P\_{\\mathrm{end},i}(t)=\\mathrm{softmax}(P\_i w\_{\\mathrm{end}})\_t\\\], with learnable vectors \\(w\_{\\mathrm{start}}\\) and \\(w\_{\\mathrm{end}}\\). Passage selection uses the \[CLS\] representations of the k passages, \\(\\hat{P}=\[P^{\[CLS\]}\_1,\\dots,P^{\[CLS\]}\_k\]\\), through \\(P\_{\\mathrm{selected}}(i)=\\mathrm{softmax}(\\hat{P}^{\\top}w\_{\\mathrm{selected}})\_i\\).

A span from word s to word t in passage i is scored by \\(P\_{\\mathrm{start},i}(s)\\times P\_{\\mathrm{end},i}(t)\\), and the passage is scored by \\(P\_{\\mathrm{selected}}(i)\\).

The objective maximizes the marginal log-likelihood of all correct spans in the positive passage together with the log-likelihood of selecting that passage, and the batch size is 16 for large datasets and 4 for small ones.

## End-to-end exact match

Table 4 reports exact match after minor normalization, and its first block of results is copied from the cited papers. On Natural Questions, single DPR scores 41.5, against 32.6 for BM25 with the same reader and 33.3 for ORQA. On TriviaQA, WebQuestions, CuratedTREC and SQuAD, single DPR scores 56.8, 34.6, 25.9 and 29.8, against 52.4, 29.9, 24.9 and 38.1 for BM25.

Multi-dataset DPR reaches 42.4 on WebQuestions and 49.4 on CuratedTREC, and multi-dataset hybrid DPR reaches 50.6 on CuratedTREC. Large datasets perform about the same with single and multi training, while the smaller WebQuestions and CuratedTREC sets gain clearly from multi-dataset training.

The authors state that higher retriever accuracy typically leads to better final QA, and that in all cases except SQuAD, answers from DPR passages are more likely to be correct than those from BM25. DPR-based models outperform the previous best results on four of the five datasets, with 1% to 12% absolute differences in exact match. On Natural Questions, the 41.5 exact match of DPR exceeds the 39.2 and 40.4 reported for the two REALM variants in Table 4.

ORQA and REALM both add pretraining tasks and end-to-end training, while DPR beats them on Natural Questions and TriviaQA using only question-answer pairs. The authors suggest that extra pretraining is more useful when the target training sets are small.

## Joint training and the number of passages

Jointly training the retriever and reader on Natural Questions gives 39.8 exact match. The authors read this as showing that training retriever and reader separately can use the available supervision effectively, and that this pipeline is competitive with a joint approach with a simpler design.

The reader fits all 100 passages into one batch on a single 32GB GPU, so latency stays close to the single-passage case, around 20ms. ORQA uses passages of 288 word pieces, against DPR's 100 tokens, and reader complexity grows super-linearly with passage length.

On Natural Questions, k = 50 is reported as optimal, and k = 10 gives 40.8 exact match against 41.5. The authors note that k = 10 is roughly comparable to ORQA's 5-passage setup.

## Limitations

On SQuAD, BM25 beats single DPR at top-20 (68.8 against 63.2), and the authors attribute this to lexical overlap and a small set of Wikipedia articles. Single DPR also trails the other systems on WebQuestions and CuratedTREC in the single-dataset end-to-end setting, which the authors say improves with more question-answer pairs.

Dense index construction is expensive, with 8.8 hours of GPU embedding and 8.5 hours of FAISS indexing for 21 million passages, while Lucene needs about 30 minutes. The cross-dataset transfer was checked only on WebQuestions and CuratedTREC, from a model trained on Natural Questions.

The joint-training result is a single run on Natural Questions only.

## Paper info

- **Authors**: Karpukhin, Vladimir, Oğuz, Barlas, Min, Sewon, Lewis, Patrick, Wu, Ledell, Edunov, Sergey, Chen, Danqi, Yih, Wen-tau
- **Venue**: arXiv · Preprint
- **First published**: 2020-4-10
- **Added**: 2026-10-20
- **Updated**: 2020-9-30
- **Version**: v3
- **arXiv**: 2004.04906
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

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

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.

## Quote from the paper

Karpukhin, Vladimir, Oğuz, Barlas, Min, Sewon, Lewis, Patrick, Wu, Ledell, Edunov, Sergey, Chen, Danqi, Yih, Wen-tau (2020). Dense Passage Retrieval for Open-Domain Question Answering. arXiv:2004.04906v3. https://arxiv.org/abs/2004.04906v3

**BibTeX**

```
@misc{vladimir2020dense,
  title = {{Dense Passage Retrieval for Open-Domain Question Answering}},
  author = {Karpukhin, Vladimir and Oğuz, Barlas and Min, Sewon and Lewis, Patrick and Wu, Ledell and Edunov, Sergey and Chen, Danqi and Yih, Wen-tau},
  year = {2020},
  eprint = {2004.04906},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2004.04906v3}
}
```

## Other paper commentary

- [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)
- [StreamEmbed: Real-Time Indexing from Pixels for Screenshot Retrieval](https://refivu.com/en/papers/62997798-538e-4c46-9f02-24c435620ff4-streamembed-real-time-indexing-from-pixels-for-screenshot.md)
- [ZeRO: Memory Optimizations Toward Training Trillion Parameter Models](https://refivu.com/en/papers/30a4fae5-65d8-4fa2-8552-c186c4a4d88f-zero-memory-optimizations-toward-training-trillion-parameter.md)
- [Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation](https://refivu.com/en/papers/16116a1b-83a4-4d2d-b5ff-31f5b005ba3f-train-short-test-long-attention-with-linear-biases.md)
- [LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale](https://refivu.com/en/papers/263598fd-8186-4bb8-858a-0eba8ecdb369-llm-int8-8-bit-matrix-multiplication-for-transformers.md)
- [SQuAD: 100,000+ Questions for Machine Comprehension of Text](https://refivu.com/en/papers/b88d7f5b-b008-4a74-a452-4513427bbf9f-squad-100-000-questions-for-machine-comprehension-of.md)
- [mixup: Beyond Empirical Risk Minimization](https://refivu.com/en/papers/cc1e3261-af7e-47fa-99d8-0806fbe6afcf-mixup-beyond-empirical-risk-minimization.md)
- [Rethinking the Inception Architecture for Computer Vision](https://refivu.com/en/papers/5a8c1d5f-a10c-4a76-a110-b62861a7dc8a-rethinking-the-inception-architecture-for-computer-vision.md)

## Terms in this paper

- [BERT](https://refivu.com/en/terms/45b639a1d317-bert)
- [cosine similarity](https://refivu.com/en/terms/3baa01a8760d-cosine-similarity)
- [exact match](https://refivu.com/en/terms/f6e0295e5c92-exact-match)
- [TriviaQA](https://refivu.com/en/terms/d04d9611868e-triviaqa)
- [Triplet loss](https://refivu.com/en/terms/6b3cf5362b16-triplet-loss)
- [Wikipedia](https://refivu.com/en/terms/2569175e3d90-wikipedia)
- [BM25](https://refivu.com/en/terms/64437f95755a-bm25)
- [negative log likelihood](https://refivu.com/en/terms/339ecb7aa325-negative-log-likelihood)
- [in-batch negatives](https://refivu.com/en/terms/a4ee4e02506f-in-batch-negatives)
- [Natural Questions](https://refivu.com/en/terms/2053f89c9387-natural-questions)
- [open-domain question answering](https://refivu.com/en/terms/b846fb1506b3-open-domain-question-answering)
- [Euclidean distance](https://refivu.com/en/terms/d709f3cd41c0-euclidean-distance)
- [WebQuestions](https://refivu.com/en/terms/4353621a1edb-webquestions)
- [CuratedTrec](https://refivu.com/en/terms/ecfe7ea6b792-curatedtrec)
- [dual-encoder architecture](https://refivu.com/en/terms/53e06f67a0a4-dual-encoder-architecture)
- [FAISS](https://refivu.com/en/terms/71e40b3935f9-faiss)
- [Inverse Cloze Task](https://refivu.com/en/terms/6171a6819583-inverse-cloze-task)
- [maximum inner product search](https://refivu.com/en/terms/eb67006577a0-maximum-inner-product-search)
- [REALM](https://refivu.com/en/terms/50d293e242cc-realm)
- [SQuAD v1.1](https://refivu.com/en/terms/c22da75b31f9-squad-v1-1)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/c44c51e1-e59a-4cb6-8e94-20a4b572abc0-dense-passage-retrieval-for-open-domain-question-answering)
