liveBook · Manning

Chapter 7: HyDE: Imagining the answer before you search

What you will learn in chapter 7 of Retrieval Augmented Generation, The Foundational Ideas

Introduces query-document mismatch and HyDE’s idea of searching with an imagined answer while grounding the final response in retrieved documents.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces query-document mismatch and HyDE’s idea of searching with an imagined answer while grounding the final response in retrieved documents.

Key terms: query-document mismatch, FP1 (Missing Content), FP2 (Missed the Top Rank), HyDE, hypothetical document, document-to-document similarity, zero-shot, relevance labels, model relevance, factual grounding

7.1 The query-document mismatch problem

This section explains why short, colloquial queries can miss relevant technical documents and illustrates how HyDE narrows that mismatch by searching with an imagined answer.

Key terms: dense retrieval, semantic gap, zero-shot, query-document mismatch, HyDE, hypothetical answer, document-only similarity, register, document encoder, BM25

7.2 Generating hypothetical documents

This section explains how HyDE turns a sparse query into an imagined document for retrieval while leaving factual grounding to real documents.

Key terms: HyDE, hypothetical document, semantic gap, query embedding, encoder, relevance modeling, factual grounding, trusted corpus

7.3 Zero-shot dense retrieval without relevance labels

This section explains how HyDE turns a generated passage into a zero-shot search vector, why that vector can tolerate some factual errors, and how the approach is used and evaluated.

Key terms: hypothetical document, unsupervised contrastively learned encoder, vector embedding, similarity search, dense bottleneck, lossy compressor, relevance pattern, semantic frame, hallucinations, zero-shot

7.4 Implementing HyDE for challenging queries

This section explains where HyDE can help with challenging queries, how to use it for non-English retrieval, and the limits and costs of doing so.

Key terms: zero-shot, hypothetical document, vocabulary problem, multilingual generative LLM, multilingual encoder, shared vector space, query-document mismatch, latency, computational cost, low-resource languages

7.5 Case study: Medical knowledge retrieval

A medical retrieval case study shows how HyDE uses a hypothetical answer to find more relevant PubMed documents while keeping the final answer grounded in verified sources.

Key terms: HyDE, hypothetical answer, semantic key, domain expert simulator, PubMed vector store, hallucination risk, temporary search artifact, retrieved, verified documents, grounded

7.6 Variations and extensions

This section distinguishes HyDE’s published refinements from later variants and explains how multi-sampling, hybrid retrieval, and reverse indexing change its tradeoffs.

Key terms: standard HyDE vector, hypothetical documents, query's own embedding, Multi-Sample HyDE, Hybrid HyDE, original query's embedding, lexical search, BM25, Reverse HyDE, query time

7.6.1 Multi-sample HyDE

This section explains how averaging embeddings from multiple hypothetical documents makes HyDE retrieval less dependent on any one generation, at the cost of more generations per query.

Key terms: multi-sample HyDE, hypothetical document, embeddings, query vector, N generations per query, latency, tokens, working default

7.6.2 Hybrid HyDE (Fusion)

This section explains how hybrid HyDE preserves the value of the original query while using HyDE’s semantic reach, and illustrates the tradeoff with query-vector positions.

Key terms: Hybrid HyDE, vector averaging, hybrid search, BM25, rank fusion, Reciprocal Rank Fusion, direct embedding, single HyDE sample, multi-sample averaged embedding, hybrid fusion embedding

7.6.3 HyDE with re-ranking

This section explains how HyDE can retrieve initial candidates for a more precise reranker, limiting the cost of that second stage.

Key terms: HyDE, multi-stage retrieval, candidate documents, re-ranking, cross-encoder, reranker

7.6.4 Reverse HyDE

This section explains how generating questions for documents at indexing time makes retrieval a question-to-question search and shifts LLM work off the query path.

Key terms: Reverse HyDE, hypothetical questions, query-to-query similarity search, metadata, deduplicating, query-time latency, indexing, hot path, generation, index

7.6.5 Learned query refinement: RQ-RAG

This section contrasts RQ-RAG’s learned query refinement with HyDE’s prompt-only approach, then explains practical ways to deploy HyDE and guard against misleading retrieval.

Key terms: RQ-RAG, query refinement, control tokens, multi-hop, sub-query, refinement trajectories, trajectory selection, supervised fine-tuning, zero-shot, HyDE

7.7 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 6: Atlas: Few-shot learning with retrieval augmentation Chapter 8: RAG-Fusion: Multi-query retrieval enhancement →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.