Combine dense vector search with sparse keyword (BM25) search and fuse the results for more robust retrieval.
How hybrid search fuses meaning and exact matches
Step 1 of 5
Dense search
The query is embedded and matched against the vector index. It handles paraphrases well, such as "cancel my plan" matching "subscription termination".
Step 2 of 5
Sparse search
The same query runs against a BM25 keyword index at the same time. It catches exact tokens that embeddings blur, like an error code or a product name.
Step 3 of 5
RRF fusion
Reciprocal Rank Fusion scores each document by its rank in each list and adds the scores. It compares ranks, not raw scores, so the two incompatible scales do not matter.
Step 4 of 5
Rerank
A cross-encoder re-scores the fused list against the query and keeps only the best few for the prompt.
Step 5 of 5
LLM
The model answers from those chunks. Measuring recall for each branch separately shows which index needs tuning when answers miss.
Vector search finds the right idea; keyword search finds the exact name or ID. Fusion keeps both.
Query
Dense (vector)
Sparse (BM25)
RRF fusion
Reranker
LLM
clientservicemodeldatabaseagentexternal
Explanation
The query is searched both as an embedding (semantic) and as keywords (exact match / IDs / names). Results are fused with Reciprocal Rank Fusion, then reranked by a cross-encoder before being passed to the LLM.
Components
Vector index (pgvector)BM25 index (Postgres tsvector / OpenSearch)RRF fusionReranker
When to use
RAG over mixed content (prose + code + identifiers)