Inferensys

Glossary

Dense Passage Retrieval (DPR)

A dual-encoder framework trained to retrieve relevant knowledge base passages or entity descriptions by maximizing the inner product of query and context embeddings.
Knowledge engineer constructing knowledge base on laptop, document hierarchy visible, casual office setup.
INFORMATION RETRIEVAL

What is Dense Passage Retrieval (DPR)?

Dense Passage Retrieval (DPR) is a dual-encoder neural framework that retrieves relevant documents by maximizing the inner product between dense vector representations of queries and text passages.

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. Unlike sparse lexical methods like BM25, DPR captures semantic similarity by training on question-passage pairs, learning to pull relevant pairs together and push irrelevant ones apart via contrastive learning. The system retrieves the top-k passages by computing the maximum inner product search (MIPS) between the query embedding and all passage embeddings, typically using approximate nearest neighbor (ANN) indexes for scalability.

The framework is trained with in-batch negatives, where other passages in the same mini-batch serve as negative examples, dramatically improving computational efficiency. DPR forms the foundational retrieval component in Retrieval-Augmented Generation (RAG) pipelines and open-domain question answering systems, providing factual grounding for language models. Its dense representations enable robust matching across lexical gaps—retrieving relevant content even when query and passage share no overlapping keywords—making it essential for clinical entity linking and semantic search over unstructured knowledge bases.

DENSE PASSAGE RETRIEVAL

Key Features of DPR

Dense Passage Retrieval (DPR) is a dual-encoder framework that retrieves relevant passages by maximizing the inner product of dense query and context embeddings, offering superior semantic matching over sparse lexical methods like BM25.

01

Dual-Encoder Architecture

DPR uses two independent BERT-based encoders: one for queries and one for passages. This separation allows passages to be pre-encoded and indexed offline, enabling sub-linear retrieval latency at query time. The query encoder maps a natural language question to a dense vector, while the passage encoder maps every document chunk to a fixed-size embedding in the same vector space.

02

Inner Product Similarity Scoring

Relevance is computed as the dot product between the query embedding and each passage embedding. This operation is highly optimized for GPU acceleration and Approximate Nearest Neighbor (ANN) search. Unlike cross-encoders that process query-passage pairs jointly, the inner product allows for maximum inner product search (MIPS) over millions of pre-computed passage vectors in milliseconds.

03

In-Batch Negative Training

DPR is trained using a contrastive loss with hard negatives. For each relevant query-passage pair in a batch, all other passages in the same batch serve as negatives. This technique dramatically increases training efficiency by reusing computed embeddings. Additional hard negative mining—selecting high-BM25-score but irrelevant passages—further sharpens the model's disambiguation capability.

04

Dense vs. Sparse Retrieval

DPR overcomes the lexical gap that plagues sparse retrievers like BM25. Where BM25 relies on exact term overlap, DPR captures semantic similarity:

  • Synonym handling: 'physician' matches 'doctor' without explicit mapping
  • Paraphrase robustness: reworded queries retrieve the same relevant passages
  • Cross-lingual potential: embeddings can align semantically across languages This makes DPR ideal for clinical text where the same concept may be expressed with highly variable terminology.
05

Indexing with FAISS

Pre-computed passage embeddings are indexed using Facebook AI Similarity Search (FAISS) for efficient retrieval. FAISS supports multiple index types:

  • Flat Index: exact search, suitable for small corpora
  • IVF (Inverted File): clusters embeddings for faster approximate search
  • HNSW (Hierarchical Navigable Small World): graph-based indexing for high recall For biomedical knowledge bases with millions of entities, FAISS enables sub-10ms retrieval on commodity hardware.
06

Application in Clinical Entity Linking

In clinical entity linking pipelines, DPR serves as the candidate generation stage. A clinical mention (e.g., 'MI') is encoded by the query tower, and the top-k most similar UMLS concept descriptions are retrieved from a pre-indexed knowledge base. This dense retrieval step is often followed by a cross-encoder reranker for precise candidate scoring. DPR's semantic understanding is critical for resolving ambiguous abbreviations like 'MI' (myocardial infarction vs. mitral insufficiency) based on surrounding context.

DENSE PASSAGE RETRIEVAL

Frequently Asked Questions

Explore the core mechanics and architectural decisions behind Dense Passage Retrieval, the dual-encoder framework that powers high-accuracy clinical entity linking and semantic search in modern AI systems.

Dense Passage Retrieval (DPR) is a dual-encoder neural framework designed to retrieve relevant text passages from a large knowledge base by maximizing the inner product of a query vector and a context vector. Unlike sparse lexical methods like BM25, DPR encodes both the input query and all candidate passages into dense, low-dimensional vector embeddings using two independent BERT-based transformers. During inference, the system uses Approximate Nearest Neighbor Search (ANN) to rapidly identify the passages with the highest semantic similarity to the query. The framework is trained via a contrastive learning objective, where positive pairs (query, relevant passage) are pulled together in the vector space, and negative pairs (query, irrelevant passage) are pushed apart. This allows DPR to capture deep semantic relationships, making it exceptionally effective for tasks like open-domain question answering and clinical entity linking, where a mention like 'heart attack' must be matched to the correct UMLS Concept Unique Identifier (CUI) based on contextual meaning rather than keyword overlap.

RETRIEVAL ARCHITECTURE COMPARISON

DPR vs. Sparse Retrieval (BM25)

Contrasting dense dual-encoder retrieval with traditional sparse lexical retrieval for candidate generation in clinical entity linking pipelines.

FeatureDense Passage Retrieval (DPR)Sparse Retrieval (BM25)

Core Mechanism

Learned dense embeddings via dual-encoder neural networks; relevance scored by inner product of query and passage vectors

Lexical term frequency-inverse document frequency (TF-IDF) weighting with exact token matching

Semantic Understanding

Handles Lexical Mismatch

Handles Exact Term Match

Zero-Shot Generalization

Training Data Required

Large corpus of labeled query-passage pairs for contrastive learning

Inference Latency

~10-50 ms per query (GPU-accelerated ANN search)

< 5 ms per query (CPU-based inverted index)

Infrastructure Complexity

Requires GPU inference and vector database for approximate nearest neighbor search

Standard CPU-based inverted index (Lucene, Elasticsearch)

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.