The HyDE technique, introduced by Gao et al. in 2022, operates on the principle of query-document asymmetry. Short, keyword-based queries and detailed documents exist in different linguistic spaces, making direct embedding comparison suboptimal. HyDE instructs a generative language model, such as GPT, to fabricate a plausible, detailed document that would perfectly answer the query—even if the generated text contains factual errors. The critical insight is that the structure and topical vocabulary of this hypothetical document will closely mirror real relevant documents, creating a dense embedding vector that serves as a far more effective search probe than the original query's embedding.
Glossary
Query Expansion with HyDE

What is Query Expansion with HyDE?
Query Expansion with HyDE (Hypothetical Document Embeddings) is a retrieval technique where a language model generates a hypothetical ideal document from a user query, and the dense vector embedding of that synthetic text is used to perform a similarity search against a real document corpus, bridging the vocabulary gap between short queries and verbose documents.
The process follows a three-stage pipeline: generation, encoding, and retrieval. First, a prompt like 'Write a passage that answers the question' is fed to an instruction-tuned language model to produce the hypothetical document. Next, an unsupervised contrastively trained encoder transforms this synthetic text into a dense vector. Finally, this vector is used to query a vector database via approximate nearest neighbor (ANN) search. Crucially, HyDE is an unsupervised, zero-shot method requiring no relevance-labeled training data, making it immediately applicable to any domain. It is particularly effective for fact-seeking queries where the generated document's topicality compensates for its potential factual inaccuracy.
Core Characteristics of HyDE
Hypothetical Document Embeddings (HyDE) represent a paradigm shift in query expansion, using generative language models to bridge the vocabulary gap between short user queries and the dense, factual language of indexed documents.
The Zero-Shot Grounding Mechanism
HyDE operates on a grounding-by-generation principle. Instead of directly embedding a short, ambiguous query, a language model first generates a hypothetical ideal document that answers the query. The dense embedding of this synthetic, detailed text is then used to perform a vector similarity search against the real document corpus. This process effectively re-anchors the query in the embedding space, moving it closer to the region where actual relevant documents reside, without requiring any task-specific training data.
Contrast with Traditional Query Expansion
Traditional query expansion methods, such as Pseudo-Relevance Feedback (PRF) or synonym expansion, add discrete terms to the original query. HyDE fundamentally differs by generating a complete, coherent passage. Key distinctions:
- PRF assumes top-k initial results are relevant, risking query drift from bad initial hits.
- Synonym expansion only adds words with similar meanings, failing to capture complex contextual relationships.
- HyDE leverages the language model's parametric knowledge to synthesize a document that captures the query's intent in the same verbose, factual style as the target corpus, even if the generated text contains fabricated details.
The Role of the Generative Model
The instruction-tuned language model acts as a query-to-document translator. It is prompted with a simple instruction like, 'Write a passage that answers the question.' The model's output is not required to be factually correct; its purpose is to capture the linguistic pattern and topical density of a relevant document. This synthetic document serves as a dense, high-dimensional proxy for the user's information need, effectively performing a form of unsupervised domain adaptation for the retrieval system.
Unsupervised Corpus Alignment
A core advantage of HyDE is its unsupervised alignment with the target corpus. The generative model produces text in a verbose, explanatory style that naturally mirrors the statistical patterns of the indexed documents. This contrasts sharply with embedding a terse query directly, which often maps to a sparse, low-information region of the vector space. By generating a document-like embedding, HyDE performs a zero-shot transformation that aligns the query representation with the distribution of the document embeddings, significantly improving dense retrieval recall.
Instruction Following for Domain Control
The behavior of HyDE can be steered by modifying the instruction prompt given to the generative model. For a legal corpus, the prompt might be: 'Write a legal memorandum answering the question.' For a medical corpus: 'Write a section of a clinical guideline that addresses the topic.' This simple prompt engineering allows the same core architecture to adapt its generated document style to different domains, controlling the linguistic register and topical specificity of the hypothetical document to better match the target index.
Re-ranking with HyDE
While HyDE is primarily a retrieval-stage technique, its generated document can also be used for re-ranking. The synthetic passage can be fed alongside a candidate document into a cross-encoder model to compute a fine-grained relevance score. This provides a powerful signal because the cross-encoder can directly compare the generated 'ideal' answer with the actual retrieved document, assessing factual overlap and logical consistency beyond simple vector similarity.
Frequently Asked Questions
Explore the mechanics, benefits, and limitations of Hypothetical Document Embeddings (HyDE), a novel technique that uses generative language models to bridge the vocabulary gap between short user queries and the rich semantic content of indexed documents.
Query Expansion with Hypothetical Document Embeddings (HyDE) is a zero-shot dense retrieval technique where a generative large language model (LLM) first creates a hypothetical ideal document in response to a user query, and the dense vector embedding of that generated text is then used to perform a similarity search against a real document corpus. The core mechanism operates in four steps: first, a user query like 'how to mitigate transformer hallucination' is passed to an instruction-tuned LLM with a prompt to 'write a scientific passage that answers the question.' Second, the LLM generates a synthetic document, which may contain factual errors but captures the correct topical essence and linguistic patterns. Third, an encoder model like a Contriever or text-embedding-3-large converts this hypothetical document into a dense embedding vector. Finally, this vector is used to query a vector database via approximate nearest neighbor (ANN) search, retrieving real documents that are semantically similar to the hypothetical one. This process effectively transforms a sparse, keyword-deficient query into a dense, context-rich representation that aligns more closely with the embedding space of the indexed corpus.
HyDE vs. Other Query Expansion Techniques
A technical comparison of Hypothetical Document Embeddings against alternative query expansion methodologies for dense retrieval pipelines.
| Feature | HyDE | Pseudo-Relevance Feedback | Synonym Expansion | LLM Query Rewriting |
|---|---|---|---|---|
Core Mechanism | Generates hypothetical document from query, embeds it for vector search | Extracts terms from top-k initial retrieval results | Adds dictionary or thesaurus synonyms to original terms | Uses LLM to reformulate or decompose original query |
Retrieval Paradigm | Dense vector only | Sparse or hybrid | Sparse keyword | Dense or hybrid |
Requires Initial Retrieval Pass | ||||
Handles Vocabulary Mismatch | Strong: bridges semantic gap via generation | Moderate: limited to terms in top-k docs | Weak: only exact synonym matches | Strong: can introduce new semantic concepts |
Latency Overhead | High: one LLM generation + one embedding inference | Medium: two full retrieval passes | Low: dictionary lookup | High: one LLM generation call |
Risk of Topic Drift | Moderate: hallucinated document may diverge | High: noise from irrelevant top-k docs compounds | Low: synonyms preserve core meaning | Moderate: rewriting may alter original intent |
Cold Start Performance | Strong: no prior relevance data needed | Weak: depends on quality of initial retrieval | Strong: relies on static lexical resources | Strong: zero-shot capability of LLM |
Computational Cost | High: generative model inference | Medium: two retrieval passes | Negligible | High: generative model inference |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Query Expansion with HyDE is part of a broader landscape of techniques designed to bridge the vocabulary gap between user intent and indexed knowledge. The following concepts are essential for understanding the full query understanding pipeline.
Query Expansion
The parent category of techniques that augment the original search query with additional, related terms to improve recall. Unlike HyDE, which generates a hypothetical document, traditional methods include synonym expansion, stemming, and adding terms from a thesaurus. The core goal is to bridge the vocabulary gap between how users phrase a query and how relevant documents are actually written.
Pseudo-Relevance Feedback (PRF)
A classic query expansion technique that assumes the top-k documents from an initial retrieval are relevant. Key terms are extracted from these documents and added to the query for a second, improved retrieval pass. HyDE can be viewed as a generative alternative to PRF, creating a synthetic 'ideal' document instead of relying on potentially noisy initial results.
Dense Retrieval
The retrieval paradigm that HyDE is designed to enhance. Dense retrieval encodes queries and documents into fixed-length vector embeddings using neural networks, enabling semantic matching via approximate nearest neighbor search. HyDE generates a document embedding directly from the query, bypassing the traditional query-embedding step to improve alignment with the document embedding space.
Query Decomposition
The process of breaking down a complex, multi-faceted query into a set of simpler, atomic sub-queries. While HyDE expands a query by generating a hypothetical answer, query decomposition splits it into independently resolvable components whose answers are later synthesized. Both techniques address complex information needs but from opposite directions.
Bi-Encoder Scoring
The underlying architecture that makes HyDE computationally feasible. A bi-encoder encodes the query and each document independently into dense vectors, enabling fast, pre-computed indexing. HyDE leverages this by generating a document-side embedding from the query, which can be compared against pre-indexed document vectors without re-encoding the entire corpus.
Query Expansion with Language Models
The broader category to which HyDE belongs, using generative large language models to produce additional context, keywords, or a hypothetical answer. Variants include:
- Q2D: Query-to-Document generation (HyDE's core mechanism)
- Q2Q: Query-to-Query generation, producing multiple reformulated queries
- Q2E: Query-to-Entity extraction for knowledge graph traversal

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us