Retrieval Methods: Dense, Sparse, and Hybrid
Now that you understand embeddings and similarity search, let's learn the different retrieval strategies.
The right retrieval method depends on your use case:
- Dense retrieval (semantic): Great for meaning, terrible for exact matches
- Sparse retrieval (keyword/BM25): Great for exact matches, misses synonyms
- Hybrid retrieval: The best of both worlds
Topics
- Dense Retrieval — Embedding-based semantic search
- Sparse Retrieval — BM25, TF-IDF keyword search
- Hybrid Search — Combining both (your solution!)
- Metadata Filtering — Structured filters
- Re-ranking — Improving result quality
The Core Problem (Reminder)
User searches: "Order #1766"
Dense (Semantic) Result:
├─ Order #1766 (0.98 similarity) ✅
├─ Order #1767 (0.96 similarity) ❌ WRONG!
└─ Order #1765 (0.95 similarity) ❌ WRONG!
Sparse (Keyword) Result:
└─ Order #1766 (exact match) ✅
Hybrid Result (Dense + Sparse):
└─ Order #1766 (highest combined score) ✅
The Solution Path
You've learned:
- ✅ Embeddings capture semantic meaning
- ✅ But treat Order #1766 and #1767 as similar
- ✅ BM25 captures exact keyword matches
- ❓ How to combine them?
This section answers that question with practical solutions.
Reading Order
- Dense Retrieval — Recap of embeddings + search
- Sparse Retrieval — How BM25 works and why it finds exact matches
- Hybrid Search ← Start here if you want the solution
- Metadata Filtering — Additional safety layer
- Re-ranking — Improving results with cross-encoders
Key Insight: The best RAG systems use all three:
- Dense search (find semantically similar)
- Sparse search (find exact keywords)
- Metadata filtering (enforce hard constraints)