Inferensys

Glossary

Dense Passage Retrieval (DPR)

A bi-encoder retrieval architecture that uses dense vector representations to index and search clinical documents, enabling semantic search for RAG systems by finding passages relevant to a query beyond simple keyword overlap.
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 RETRIEVAL ARCHITECTURE

What is Dense Passage Retrieval (DPR)?

Dense Passage Retrieval (DPR) is a neural retrieval architecture that uses a dual-encoder framework to map both queries and documents into a shared, dense vector space, enabling semantic search that captures conceptual meaning rather than relying on exact keyword overlap.

DPR employs two independent BERT-based encoders: one for encoding a query and another for encoding text passages. Both outputs are mapped to high-dimensional vectors where the relevance score is computed as the dot product between them. This bi-encoder design allows passages to be pre-indexed offline, making retrieval fast at inference time.

In clinical RAG systems, DPR overcomes the lexical gap inherent in sparse methods like BM25. A query for 'heart attack' can retrieve passages discussing 'myocardial infarction' without explicit term matching. Training uses in-batch negatives and hard negatives to teach the model to distinguish relevant from topically similar but irrelevant passages.

ARCHITECTURE

Key Features of DPR

Dense Passage Retrieval (DPR) is a bi-encoder architecture that uses dense vector representations to index and search clinical documents, enabling semantic search for RAG systems by finding passages relevant to a query beyond simple keyword overlap.

01

Dual-Encoder Architecture

DPR uses two independent BERT-based encoders: a query encoder and a passage encoder. Each maps text into a fixed-size dense vector (768 dimensions for BERT-base) in a shared embedding space. At inference time, the passage encoder pre-computes embeddings for all documents offline, while the query encoder generates a single vector online. Retrieval becomes a fast Maximum Inner Product Search (MIPS) between the query vector and pre-indexed passage vectors, enabling sub-second search across millions of clinical documents.

02

In-Batch Negative Training

DPR is trained using a contrastive loss with in-batch negatives, a technique that dramatically improves computational efficiency. For a batch of N query-passage pairs, the model treats the correct passage for a query as the positive and all other N-1 passages in the batch as negatives. This creates N*(N-1) negative examples per batch without explicit sampling. The InfoNCE loss maximizes the similarity of positive pairs while minimizing similarity with negatives, teaching the model to distinguish relevant clinical evidence from distractors.

03

Semantic vs. Lexical Retrieval

Unlike traditional BM25 or TF-IDF sparse retrieval, DPR captures semantic meaning beyond exact keyword matching. A query for 'heart attack management' retrieves passages discussing 'myocardial infarction treatment protocols' even without shared terms. This is critical in clinical settings where:

  • Synonymy: 'hypertension' and 'high blood pressure' map to the same concept
  • Paraphrasing: Clinical guidelines may express the same recommendation differently
  • Conceptual similarity: Related conditions share latent semantic proximity
04

FAISS Integration for Scalable Indexing

DPR relies on Facebook AI Similarity Search (FAISS) for efficient billion-scale vector indexing. FAISS compresses embeddings using Product Quantization (PQ) and organizes them with Inverted File Index (IVF) structures. This enables:

  • Sub-millisecond retrieval from 1M+ clinical passages
  • GPU-accelerated exact and approximate nearest neighbor search
  • Memory-efficient storage via vector compression
  • Real-time index updates as new clinical documents are ingested
05

Domain Adaptation for Clinical Text

General-domain DPR models trained on Natural Questions or MS MARCO underperform on clinical text due to specialized vocabulary and document structures. Effective clinical DPR requires:

  • Domain-adaptive pretraining on MIMIC-III, PubMed, or institutional EHR corpora
  • Hard negative mining using BM25 to find passages with high lexical but low semantic relevance
  • Query augmentation with UMLS concept expansions to bridge consumer health queries to technical clinical language
  • Fine-tuning on clinical QA datasets like emrQA or BioASQ
06

Hybrid Retrieval with BM25

Production clinical RAG systems often combine DPR with BM25 sparse retrieval in a hybrid architecture. DPR excels at semantic matching but can miss rare terms like specific drug names or gene variants. BM25 provides exact lexical matching for these cases. The reciprocal rank fusion (RRF) algorithm merges results from both retrievers, ensuring high recall for both conceptual queries and precise entity lookups. This hybrid approach consistently outperforms either method alone on clinical retrieval benchmarks.

RETRIEVAL PARADIGM COMPARISON

DPR vs. Sparse Retrieval (BM25)

A technical comparison of dense vector retrieval (DPR) against traditional sparse lexical retrieval (BM25) for clinical document search.

FeatureDense Passage Retrieval (DPR)Sparse Retrieval (BM25)

Core Mechanism

Encodes queries and passages into dense, fixed-length vectors in a continuous latent space; relevance is computed via dot product or cosine similarity.

Tokenizes text into bags of words; relevance is computed via exact term frequency-inverse document frequency (TF-IDF) weighting and document length normalization.

Semantic Understanding

Vocabulary Mismatch Handling

Handles synonyms, paraphrases, and related concepts natively through dense embeddings trained on co-occurrence data.

Fails to match semantically equivalent terms with different surface forms (e.g., 'myocardial infarction' vs. 'heart attack') unless explicit query expansion is applied.

Exact Term Matching

Training Data Requirement

Requires a large corpus of labeled query-passage pairs (e.g., MS MARCO, clinical QA datasets) for supervised contrastive learning.

Zero-shot; no training data required. Operates purely on corpus statistics.

Index Size

Large; requires storing a dense vector (typically 768 dimensions of float32) per passage, often necessitating approximate nearest neighbor (ANN) indexes like FAISS.

Compact; stores an inverted index mapping terms to posting lists, highly compressed and efficient.

Query Latency

Moderate; dependent on ANN index configuration and vector dimensionality. Sub-50ms typical with optimized GPU indexes.

Very low; sub-10ms typical due to highly optimized inverted index traversal and early termination heuristics.

Clinical Acronym Handling

Can learn to map acronyms to their expansions contextually (e.g., 'CHF' to 'congestive heart failure') if present in training data.

Treats acronyms as distinct tokens; fails to match 'CHF' with 'congestive heart failure' without a synonym dictionary.

DENSE PASSAGE RETRIEVAL

Frequently Asked Questions

Clear, technically precise answers to common questions about the bi-encoder architecture powering semantic search in clinical AI systems.

Dense Passage Retrieval (DPR) is a bi-encoder neural retrieval architecture that represents both queries and documents as dense, low-dimensional vectors in a shared semantic space, enabling relevance matching beyond exact keyword overlap. The system employs two independent BERT-based encoders: a query encoder that maps a clinical question like 'Does this patient have diabetic retinopathy?' into a fixed-size embedding, and a passage encoder that pre-indexes every passage in a clinical corpus into the same vector space. At retrieval time, the system computes the inner product or cosine similarity between the query vector and all passage vectors, returning the top-k passages with the highest semantic similarity scores. Unlike sparse retrieval methods such as BM25 that rely on term frequency, DPR captures contextual semantics, understanding that 'myocardial infarction' and 'heart attack' refer to the same clinical concept even when they share no lexical overlap. The architecture is trained using a contrastive loss function with in-batch negatives, where the model learns to maximize the similarity between a query and its relevant passage while minimizing similarity with all other passages in the training batch. This dense representation approach is foundational to modern Retrieval-Augmented Generation (RAG) systems in healthcare, where accurate passage retrieval directly determines the factual grounding of generated clinical summaries.

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.