Hybrid Search
Words AND meaning together
Vector search misses exact strings and rare tokens that lexical search nails, and vice versa. Hybrid search — combining BM25-style keyword with vector — covers both, and its success depends on fusion and weighting.
What you will learn
- Explain BM25's and vector search's complementary strengths
- Combine retriever scores with RRF or weighted fusion
- Tune fusion settings deliberately
What is this?
Hybrid search runs a lexical retriever (BM25-like) and a vector retriever over the same corpus, then fuses the two ranked lists into one — via Reciprocal Rank Fusion (RRF) or weighted score blending. Synonyms (vector wins) and exact identifiers (lexical wins) both retrieve correctly; the fusion knob decides which voice dominates.
Why do you need it?
- Code, SKUs and error codes are lexical: vector search mangles exact strings.
- Paraphrase and intent are semantic: BM25 misses them.
- Hybrid reliably beats either retriever alone on mixed corpora.
- RRF is robust and tuning-light; weighted blending gives finer control (at the risk of calibration pain).
Mental model
Two scouts reporting back
Hybrid fusion
Scout A reads literally (finds your exact slogan), Scout B reads pragmatically (finds the rival that means the same). Neither always spots everything, so the leader merges their ranked shortlists, counting each 'place' — a scout placing 3rd plus the other placing 5th often beats a single scout's 2nd-place-only report.
How it works
- Index: store original text/fields for lexical search AND embed vectors.
- Query: run lexical on the text and vector on the embedding in parallel.
- Fusion: RRF sums 1/(k+rank) over both lists; weighted fusion blends normalized scores.
- K (RRF) default ~60, then paper-average results close to optimal with zero tuning.
- Optional: metadata filters apply to both retrievers consistently.
Two retrievers, one ranked list.
In production
- Enterprise search for code+tickets: exact error strings and conceptual match in one box.
- RAG pipelines hybrid-retrieve then rerank → fewer missing-truth cases.
- E-commerce catalogs: product codes (lexical) plus 'similar to the one I liked' (vector).
Best practices
- Default to RRF unless you have strong reason to blend scores.
- Ensure metadata filters apply to both retrievers identically.
- Keep source text indexed for lexical — vector-only stores can't do hybrid.
- Benchmark hybrid vs each retriever separately on your eval set before trusting the sandwich.
Common mistakes
- Fusing lists from different corpus snapshots (stale mismatch).
- Normalizing scores differently per retriever then blending — double-counted strengths.
- Assuming hybrid automatically beats single retrievers; verify per task.
Common issues
Hybrid misses a query each single-armed retriever handledFusion or filter mismatch
Check filter parity and fusion denominators; test retrievers isolated first.
RRF floods vectors with lexical noiseSmall k (like 1-10) over-weighted
Use k~60 and re-benchmark with k sweep.
Debugging tips
- Exact-code queries missing → lexical part has no source-text index or analyzer broke tokens.
- Heavy synonym dependence misses → vector weight too low in blending.
- Duplicated hits from both retrievers → dedupe keys before fusion (union by id).
Interview checkpoint
Hands-on lab
- Compute a simple term-frequency keyword score
- Smooth it with an inverse document frequency
- Blend keyword and semantic scores and compare rankings
Keyword Plus Semantic Blending
30 min · intermediate
Quick quiz
Reciprocal Rank Fusion (RRF) combines documents by…
BM25 excels at synonym matches.