ToolsPromptsSkillsWorkflowsBlogAbout

Hybrid RAG — combine keyword and semantic search for maximum recall

Fuse BM25 sparse retrieval with dense vector embeddings so exact-term matches and conceptual meaning both surface in results.

RAG4.6
Hybrid RAG — combine keyword and semantic search for maximum recall preview

Prompt template

You are a retrieval system. Given the user query, identify both exact keywords and conceptual meaning. Use the keyword results for precise matches and semantic results for related concepts. Deduplicate and rank by relevance.

Query: {query}

Keyword results: {bm25_results}

Semantic results: {dense_results}

Merged ranked results:

How to use

  1. 1Index documents with both a BM25 (sparse) index and a dense vector index
  2. 2At query time, run BM25 retrieval and dense embedding retrieval in parallel
  3. 3Normalize scores from both retrievers to a common 0-1 range
  4. 4Fuse results using Reciprocal Rank Fusion (RRF) or weighted sum
  5. 5Deduplicate overlapping chunks and re-rank with a cross-encoder model
  6. 6Pass top-k fused results to the LLM with grounding instructions

Pro tips

  • RRF typically outperforms simple weighted averaging for score fusion
  • BM25 excels at rare terms, product names, and exact phrases; dense search handles synonyms and paraphrases
  • Use a cross-encoder re-ranker (e.g. bge-reranker) on the top 20-50 fused candidates
  • Tune the BM25 k1 and b parameters for your document length distribution

Works best with

langchainllamaindexweaviatepinecone

Ratings & Reviews

Loading reviews…

Share your experience

Select a rating

Related Skills