Course contentsShow
← Machine Learning and Deep Learning
Lesson 1999 of 3,53843. Retrieval-Augmented Generation: Advanced TechniquesFree lesson

Hybrid Search Architecture

Combining vector and keyword search in parallel with separate retrievers and result merging strategies.

Hybrid Search Architecture

What you'll learn: How to combine vector and keyword search in parallel to leverage both semantic understanding and exact-match precision in retrieval systems.

The Core Idea

Pure vector search excels at semantic similarity but can miss exact keyword matches. Pure keyword search (BM25) nails exact terms but ignores meaning. A hybrid search architecture runs both retrievers in parallel and merges their results to get the best of both worlds.

Think of it like asking two librarians for book recommendations: one who understands the theme you're after (vector search) and one who finds books with specific terms you mentioned (keyword search). You combine their suggestions intelligently.

How It Works

Parallel Retrieval

Both retrievers query independently:

  • Vector retriever: Embeds your query and finds top-K semantically similar chunks
  • BM25 retriever: Searches for keyword matches using traditional inverted indexes

Result Merging Strategies

You need to combine two ranked lists. Common approaches:

Reciprocal Rank Fusion (RRF): Scores each document by summing 1/(k + rank) from each retriever where it appears. Simple, effective, no normalization needed.

Weighted Linear Combination: Normalize similarity scores from both retrievers to [0,1], then combine as α·vector_score + (1-α)·keyword_score. Requires tuning α.

Round-Robin Interleaving: Alternately pick top results from each list until you have enough chunks.

The Payoff

Hybrid search handles queries like "Python decorators" (benefits from keyword match) and "how do I modify function behavior without changing code" (benefits from semantic understanding) equally well.

Key Takeaway: Hybrid search architectures combine vector and keyword retrievers in parallel with fusion strategies like RRF to capture both semantic similarity and exact-match precision, making RAG systems more robust across diverse query types.