Hybrid Search: BM25 and Dense Retrieval Combined › Practical Considerations

Michael BrenndoerferJanuary 29, 20265 min read
Language AI HandbookAll chapters
Part 44 of 67Retrieval-Augmented Generation
Chapter 342Hybrid Search: BM25 and Dense Retrieval Combined › Practical Considerations
Reading section 7 of 10 · Practical Considerations · 5 minSection 7 of 10 · 5 min

Book contents

Section 7 of 10 · 5 min read

Hybrid Search: BM25 and Dense Retrieval Combined › Practical ConsiderationsOne section · Sections in this chapter7 / 10 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Implementing hybrid search in production requires more thought than the toy examples above suggest. Several practical issues arise at scale that are easy to overlook when prototyping. The gap between a working demonstration and a production-ready system is real, and understanding it before you start will save significant time.

Think of production hybrid search as managing two parallel pipelines that must be orchestrated carefully. Each pipeline has its own index, its own serving infrastructure, and its own failure modes. When they run correctly in parallel, the combined system is better than either alone. When one pipeline is slow, misconfigured, or serving stale data, the hybrid output degrades in ways that are harder to debug than single-system failures.

Index Design and Latency

BM25 and dense retrieval have fundamentally different index types. BM25 uses an inverted index: a map from each vocabulary term to the list of documents containing it, along with term frequency statistics. This index scales well with document count and supports very fast retrieval for short queries through posting list intersection. Dense retrieval uses an approximate nearest neighbor index (HNSW, IVF, or similar, as discussed in prior chapters) over high-dimensional embeddings. Both indices can be queried in milliseconds at corpus sizes in the millions, but they must both be queried in parallel for hybrid search to avoid doubling latency.

Well-designed hybrid search systems issue both queries simultaneously and join the results after both return. If one system is materially slower, it becomes the bottleneck. In practice, HNSW indexes on GPU-accelerated hardware are often faster than BM25 on large corpora, making the inverted index the potential bottleneck for very high query volumes.

The memory footprint also differs substantially. An inverted index for a million-document corpus might occupy a few gigabytes, dominated by term-frequency and document-frequency statistics. A dense index storing 768-dimensional float32 embeddings for the same corpus occupies 1,000,000×768×4=3.071{,}000{,}000 \times 768 \times 4 = 3.07 GB just for the raw vectors, before any index structure overhead. For large corpora, the memory requirements for the dense index are the binding constraint, and strategies like product quantization (compressing each vector to a smaller representation) become necessary.

Sparse and Dense Index Co-location

Modern vector database systems like Elasticsearch (with vector search extensions) and Weaviate support hybrid retrieval natively, maintaining both an inverted index for BM25 and a vector index for dense retrieval within a single system. This simplifies operational complexity. Alternatively, you can run Elasticsearch or Apache Solr for BM25 alongside a separate Faiss or Qdrant instance for dense retrieval, but this requires managing two separate services and merging results at the application layer.

The co-location approach has operational advantages: a single system to monitor, a single API to query, and a single codebase to maintain. The split-system approach gives more flexibility in choosing the best tool for each retrieval type and can scale each component independently. For teams with strong DevOps infrastructure, the split approach is fine. For teams that want operational simplicity, a system with native hybrid search support is strongly preferred.

Domain Adaptation and Weight Tuning

The optimal α\alpha for weighted fusion or the choice between RRF and weighted fusion depends heavily on the domain and query distribution. On technical documentation corpora where users frequently search by exact function names, class names, or error codes, heavier weight toward BM25 is beneficial. On open-domain question answering or customer support corpora where users rephrase common questions differently each time, heavier weight toward dense retrieval often wins.

The best practice is to collect a sample of real queries with relevance judgments (which documents users clicked, or human-annotated relevant documents) and use those to tune α\alpha via cross-validation. Without labeled data, RRF with the default k=60k = 60 is the safest starting point.

Sparse Encoders as a Third Hybrid Component

A growing trend extends hybrid search with sparse learned encoders like SPLADE. SPLADE uses a transformer to produce a sparse vector over the full vocabulary, where each dimension is a term's importance weighted by the model's understanding of the query or document. Unlike BM25, which is purely term-frequency-based, SPLADE can expand a query "heart attack" to also assign high weight to "myocardial," "cardiac," and "infarction" in its sparse representation. This makes sparse encoders a middle ground between classical BM25 and dense retrievers: they maintain the sparse, vocabulary-aligned structure that supports efficient inverted index retrieval while incorporating semantic understanding.

Think of SPLADE as a learned version of query expansion: instead of manually writing synonym dictionaries, the model learns from training data which vocabulary dimensions should be activated for which queries and documents. The resulting sparse vectors can be indexed and searched using the same inverted index infrastructure as BM25, but they capture a much richer notion of term relevance. Hybrid systems combining BM25, SPLADE, and dense retrieval can outperform any pairwise combination, though they also increase system complexity and require more index infrastructure.