Why this matters
- PolicyDesk's vector search missed "casual leave" when employees typed the exact phrase "CL entitlement," which exists only as an acronym in the handbook.
- BM25 caught the acronym. Vectors caught "time off." Hybrid search is how you stop choosing.
- Interviewers ask you to write the BM25 idea, not to derive it from scratch, and to say when keyword search still wins.
- The rest of the pipeline is decoration if top-k is the wrong pages.
Three families
| Technique | What it matches | Best at | Weak at |
|---|---|---|---|
| Similarity (vector) search | Meaning, via embeddings | Paraphrase: 'time off' finds 'privilege leave' | Rare exact tokens: error codes, acronyms, SKUs, section numbers |
| Keyword / lexical search | Terms, usually BM25 | Exact words, names, codes, and phrases that must appear | Synonyms and paraphrases the user did not type |
| Hybrid | Both, then a fused ranking | Real questions, which mix meaning and exact terms | More moving parts: two indexes and a fusion rule |
Similarity (vector) search
What it matchesMeaning, via embeddingsBest atParaphrase: 'time off' finds 'privilege leave'Weak atRare exact tokens: error codes, acronyms, SKUs, section numbersKeyword / lexical search
What it matchesTerms, usually BM25Best atExact words, names, codes, and phrases that must appearWeak atSynonyms and paraphrases the user did not typeHybrid
What it matchesBoth, then a fused rankingBest atReal questions, which mix meaning and exact termsWeak atMore moving parts: two indexes and a fusion rule
Most production RAG systems that survive contact with employees use hybrid search. Pure vectors feel magical in a demo and fail on the policy code "CL-2." Pure keywords fail the moment someone asks in their own words.
Similarity search
You embed the query, embed (already stored) chunks, and rank by cosine, Euclidean distance, or dot product. The top k chunks go forward.
k is a product decision. k=3 keeps the prompt tight and fails if the answer is split across chunks 4 and 5. k=20 pastes a noisy dossier and the model may attend to the wrong paragraph. Start at 4 to 8 for a handbook, then measure whether the gold chunk appears in the set. That measurement is Recall@k, defined in the evaluation lesson.
# Shape of a vector query. Client method names differ by version.
hits = client.query_points(
collection_name="hr_docs",
query=query_vector,
limit=5,
).points
for hit in hits:
print(hit.score, hit.payload["text"])
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 3 sections
- Keyword search and BM25
- Hybrid search
- Choosing deliberately
Test yourself
Answer these before moving on — recall is what makes it stick.