Dense Passage Retrieval (DPR) is a neural retrieval architecture that trains two independent BERT-based encoders—one for questions and one for passages—to map text into a dense vector space where relevant query-document pairs have high cosine similarity. Unlike sparse methods like BM25, DPR captures semantic meaning beyond exact keyword overlap, enabling it to retrieve passages that answer a question even when they use entirely different terminology.
Glossary
Dense Passage Retrieval (DPR)

What is Dense Passage Retrieval (DPR)?
A foundational bi-encoder framework that uses in-batch negative sampling and contrastive learning to train a dual-encoder system specifically optimized for retrieving relevant text passages.
The framework is trained using a contrastive loss with in-batch negative sampling, where positive passages paired with a query are contrasted against all other passages in the training batch treated as negatives. This computationally efficient strategy allows DPR to learn high-quality dense representations without exhaustive negative mining, making it a foundational component in modern retrieval-augmented generation (RAG) architectures and semantic search systems.
Key Features of Dense Passage Retrieval
Dense Passage Retrieval (DPR) is a foundational dual-encoder framework that uses contrastive learning and in-batch negative sampling to train models specifically optimized for high-precision semantic passage retrieval.
Dual-Encoder Architecture
DPR employs a bi-encoder design with two independent BERT-based encoders: one for questions and one for passages. This separation allows passage embeddings to be pre-computed offline and indexed via FAISS, while only the query is encoded at runtime. This decoupling is the key to achieving sub-second latency on billion-scale corpora, as the computationally expensive passage encoding happens asynchronously during ingestion.
Contrastive Learning with In-Batch Negatives
DPR is trained using a contrastive loss function that maximizes the similarity between a question and its correct passage while minimizing similarity with all other passages in the batch. The critical innovation is in-batch negative sampling: every other passage in the training batch serves as a negative example for a given question. This technique dramatically increases training efficiency by reusing computed embeddings, eliminating the need for an external negative mining pipeline. The model learns fine-grained distinctions between topically similar but irrelevant passages.
Dot-Product Similarity Scoring
Unlike cross-encoders that require joint computation, DPR measures relevance using a simple dot product between the query vector and pre-computed passage vectors. This linear operation is the fastest similarity function available and is natively supported by Maximum Inner Product Search (MIPS) algorithms in FAISS. The dot product effectively captures directional alignment and magnitude, providing a strong signal for semantic relevance without the computational overhead of cosine normalization during retrieval.
Gold Passage Supervision
DPR training relies on supervised datasets where each question is paired with a single relevant 'gold' passage extracted from a larger document corpus like Wikipedia. The model is not trained to retrieve documents broadly but to pinpoint the exact passage span that answers the question. This fine-grained supervision teaches the encoder to distinguish between a document that merely mentions a topic and a passage that directly addresses the specific information need, significantly boosting precision@k metrics.
FAISS Index Integration
DPR is designed for tight integration with FAISS (Facebook AI Similarity Search) for production deployment. After offline batch vectorization, passage embeddings are loaded into a FAISS index—typically an IVFPQ or HNSW structure—that enables approximate nearest neighbor search with logarithmic time complexity. This allows DPR to scale to corpora containing billions of passages while maintaining retrieval latency suitable for real-time question answering systems.
Zero-Shot Cross-Domain Transfer
A DPR model trained on general-domain data like Natural Questions or TriviaQA exhibits strong zero-shot retrieval performance on unseen domains without fine-tuning. The dense representations capture transferable semantic patterns that generalize beyond the training distribution. This property makes DPR a practical off-the-shelf retriever for enterprise applications where labeled in-domain QA pairs are scarce, serving as a strong baseline before domain adaptation.
DPR vs. Traditional Retrieval Methods
A feature-level comparison of Dense Passage Retrieval against classic sparse lexical methods and early neural IR approaches.
| Feature | DPR (Bi-Encoder) | BM25 (Sparse) | Cross-Encoder Only |
|---|---|---|---|
Core Mechanism | Dual-encoder with dot-product similarity over dense vectors | Term-frequency inverse-document frequency with exact lexical matching | Joint query-document encoding with full attention interaction |
Semantic Understanding | |||
Handles Synonyms & Paraphrases | |||
Pre-computable Document Index | |||
Query Latency (10M docs) | < 50 ms | < 10 ms |
|
Training Data Required | Large-scale query-passage pairs with hard negatives | None (unsupervised) | Large-scale relevance-judged pairs |
Exact Keyword Match Precision | |||
Scalability to Billions of Docs |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
Clear, technical answers to the most common questions about the bi-encoder architecture, training methodology, and production deployment of Dense Passage Retrieval systems.
Dense Passage Retrieval (DPR) is a bi-encoder neural architecture that maps both queries and text passages into a shared, continuous vector space where semantic similarity is measured by dot product or cosine similarity. Unlike sparse retrieval methods like BM25 that rely on exact term matching, DPR uses two independent BERT-based encoders—a query encoder and a passage encoder—to generate dense embeddings. At retrieval time, the query is encoded once, and the system performs an Approximate Nearest Neighbor (ANN) search over a pre-computed index of passage embeddings to find the top-k most semantically relevant results. This separation allows passage embeddings to be computed offline, making real-time retrieval feasible even over millions of documents. The architecture's core innovation is its training methodology, which uses in-batch negative sampling and a contrastive loss function to teach the model that a query's embedding should be closer to its positive passage than to any negative passage in the training batch.
Related Terms
Core architectural components and complementary techniques that form the foundation of modern bi-encoder retrieval systems.
Bi-Encoder Architecture
The dual-tower neural architecture that independently encodes queries and passages into separate dense vectors. Unlike cross-encoders, bi-encoders allow pre-computation of passage embeddings offline, enabling fast approximate nearest neighbor (ANN) lookups at query time. The trade-off is reduced interaction-based precision since the query and passage never attend to each other directly during encoding. DPR uses two independent BERT-based encoders—one for queries, one for passages—trained with contrastive learning to pull relevant pairs together and push irrelevant pairs apart in the shared vector space.
In-Batch Negative Sampling
A training efficiency technique where other passages in the same mini-batch serve as negative examples for each query, rather than requiring explicit negative mining. For a batch of B query-passage pairs, each query gets 1 positive passage and B-1 negatives. This dramatically increases the number of training examples without additional computation. DPR's original implementation used gold passages from the same batch as negatives, creating a more challenging training signal than random negatives. The technique requires large batch sizes—often 128 or more—to provide sufficient negative diversity.
Contrastive Loss Function
The mathematical objective that drives DPR training by maximizing the similarity between a query and its correct passage while minimizing similarity with all negatives. DPR typically uses InfoNCE loss (a variant of noise contrastive estimation):
- Computes cosine similarity between query embedding and all passage embeddings in the batch
- Applies softmax over similarity scores to produce a probability distribution
- Minimizes negative log-likelihood of the correct passage
The temperature parameter controls how sharply the model penalizes hard negatives—lower temperatures create stricter separation.
Passage Indexing and FAISS
Once trained, the passage encoder generates embeddings for the entire corpus offline. These vectors are stored in FAISS (Facebook AI Similarity Search), which provides GPU-accelerated indexing for billion-scale collections. FAISS supports multiple index types:
- IndexFlatIP: Exact inner product search, 100% recall but slow
- IndexIVFPQ: Inverted file with product quantization, trading accuracy for speed
- IndexHNSW: Graph-based navigation for logarithmic-time search
DPR's separation of encoding from indexing means passage embeddings can be updated incrementally without retraining the query encoder.
Hybrid Retrieval Integration
DPR's dense vectors are often combined with BM25 sparse retrieval in a hybrid system to capture both semantic meaning and exact keyword matches. The fusion typically uses:
- Reciprocal Rank Fusion (RRF): Combines ranked lists without requiring score calibration
- Linear interpolation: Weighted sum of normalized dense and sparse scores
- Re-ranking pipeline: DPR retrieves top-K candidates, then a cross-encoder refines the final order
This addresses DPR's known weakness with rare entities and exact phrase matching, where lexical methods like BM25 excel.
Training Data Requirements
DPR requires supervised query-passage pairs for effective training, typically sourced from:
- MS MARCO: Microsoft's large-scale reading comprehension dataset with real Bing queries
- Natural Questions: Google queries paired with Wikipedia passages containing answers
- TREC CAR: Synthetic queries generated from Wikipedia section headings
- Domain-specific logs: Click-through data from production search systems
Data quality is critical—DPR trained on mismatched or noisy pairs will learn poor representations. Hard negative mining, where negatives are chosen to be top-ranked by a baseline retriever, significantly improves model robustness.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us