Hybrid Search (BM25 + Vectors)
A RAG system is only as good as the passages that its search finds. Keyword search is good at exact words, and vector search is good at meaning. Hybrid search runs both and merges the results, so each one covers the weak spots of the other.
New words
- RAG
- An AI that first searches your documents, then writes an answer from what it found.
- BM25
- A classic formula that ranks documents by the keywords they contain.
- Vector
- A list of numbers, where similar meanings get vectors that are close together.
- Embedding
- The vector that a model makes from a text to capture its meaning.
- Cosine similarity
- A score that shows how close the meanings of two vectors are.
- RRF
- Reciprocal Rank Fusion: a way to merge ranked lists using only the ranks.
- Recall
- The share of the right passages that appear in the top results.
What you will learn
- The problem: two kinds of question
- BM25: keyword search done well
- Vector search: matching by meaning
- Where each one fails
- Combining them: Reciprocal Rank Fusion
- Try it: fuse two rankings
- Trade-offs: what can go wrong?
- Production practices: what real teams do
- In code
- In a real system
- Interview tip
- Key takeaways
10 quiz questions at the end.
The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.