liveBook · Manning

Hybrid retrieval-augmented generation

As explained in Context Engineering

Hybrid RAG is a retrieval-augmented generation approach that combines multiple retrieval methods over structured and unstructured data.

Hybrid retrieval-augmented generation (Hybrid RAG) combines multiple retrieval channels over structured and unstructured data to supply context for an LLM. The channels complement one another: lexical search finds exact keywords and error codes, dense vector search finds related meanings and synonyms, and knowledge graphs capture explicit relationships between entities. section 3.4 section 3.3.2

A typical retrieval flow has three stages:

  • Pre-filter candidates using structured metadata, such as tenant ID, date range, document category, or access permissions. section 3.4
  • Retrieve candidates through parallel channels, such as BM25 lexical search, dense semantic search, and graph traversal. section 3.4
  • Merge and rank the candidate lists using rank fusion or a downstream reranker, then provide the selected context to the LLM. section 3.4

Weighted score fusion combines retrieval scores directly, but BM25 and cosine similarity scores have different scales and distributions. Normalizing them and tuning fixed weights can be fragile. Reciprocal rank fusion (RRF) instead sums contributions based on each candidate’s position in the retrieval lists: each contribution is 1 / (k + rank), where rank starts at one and k is conventionally 60. The smoothing constant reduces the difference between leading positions. section 3.4

Finding an incident

For a query containing an error code, lexical search can retrieve exact matches while dense search finds descriptions with related wording. Graph traversal can add context about explicitly connected entities. Fusion brings these candidates into one ranked list for context selection. section 3.4 section 3.3.2

How Context Engineering covers it

How deep it goes
Explains metadata filtering, parallel retrieval, candidate fusion, and reciprocal rank fusion scoring, including the drawbacks of weighted score fusion.
Examples
Uses error codes, tenant IDs, date ranges, document categories, and access permissions to illustrate retrieval and filtering.
What you can do after
Evaluate/understand how complementary retrieval channels and rank fusion contribute to context selection.
How it connects
Connects lexical search, semantic search, knowledge graphs, graph traversal, reranking, and reciprocal rank fusion.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Context Engineering. The section links point to the parts of the book it draws on.