Skip to content
derpx06Notes on systems, models & learning
4. Embeddings & Vector Stores · lesson 37 of 68 · 1 min · January 10, 2026

Hybrid Search Concepts

The best of both worlds. Reciprocal Rank Fusion.

We saw that Dense Search (Vectors) and Sparse Search (Keywords) have opposite strengths. Hybrid Search runs both and combines the results.

  1. User Query: "Error 501 on login page."
  2. Dense Retriever: Finds docs about "Login Issues" (Concepts).
  3. Sparse Retriever: Finds docs containing "Error 501" (Exact Match).
  4. Ensemble: Combine the two lists.

How do you combine the lists? You can't just add the scores (Cosine Similarity score 0.8 is not comparable to BM25 score 15.0). We use Rank Fusion.

We look at the rank, not the score.

  • Doc A: Rank 1 in Dense, Rank 5 in Sparse.
  • Doc B: Rank 10 in Dense, Rank 1 in Sparse.

RRF gives points for being high on either list.

hybrid_search.py
from langchain.retrievers import EnsembleRetriever

ensemble_retriever = EnsembleRetriever(
  retrievers=[bm25_retriever, vector_retriever],
  weights=[0.5, 0.5]
)

docs = ensemble_retriever.get_relevant_documents("query")

Hybrid Search is the current state-of-the-art for production RAG. It provides the "Safety" of keywords with the "Magic" of vectors.

Key Intuition: "Don't put all your eggs in one index."