S
Saurav Danej
90-Day AI/ML LinkedIn Content System
← All days
64
Day 64 of 90RAG

Hybrid search — BM25 + dense, the right way

POST 1 of 5 MorningRAGConcept

BM25 isn't legacy. It's complementary.

Dense vector search captures meaning. BM25 captures exact terms. They miss different things.

Dense misses: product codes, names, abbreviations, rare technical terms.
BM25 misses: paraphrases, synonyms, typos, conceptual matches.

Use both. Score each independently. Combine with Reciprocal Rank Fusion (RRF):

RRF(d) = sum over methods of 1 / (k + rank_method(d))

k is a small constant (60). Higher rank in either method → bigger score. Simple, robust, works.
#RAG#LLM#AI#VectorSearch#100DaysOfCode#HybridSearch
POST 2 of 5 MiddayRAGDeep dive

When hybrid gives the biggest lift

Hybrid helps most when:
- Your domain has many proper nouns / IDs / codes
- Users mix natural language and exact terms
- The corpus has duplicate content with different phrasings

It helps less when:
- All queries are short, vague, conceptual
- BM25 over the corpus already returns garbage (poor full-text index)
- Latency budget is razor-thin (you're now running 2 searches)

Measure on YOUR eval set. 5-15% recall@5 lift is typical when hybrid wins.
#RAG#LLM#AI#VectorSearch#100DaysOfCode#RAG
POST 3 of 5 AfternoonRAGCode

RRF in 8 lines

Run dense and BM25 separately. Each returns a ranked list. Combine. The k constant flattens early ranks; 60 is the published default that works almost everywhere.
#RAG#LLM#AI#VectorSearch#100DaysOfCode#Python
POST 4 of 5 EveningRAGTip

Use the same chunks for both indexes

Common bug: BM25 indexed at the document level, dense at the chunk level. RRF then combines results pointing at different units. Mismatch.

Fix: index both at the chunk level. Same chunks, two methods.

Qdrant 1.10+, Weaviate, OpenSearch all let you store BM25 + vector on the same chunk. One source of truth for IDs. Cleaner RRF.
#RAG#LLM#AI#VectorSearch#100DaysOfCode#RAG
POST 5 of 5 NightRAGRecap

Day 64 — hybrid search, demystified

Day 64 done.

- BM25 + dense are complementary
- RRF blends ranks robustly
- 8-line implementation
- Index both at the chunk level

Tomorrow (Day 65): rerankers — the small models that often double your retrieval quality.
#RAG#LLM#AI#VectorSearch#100DaysOfCode#RAG