Modern AI Engineering

Lesson 10.4 · 25 min · video lesson

Hybrid Search: Combining Sparse and Dense Retrieval

Keyword search finds "E1042" but misses "my printer won't print bills"; semantic search does the opposite. What if we did not have to choose?

In short: Hybrid search runs keyword search (usually BM25) and semantic (vector) search on the same query and merges the two ranked lists into one. The most popular merge is Reciprocal Rank Fusion, which adds up 1 / (k + rank) from each list and ignores raw scores; the alternative is to normalise both score scales and blend them with a weight. The result catches both exact terms and paraphrases.

What you will learn

  • What is keyword search
  • Why keyword search alone is not enough
  • What is semantic search
  • Why semantic search alone is not enough
  • What is Hybrid Search
  • How Hybrid Search runs both searches
  • How the two result lists are combined
  • Reciprocal Rank Fusion (RRF)
  • Weighted score combination and normalization
  • Hybrid Search in the real world

In this lesson

  1. Keyword search, and why it is not enough alone
  2. Semantic search, and why it is not enough alone
  3. What is hybrid search, and how it runs both searches
  4. How the two result lists are combined
  5. Reciprocal Rank Fusion (RRF)
  6. Weighted score combination and normalisation
  7. Code you can run: BM25 + vectors + RRF
  8. Choosing a fusion method, and hybrid search in the real world
  9. Common mistakes and how to spot them
  10. Practice: try it yourself

Key terms in this lesson

BM25
A keyword ranking formula based on term frequency, inverse document frequency and document length.
Hybrid search
Running keyword and vector search together and merging their results.
Reciprocal Rank Fusion
Merging ranked lists by summing 1 / (k + rank) for each document.
Min-max normalisation
Rescaling scores so the lowest becomes 0 and the highest becomes 1.
Alpha (α)
The weight that balances vector and keyword scores in a weighted hybrid blend.
Stemming
Reducing words to a root form so "invoices" matches "invoice".

This lesson is part of the Generative AI Engineering and Complete AI Engineer tracks. See plans and pricing to open the full lesson, its video, labs and quiz, or try the free lesson first (free account needed).

← 10.3 Semantic Search: Finding Meaning, Not Just Keywords · 10.5 Rerankers: Re-Scoring Retrieved Results by Relevance →