Skip to content

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

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:

  1. ✅ Embeddings capture semantic meaning
  2. ✅ But treat Order #1766 and #1767 as similar
  3. ✅ BM25 captures exact keyword matches
  4. ❓ How to combine them?

This section answers that question with practical solutions.

Reading Order

  1. Dense Retrieval — Recap of embeddings + search
  2. Sparse Retrieval — How BM25 works and why it finds exact matches
  3. Hybrid Search ← Start here if you want the solution
  4. Metadata Filtering — Additional safety layer
  5. Re-ranking — Improving results with cross-encoders

Key Insight: The best RAG systems use all three:

  1. Dense search (find semantically similar)
  2. Sparse search (find exact keywords)
  3. Metadata filtering (enforce hard constraints)