Inferensys

Glossary

Dense Passage Retrieval (DPR)

A bi-encoder architecture that independently encodes queries and documents into dense vector representations, enabling efficient semantic similarity search via approximate nearest neighbor lookup for open-domain question answering.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
BI-ENCODER ARCHITECTURE

What is Dense Passage Retrieval (DPR)?

Dense Passage Retrieval (DPR) is a neural retrieval architecture that uses two independent BERT-based encoders to map queries and text passages into a shared dense vector space, where semantic similarity is computed via dot product for efficient open-domain question answering.

Dense Passage Retrieval (DPR) is a bi-encoder architecture that independently encodes queries and documents into dense, fixed-length vector representations using dual BERT models. Unlike sparse lexical methods such as BM25, DPR captures semantic meaning beyond exact keyword overlap by training on question-passage pairs with in-batch negative sampling, enabling retrieval of relevant documents even when they share no common terminology with the query.

During inference, all passages in a corpus are pre-encoded offline into a dense index. At query time, only the query encoder runs, and the resulting vector is compared against the index using approximate nearest neighbor (ANN) search—typically via FAISS—to retrieve the top-k most semantically similar passages. This decoupled architecture makes DPR highly scalable for open-domain question answering, though it sacrifices the fine-grained token-level interactions that cross-encoder reranking stages later recover.

ARCHITECTURAL COMPONENTS

Key Features of Dense Passage Retrieval

Dense Passage Retrieval (DPR) is a bi-encoder architecture that independently encodes queries and passages into dense vector representations, enabling efficient semantic similarity search via approximate nearest neighbor (ANN) lookup. The following cards break down its core mechanisms and design principles.

01

Dual-Tower Bi-Encoder Architecture

DPR uses two independent BERT-based encoders: a query encoder and a passage encoder. This separation allows all passages in the corpus to be encoded offline into a static vector index. At query time, only the query is encoded, and its vector is used to search the pre-computed index via cosine similarity or inner product. This is fundamentally different from cross-encoders, which require processing the concatenated query-passage pair for every candidate, making them computationally prohibitive for first-pass retrieval over millions of documents.

O(1) query encoding
Online Compute Cost
65M+
Passages Indexed Offline
02

Contrastive In-Batch Negative Training

DPR is trained using a contrastive loss with in-batch negatives. For each relevant query-passage pair in a training batch, all other passages in that same batch are treated as negative examples. This is computationally efficient because it reuses the passage embeddings already computed for the batch. The model is optimized to maximize the similarity between the query and its positive passage while minimizing similarity with all negatives. Hard negative mining—adding high-BM25-scoring but irrelevant passages—is critical for teaching the model fine-grained semantic distinctions.

N-1 negatives/batch
Training Efficiency
03

ANN Indexing with FAISS

Once all passages are encoded into dense vectors, they are indexed using Facebook AI Similarity Search (FAISS) for efficient approximate nearest neighbor search. DPR typically uses Hierarchical Navigable Small World (HNSW) graphs or Inverted File with Product Quantization (IVFPQ) to compress vectors and accelerate retrieval. This enables sub-linear search time over billion-scale corpora, trading a small amount of accuracy for massive speed gains. The index can be stored entirely in memory or on disk with memory-mapped files.

< 50ms
Retrieval Latency per Query
99.9% recall@100
ANN Accuracy
04

Complementarity with Sparse Retrieval

DPR excels at semantic matching—finding passages that answer a question using different vocabulary than the query. However, it can struggle with precise lexical matches like rare entity names or numbers. This is why DPR is most powerful when combined with BM25 or learned sparse retrieval in a hybrid system. The two methods retrieve different result sets with high complementarity, and their outputs are fused using Reciprocal Rank Fusion (RRF) or weighted sum fusion to maximize overall recall.

+19%
Top-20 Accuracy vs BM25 Alone
05

Asymmetric Dataset Design

DPR training requires a specific dataset structure: natural questions paired with positive passages containing the answer span. The original DPR paper used datasets like Natural Questions, TriviaQA, and SQuAD. Critically, the positive passage is the one actually containing the answer, not just a top-ranked BM25 result. This ensures the model learns to retrieve passages that genuinely answer the question, not just those that are topically related. Negative passages are sampled from top BM25 results that do not contain the answer.

60k+
Training Questions (NQ)
06

Dot Product vs. Cosine Similarity Scoring

During inference, similarity between the query vector and passage vectors is computed using either dot product or cosine similarity. DPR is typically trained with dot product, which is faster to compute and works well when vectors are L2-normalized. Cosine similarity is equivalent to dot product on normalized vectors. The choice affects ANN index configuration: FAISS supports both inner product search and L2 distance search, with inner product being the direct implementation of dot product scoring.

768
Typical Embedding Dimension
RETRIEVAL ARCHITECTURE COMPARISON

DPR vs. Sparse Retrieval vs. Cross-Encoder

A technical comparison of three core retrieval and scoring paradigms for answer engine pipelines.

FeatureDense Passage Retrieval (DPR)Sparse Retrieval (BM25)Cross-Encoder

Architecture

Bi-Encoder (Dual-Tower)

Bag-of-Words / Inverted Index

Cross-Encoder (Single-Tower)

Query-Document Interaction

Late Interaction (Cosine Similarity)

Exact Term Matching

Early/Full Interaction (Concatenated Input)

Indexing Speed

Slow (Requires Neural Encoding)

Fast (Tokenization & Postings)

N/A (No Pre-indexing)

Online Retrieval Speed

Fast (ANN Search)

Very Fast (Inverted Index Lookup)

Very Slow (Re-encodes Query-Doc Pairs)

Semantic Understanding

Handles Vocabulary Mismatch

Handles Exact Term/Rare Entity Match

Score Calibration

Uncalibrated Dot Product

Probabilistic (TF-IDF Derived)

Calibrated Relevance Score

DENSE PASSAGE RETRIEVAL

Frequently Asked Questions

Clear, technical answers to the most common questions about the bi-encoder architecture powering modern semantic search and open-domain question answering.

Dense Passage Retrieval (DPR) is a bi-encoder neural architecture that independently encodes queries and text passages into dense, low-dimensional vector representations, enabling efficient semantic similarity search via approximate nearest neighbor (ANN) lookup. Unlike sparse lexical methods like BM25 that rely on exact term matching, DPR captures deep semantic relationships. The architecture uses two separate BERT-based encoders: a query encoder and a passage encoder. During training, the model is optimized using a contrastive loss function with in-batch negatives, maximizing the dot-product similarity between a question and its relevant passage while minimizing it for all other passages in the batch. At inference time, all passages in the corpus are pre-encoded offline into a vector index. A user query is then encoded on-the-fly, and the top-k passages with the highest cosine similarity are retrieved, typically using an algorithm like Hierarchical Navigable Small World (HNSW) for sub-linear search speed. This decoupling of encoding from search is what makes DPR scalable to millions of documents while maintaining sub-100ms latency.

Prasad Kumkar

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.