Hybrid Search: Dense + Sparse / BM25
An information retrieval architecture that combines vector semantic search (Dense retrieval — understanding meaning and synonyms) with classical keyword search (Sparse retrieval / BM25). It provides an ideal balance between conceptual understanding and precise searches for articles, serial numbers, or names.
1. Concept Overview & Systemic Problem
With the advent of vector databases in the AI landscape, many enthusiasts proclaimed: “Classical keyword search (like in Google or Elasticsearch) is dead! Now we search only by meaning!”
However, this euphoria quickly turned into disappointment. Try finding in a vector database:
- Passport number:
AA 491823. - Part model:
chip RTX 4070 Ti Super. - Error code:
ERR_CONNECTION_TIMED_OUT.
Vector models struggle with exact codes — to them, these are just nonsensical strings of letters and numbers. They might return an article about AMD graphics cards because “in terms of meaning, it’s also computer hardware!”
The solution is Hybrid Search — a golden alliance of two technologies:
- Dense Retrieval (Vectors): responsible for searching synonyms, context, and overall meaning (“something warm for winter” ➔ jacket, parka).
- Sparse Retrieval (BM25 / Keywords): responsible for pinpointing exact letters and numbers (“article 49182”).
The key engineering principle: a duo of detectives: one has a keen sense of human psychology and motives (vector), while the other cross-references fingerprints against a database (BM25).
2. Architectural Taxonomy & Mental Model
┌─────────────────────────────────────────────────────────────┐
│ HYBRID SEARCH ARCHITECTURE │
├─────────────────────────────────────────────────────────────┤
│ INPUT QUERY: “Replacement filter for Philips FC9334 vacuum” │
├─────────────────────────────────────────────────────────────┤
│ ┌───────────────────────────┬───────────────────────┐ │
│ ▼ ▼ │ │
│ [ DENSE VECTOR SEARCH ] [ SPARSE KEYWORD SEARCH ] │ │
│ (Understands topic: cleaning, (Searches for exact code: │ │
│ vacuums, home appliances) “Philips”, “FC9334”) │ │
│ │ │ │ │
│ └─────────────┬─────────────┘ │ │
│ ▼ │ │
│ [ RRF RANK FUSION ] │ │
├─────────────────────────────────────────────────────────────┤
│ 🎯 RESULT: Exact instruction for model FC9334 │
│ at the top of the results! │
└─────────────────────────────────────────────────────────────┘
3. Technical Pipeline & Internal Mechanics
- Resilience to specificity: works perfectly in medical, engineering, and legal databases where precise codes for diseases, part numbers, and law references are critically important.
- Language independence: finds documents even with mixed languages in the query (e.g., surzhyk or English terms amidst Ukrainian text).
4. Production Engineering Scenarios
01. Medical Database Search
Implement Hybrid Search in a medical database to ensure accurate retrieval of disease codes and treatment protocols, enhancing clinical decision-making.
02. E-commerce Product Lookup
Utilize Hybrid Search in e-commerce platforms to allow users to find products by both exact SKU numbers and related product descriptions, improving user experience and sales.
03. Legal Document Retrieval
Deploy Hybrid Search in legal databases to efficiently locate case laws and statutes, ensuring legal professionals can quickly access precise information.
5. Pitfalls, Common Mistakes & Security
Avoid relying solely on dense retrieval for searches requiring exact matches, as this can lead to user frustration. Always enable hybrid mode instead of pure vector search to prevent users from encountering issues when searching for precise order codes.
FAQ: Hybrid Search: Dense + Sparse / BM25
Related terms
Dense Retrieval vs Keyword Search
A comparison of two search approaches: neural network-based semantic retrieval (Dense Retrieval) and traditional keyword matching (Sparse / BM25). It explains why vector search may fail in product item searches and how hybrid search operates.
Reranking Search Results (Reranking / Cross-Encoders)
A two-step search pattern in RAG systems. The first step (fast vector or hybrid search) retrieves 20-50 candidates in 10 ms. The second step (Cross-Encoder reranker model, such as Cohere Rerank or BGE-Reranker) meticulously matches the query with each retrieved text, retaining the top 3 most accurate documents.
Semantic Search: Why Meaning-Based Search Outperforms Traditional Ctrl+F
A technology for information retrieval based on the conceptual content of a query rather than exact letter matches or keywords. It understands synonyms, paraphrasing, spelling errors, and abstract natural language questions.