Dense passage retrieval (DPR) is a neural retrieval method that encodes questions and text passages into dense vectors with two separately trained encoders and returns the passages whose vectors have the highest similarity to the question vector. In artificial intelligence, and especially in retrieval & knowledge systems, DPR showed that learned embeddings can outperform BM25 for open-domain question answering, and it became the template for the retriever stage in many RAG pipelines.
The method was introduced by researchers at Facebook AI in 2020. The name refers both to the general technique and to the specific DPR model and training recipe, which used BERT encoders, Wikipedia passages and in-batch negatives to learn what a relevant answer passage looks like.
How dense passage retrieval encodes and matches text
DPR uses a bi-encoder architecture: one encoder maps a question to a vector, and a second encoder maps each passage to a vector of the same size. In the original model, both encoders are BERT-base networks, and the 768-dimensional representation of the [CLS] token serves as the embedding. Relevance is scored with a simple dot product between the two vectors.
Because the encoders are independent, every passage in the corpus can be encoded once offline and stored in a vector index. At query time, only the question needs encoding, and an approximate nearest neighbor search over the index returns the top-k passages in milliseconds. This separation is what makes DPR practical at the scale of millions of passages.
The original pipeline has three distinct stages, summarized below with the components used in the reference implementation.
| Stage | When it runs | Reference component |
|---|---|---|
| Passage encoding | Offline, once per corpus | BERT passage encoder |
| Indexing | Offline, after encoding | FAISS vector index |
| Question encoding | Online, per query | BERT question encoder |
| Similarity search | Online, per query | Maximum inner product search |
| Reading or generation | Online, after retrieval | Extractive reader or generator model |
Training with in-batch and hard negatives
DPR is trained with a contrastive objective that pulls a question toward its positive passage and pushes it away from negative passages. The loss is the negative log-likelihood of the positive passage under a softmax over the scores of all candidates in the training batch.
The key efficiency trick is in-batch negatives: the positive passages of the other questions in the same batch serve as negatives, so a batch of B questions yields B × B comparisons almost for free. The authors added one hard negative per question, a passage ranked highly by BM25 that does not contain the answer, which teaches the model to reject passages that merely share keywords.
| Setting | Typical value | Effect on the model |
|---|---|---|
| Passage length | 100 words | Uniform units for retrieval and reading |
| Corpus size | About 21 million passages | Full English Wikipedia coverage |
| Embedding size | 768 dimensions | Expressive vectors, large index |
| Batch size | 128 questions | More in-batch negatives per step |
| Hard negatives | One BM25 passage per question | Better rejection of lexical decoys |
Later work refined this recipe with mined hard negatives from the dense model itself, distillation from cross-encoders and large-scale pretraining on question-passage pairs, but the basic contrastive setup remains the same.
Dense passage retrieval compared with other retrievers
DPR is the best-known example of dense retrieval, which contrasts with sparse and late-interaction approaches. Each family makes a different trade-off between semantic matching, exact term matching, index size and latency.
| Method | Representation | Strength | Weakness |
|---|---|---|---|
| BM25 | Sparse term weights | Exact names, codes and rare words | Misses paraphrases and synonyms |
| DPR | One dense vector per text | Semantic and paraphrase matching | Weak on rare entities and new domains |
| ColBERT | Many vectors per text | Fine-grained token matching | Much larger index |
| SPLADE | Learned sparse weights | Inverted index with expansion | More complex training |
| Cross-encoder | Joint question-passage encoding | Highest ranking accuracy | Too slow for first-stage search |
On the Natural Questions benchmark, the original DPR reached about 78% top-20 accuracy, compared with about 59% for BM25, meaning the answer appeared in the top 20 passages far more often. On SQuAD, where questions were written while viewing the passage and share many words with it, BM25 remained stronger, which illustrates where lexical overlap still matters.
Using DPR in retrieval-augmented systems
In modern RAG systems, DPR-style bi-encoders form the first-stage retriever that narrows a large corpus to a few dozen candidates. A reranker or the language model then works only on that shortlist. The decision table below shows how practitioners typically configure the retriever.
| Situation | Recommended choice | Reason |
|---|---|---|
| Many product codes or names | Hybrid search with BM25 | Dense vectors blur exact strings |
| Specialized domain text | Fine-tune on in-domain pairs | Off-the-shelf models generalize poorly |
| Precision matters most | Add a cross-encoder reranker | Rescores the top candidates jointly |
| Very large corpus | Quantized ANN index | Cuts memory and latency |
| Frequent content updates | Re-encode only changed passages | Avoids full index rebuilds |
Index memory is a practical concern: 21 million passages with 768-dimensional float32 vectors need roughly 60 GB before compression. Product quantization or binary embeddings reduce this substantially at a modest cost in recall.
Limitations and failure modes
- Poor out-of-domain generalization. DPR trained on Wikipedia questions often underperforms BM25 on benchmarks such as BEIR.
- Weakness on rare entities. Unusual names, numbers and identifiers are compressed poorly into a single vector.
- Fixed passage boundaries. Answers split across two 100-word chunks may never be retrieved together.
- Re-encoding cost. Changing the passage encoder requires recomputing every vector in the index.
These limits explain why production systems rarely rely on dense retrieval alone. Hybrid search, reranking and domain fine-tuning address most of them, while the core DPR idea of encoding text into comparable vectors stays at the center of semantic search.
In everyday language
Dense passage retrieval is a way to find text by meaning, not by exact words. The system turns every question and every paragraph into a list of numbers. Similar meanings get similar numbers.
Imagine a librarian who understands what a question means. Ask about the tallest mountain, and the librarian also brings pages about Everest, even if the word tallest never appears. That is the core idea: match ideas, not just words.
Seen in the real world
A support team at a software company maintains about 40,000 help articles, split into roughly 300,000 short passages. Customers often describe problems in their own words, such as “the app forgets my login,” while the articles say “session token expiration.” Keyword search returns poor results for these questions.
The team fine-tunes a DPR-style bi-encoder on 20,000 historical pairs of customer questions and the articles that solved them. Passages are encoded overnight and stored in an approximate nearest neighbor index, and each incoming question is matched within about 50 milliseconds. A cross-encoder reranks the top 20 results before a language model drafts the answer.
The outcome is noticeably better answer coverage for paraphrased questions. The team keeps BM25 in a hybrid setup, however, because queries containing error codes such as E4031 still match more reliably by exact keywords.