GenAI & LLMs · September 2026
HyDE: When RAG Should Imagine the Answer Before Searching
Why Hypothetical Document Embeddings can bridge the query–document gap, where they fail, and how HyDE fits inside an adaptive enterprise retrieval stack.

Retrieval-Augmented Generation usually begins by embedding a user query and searching for nearby documents. That works well when the language of the question resembles the language of the corpus. In specialized domains, it often does not.
A user asks, “How do we rotate credentials after a service account is compromised?” The relevant runbook says, “Emergency credential rotation requires revocation of the active secret, creation of a replacement credential, and redeployment of dependent workloads.” The intent is the same, but the vocabulary, structure, and level of detail are different.
Hypothetical Document Embeddings—HyDE—addresses that mismatch with an unusual move: before searching, generate a plausible answer-shaped passage and use its embedding to find real documents. The generated passage may be wrong in detail. It is not evidence; it is a search instrument.
HyDE is a retrieval strategy inside RAG
“HyDE versus RAG” is the wrong comparison. RAG is the larger retrieve–augment–generate architecture. HyDE changes the representation used to begin retrieval. The retrieved corpus, context builder, generator, citations, and evaluation stages still remain.
The original HyDE paper by Gao, Ma, Lin, and Callan introduced the method for zero-shot dense retrieval without relevance labels. An instruction-following model generates a hypothetical document; an unsupervised encoder embeds it; vector similarity retrieves real documents from the corpus. The authors describe the dense embedding as a bottleneck that preserves useful relevance patterns while grounding the result back in actual documents.
Why document-shaped search can work
Dense embedding models are good at semantic similarity, but they are not immune to domain shift. A short question such as “Why is my cloud bill suddenly higher?” may need to find a passage about autoscaling, data egress, storage growth, and reserved-capacity coverage. A hypothetical answer introduces the kinds of terms and structure that relevant documents are likely to contain.
The retrieval comparison therefore becomes document-shaped representation against document-shaped corpus content. This can improve alignment when user language is informal, abbreviated, or conceptually distant from internal documentation.
HyDE can also generate several hypothetical passages rather than one. Haystack’s documented implementation generates five, embeds each passage, and averages the vectors. Sampling multiple plausible representations can reduce the risk that one synthetic answer overcommits to a single interpretation.
| Stage | What happens | What must remain true |
|---|---|---|
| Hypothesis generation | Create one or more plausible answer-shaped passages. | The output is provisional and may contain errors. |
| Representation | Embed the generated passages, optionally aggregating several vectors. | The embedding is a search key, not a knowledge claim. |
| Candidate retrieval | Search the real corpus for nearby documents. | Permissions and metadata filters still apply. |
| Reranking | Score candidates against the original information need. | The original query remains available for precision. |
| Generation | Answer from the selected real evidence. | Claims and citations must resolve to the corpus. |
When HyDE is useful
HyDE is most useful when the failure is semantic asymmetry: the user and the corpus describe the same concept in different language. This is common in technical support, policy search, enterprise knowledge bases, legal operations, medicine, and other domains where experts write documents differently from the way users ask questions.
Good candidates for a HyDE experiment
The corpus uses expert vocabulary that users do not know.
Evaluation shows that dense retrieval misses conceptually relevant passages.
The organization has a domain corpus but little relevance-labelled data for retriever training.
User phrasing is short, colloquial, or far from document style.
The original experiments reported substantial gains over the unsupervised Contriever baseline and performance competitive with some supervised retrievers across web search, question answering, fact verification, multiple domains, and several languages. That zero-shot property remains attractive when labelled retrieval data is scarce.
When HyDE can hurt
Generation before grounding also introduces bias before retrieval. If a query contains an unknown internal acronym, proprietary product, or ambiguous name, the hypothesis model may confidently choose the wrong meaning. The resulting vector can move search away from the correct neighborhood.
- Exact identifiers: error codes, SKUs, policy IDs, legal clauses, names, and version strings often need lexical matching.
- Unknown proprietary entities: a model may invent what an internal term means before the corpus has a chance to define it.
- Precise numerical questions: synthetic expansion can blur the exact entity, period, table, or value that must be retrieved.
- Latency-sensitive paths: HyDE adds a model call before retrieval and must earn that cost with measurable recall or ranking gains.
- Ambiguous questions: one hypothetical answer may collapse several valid interpretations into the wrong one.
A documented LlamaIndex example illustrates the ambiguity problem: the term “Bel” referred to a programming language in the corpus, while the generated hypothesis interpreted it as an ancient deity. The hypothetical passage was fluent—and semantically wrong for the collection.
HyDE is not the only query transformation
Weak retrieval can have several causes. Query rewriting resolves conversational dependency by producing a complete, explicit question. Multi-query retrieval explores several phrasings or interpretations and merges their results. Decomposition turns a complex request into smaller evidence needs. HyDE specifically creates a document-shaped semantic representation.
| Technique | Representation produced | Best fit | Primary risk |
|---|---|---|---|
| Query rewriting | A clearer query | Conversational follow-ups and missing context | The rewrite can change the user’s intent. |
| HyDE | An answer-shaped passage | Vocabulary and document-style mismatch | The hypothesis can encode a false interpretation. |
| Multi-query retrieval | Several query variants | Broad or ambiguous information needs | Cost, duplicate candidates, and noisy fusion. |
| Query decomposition | Smaller sub-questions | Multi-hop comparisons and compound tasks | Errors can cascade across sub-questions. |
HyDE does not replace hybrid search or reranking
HyDE operates at the representation layer. Hybrid retrieval combines signals—typically dense semantic search with sparse lexical search—and remains valuable because exact terms and semantic meaning fail differently. A production system can retain the original query for sparse retrieval while using a HyDE representation for an additional dense path.
Reranking solves another problem. Candidate retrieval aims for recall: bring potentially useful passages into the pool. A reranker aims for precision: score which candidates most directly answer the original query. HyDE can improve the neighborhood without guaranteeing the best evidence appears at rank one.
What the recent evidence says
The evidence supports HyDE as useful but workload-dependent. A 2026 EACL study evaluated vanilla and advanced RAG methods across eight conversational QA datasets. In its unified setup, straightforward techniques including reranking, hybrid BM25, and HyDE consistently outperformed vanilla RAG. The same study found that dataset characteristics and dialogue length strongly affected effectiveness, and that no single strategy dominated every setting.
A 2026 benchmark focused on financial text-and-table retrieval found a different winner. Hybrid retrieval followed by neural reranking achieved the strongest reported results, BM25 outperformed dense retrieval on the tested financial documents, and HyDE and multi-query expansion offered limited benefit for precise numerical questions. That is exactly why retrieval changes should be evaluated by query type rather than promoted as global defaults.
Adaptive HyDE is more useful than universal HyDE
A practical enterprise system should characterize the query before choosing a retrieval strategy. Exact or numerical lookups may use sparse search, metadata, and hybrid retrieval. Conceptual questions with a vocabulary gap may add HyDE. Multi-hop requests may be decomposed. The resulting candidates can then be fused and reranked through one common evidence stage.
Routing can begin with deterministic features—identifier patterns, quoted phrases, numeric intent, query length, metadata requirements—and expand to a learned classifier only if evaluation shows that the added complexity improves the decision.
The representation layer is already evolving
HyDE proved that the literal user query is not always the best search object. Newer work explores where the hypothetical representation should be created and whether it needs to be synthetic at all.
HyPE: move hypothetical work to indexing time
Hypothetical Prompt Embeddings—HyPE—generate likely questions or prompts for document chunks during indexing. At query time, the system searches those precomputed prompt representations. The work was published in IEEE Access in 2025 and posted to arXiv in 2026. Its authors report gains across six datasets while avoiding a hypothetical-generation call in the live request path. It is compatible with reranking, multi-vector retrieval, and query decomposition.
ReDE-RF: use real documents as feedback
Real Document Embeddings from Relevance Feedback—ReDE-RF—retrieves candidates, asks a model to estimate relevance, and uses selected real documents as the representation for another nearest-neighbor search. The model judges relevance rather than generating a long domain-specific passage. The authors report improved zero-shot retrieval and lower per-query latency across low-resource datasets.
SL-HyDE: adapt the generator and retriever to a domain
In medical retrieval, SL-HyDE uses unlabeled corpora to iteratively refine hypothetical-document generation and retrieval. Its authors report stronger retrieval accuracy than baseline HyDE on their medical benchmark. This remains domain-specific research, but it shows that the hypothesis itself can become an optimized component rather than a fixed prompt.
How to implement HyDE responsibly
- Establish a baseline: measure hybrid retrieval and reranking before adding another model call.
- Keep the original query: use it for sparse retrieval, filters, reranking, intent checks, and debugging.
- Constrain the hypothesis: ask for a short domain-shaped passage; do not ask for citations, certainty, or invented identifiers.
- Preserve access control: run permissions and metadata filters against the real corpus regardless of the search representation.
- Fuse rather than replace: combine original-query and HyDE candidates, then deduplicate and rerank.
- Separate hypothesis from evidence: never expose synthetic text as a source or citation.
- Log the retrieval path: record the query class, hypothetical text, embeddings or version identifiers, candidates, ranks, latency, and cost.
- Add a fallback: if the hypothesis is low-confidence or retrieval deteriorates, revert to the baseline path.
function retrieve(query):
profile = characterize(query)
baseline = hybrid_search(query, filters=profile.permissions)
if profile.semantic_gap and not profile.exact_lookup:
hypothetical = generate_short_hypothesis(query)
hyde_candidates = dense_search(embed(hypothetical))
candidates = reciprocal_rank_fusion(baseline, hyde_candidates)
else:
candidates = baseline
evidence = rerank(query, candidates)
return enforce_permissions_and_thresholds(evidence)The pseudocode is intentionally conservative. HyDE adds a retrieval path only after characterization, while permissions, ranking, and evidence thresholds remain attached to the original request and corpus.
Measure retrieval before judging the answer
A fluent final answer can hide weak retrieval. Evaluate candidate generation and ranking independently so the team knows whether HyDE found better evidence or the generator merely wrote a more persuasive response.
| Layer | Measures | Question answered |
|---|---|---|
| Retrieval | Recall@K, Hit Rate, MRR, nDCG, Precision@K | Did the needed evidence enter the candidate set and rank highly? |
| Evidence | Context precision, context recall, source diversity, permission correctness | Was the selected context useful, sufficient, and allowed? |
| Answer | Correctness, faithfulness, citation support, completeness, abstention | Did the model use the evidence properly? |
| Operations | Latency, generation tokens, search cost, cache hit rate, error rate | Did the quality gain justify the added path? |
| Routing | Lift by query class, route accuracy, fallback rate | Was HyDE used only where it helped? |
Segment the evaluation set. Exact identifiers, numerical lookups, natural-language technical questions, vocabulary mismatches, ambiguous acronyms, and multi-hop comparisons should not be averaged into one opaque score. The routing policy needs evidence about each class.
The broader lesson: model the information need
Early RAG often assumed the user query was the natural unit of search. HyDE breaks that assumption. The information need can be represented as a rewritten query, several queries, sub-questions, a hypothetical answer, synthetic prompts, entities and relations, or structured filters.
That is the bigger evolution from simple RAG to adaptive retrieval: understand the request, choose the representation and retrieval strategy most likely to find evidence, evaluate the evidence, and retrieve again when it is insufficient.
Traditional retrieval says: search first, then construct an answer. HyDE says: imagine what a relevant answer might look like, then search for real evidence resembling it. The technique is clever. The production discipline is knowing when to use it.
Continue learning
HyDE makes the most sense inside a broader understanding of chunking, hybrid retrieval, reranking, adaptive routing, evidence evaluation, and agentic RAG. The One+i RAG learning path covers those layers from first principles through production architecture.
Read: Learning RAG from foundations to production ↗
Read: Adaptive RAG—from fixed pipelines to intelligent retrieval ↗
Explore the Awesome RAG repository ↗
Primary sources and implementation guidance
Research and documentation used for this article
Foundational and comparative research
Gao et al. — Precise Zero-Shot Dense Retrieval without Relevance Labels
The original ACL 2023 HyDE paper: hypothetical document generation, dense embeddings, zero-shot retrieval, and evaluation.
Alushi et al. — Comprehensive Comparison of RAG Methods
EACL 2026 comparison of vanilla and advanced RAG strategies across eight conversational QA datasets.
Akarsu et al. — From BM25 to Corrective RAG
2026 benchmark of retrieval strategies for financial text-and-table documents, including hybrid retrieval, reranking, HyDE, and multi-query expansion.
Representation research
Vake et al. — Hypothetical Prompt Embeddings
HyPE moves hypothetical prompt generation to indexing time and evaluates query-to-prompt matching.
Jedidi et al. — Real Document Embeddings from Relevance Feedback
ReDE-RF uses relevance estimates and real document embeddings instead of long synthetic passages.
Li et al. — AutoMIR and SL-HyDE
Domain-specific self-learning HyDE for zero-shot medical information retrieval.
Implementation documentation
Haystack — Hypothetical Document Embeddings
Current implementation guidance, multi-hypothesis generation, embedding aggregation, and retriever integration.
LlamaIndex — HyDE query transform
HyDE query transformation example, including an instructive ambiguity failure case.
Pinecone — Hybrid search
Managed dense and sparse retrieval patterns that can complement a HyDE path.
Qdrant — Hybrid search
Dense, sparse, fusion, and reranking architecture for high-recall retrieval.