Hypothetical Document Embeddings (HyDE) is a query expansion technique that uses a language model to generate a synthetic, ideal document in response to a user query, then encodes that generated document into a vector embedding for similarity search against a vector store. This bridges the semantic gap between short, ambiguous queries and the detailed, factual documents they aim to retrieve by aligning the query representation with the document embedding space.
Glossary
Hypothetical Document Embeddings (HyDE)

What is Hypothetical Document Embeddings (HyDE)?
A query expansion technique where a language model generates a hypothetical ideal document in response to a query, and the embedding of that synthetic document is used to search the vector store instead of the raw query.
The process involves prompting an instruction-tuned LLM to produce a plausible answer or document that directly addresses the query, even if factually incorrect. This hypothetical document captures the structural and linguistic patterns of real documents, and its embedding yields a more discriminative search vector than the raw query embedding alone, significantly improving recall in dense retrieval systems without requiring fine-tuned encoders.
Key Characteristics of HyDE
HyDE (Hypothetical Document Embeddings) is a zero-shot retrieval technique that bridges the vocabulary gap between short queries and long documents by generating a synthetic 'ideal' answer before performing a vector search.
The Query-to-Document Gap
Standard dense retrieval embeds a short user query and searches for similar document chunks. This creates a vocabulary mismatch problem: queries use terse, keyword-heavy language, while documents use expansive, descriptive prose. Embedding both in the same space often fails to capture their semantic equivalence. HyDE solves this by first transforming the query into the document space.
- Problem: Query 'What is a cat?' is short; relevant documents discuss 'feline domestication history'.
- Result: Raw query embeddings often miss nuanced, long-form answers.
Synthetic Document Generation
HyDE instructs a generative language model (like GPT-3.5 or Llama 2) to create a hypothetical document that answers the user's query. The prompt is typically: 'Write a passage that answers the question: [QUERY]'. The model generates a synthetic text that captures the expected style, tone, and factual content of a real answer, even if the generated facts are hallucinated.
- Key Insight: The synthetic document does not need to be factually correct.
- Purpose: It only needs to 'look like' a real document to produce a useful embedding vector.
Embedding and Retrieval
The generated hypothetical document is then passed through a dense embedding model (e.g., Instructor-XL, Contriever) to produce a vector. This vector is used to query the vector database instead of the raw query embedding. Because the synthetic document mimics the structure of real indexed documents, its embedding lands in a dense region of the vector space populated by relevant, real documents.
- Process: Query → LLM → Hypothetical Doc → Embedding Model → Vector → Vector DB Search
- Contrast: Standard retrieval skips the LLM and Hypothetical Doc steps.
Zero-Shot and Language Agnostic
HyDE is fundamentally a zero-shot technique. It requires no fine-tuning, no labeled training data, and no model retraining. It works by chaining two pre-existing, off-the-shelf models: a generative LLM and a contrastively trained embedding model. Furthermore, because the generative model can produce text in any language it supports, HyDE is inherently language agnostic.
- No Training: Works immediately with any generative model and any embedding model.
- Multilingual: Generate the hypothetical document in the same language as the target corpus for cross-lingual retrieval.
Performance and Trade-offs
HyDE consistently outperforms standard dense retrieval (using the raw query embedding) on benchmarks like TREC DL and BEIR. It is particularly effective for complex, fact-seeking queries. The primary trade-off is latency and cost: a full LLM generation step is added before the vector search.
- Latency: Adds 1-3 seconds for the LLM generation call.
- Cost: Incurs token generation costs for every query.
- Mitigation: Use smaller, faster instruction-tuned models (e.g., Llama-3-8B) to minimize overhead.
HyDE vs. Query2Doc
HyDE is closely related to Query2Doc, a contemporaneous technique. Both generate synthetic text to augment retrieval. The distinction is subtle: Query2Doc appends the generated pseudo-document to the original query before embedding, while classic HyDE replaces the query entirely with the hypothetical document's embedding.
- HyDE: Embed only the hypothetical document.
- Query2Doc: Concatenate query + generated doc, then embed.
- Modern Practice: Many implementations now use a hybrid, embedding both and fusing results via Reciprocal Rank Fusion (RRF).
Frequently Asked Questions
Core concepts and operational mechanics of the HyDE query expansion technique for improving retrieval accuracy in RAG systems.
Hypothetical Document Embeddings (HyDE) is a query expansion technique where a language model generates a hypothetical ideal document in response to a user query, and the embedding of that synthetic document is used to search the vector store instead of the raw query embedding. The process operates in two stages: first, a generative model like GPT-4 creates a plausible answer document—even if factually incorrect—that captures the structural and topical patterns of a relevant result. Second, an embedding model converts this synthetic document into a dense vector, which is then used to perform an approximate nearest neighbor (ANN) search against the vector database. This works because the hypothetical document's embedding resides closer to the actual relevant documents in the high-dimensional embedding space than the short, sparse query embedding would, effectively bridging the lexical gap between terse user queries and verbose indexed content.
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
Explore the core retrieval and embedding strategies that complement Hypothetical Document Embeddings (HyDE) to build robust, high-recall RAG pipelines.
Query Expansion
The broader category of techniques that HyDE belongs to, where a user's original query is transformed or augmented to improve retrieval recall. HyDE is a specific, generative form of this.
- Paraphrasing: Generating alternative phrasings of the same query.
- Synonym Injection: Adding related terms to capture lexical variations.
- HyDE: Generating a synthetic answer document to bridge the semantic gap.
Dense Passage Retrieval (DPR)
A foundational bi-encoder architecture that uses separate models to embed queries and documents into a shared vector space. HyDE often operates on top of a DPR index.
- Bi-Encoder: Independent encoding of query and document.
- Dot-Product Similarity: Measures relevance between the two vectors.
- Limitation: Struggles with asymmetric queries where the user asks a question but the document contains a statement.
Semantic Search
The retrieval paradigm that HyDE enhances by moving beyond keyword matching to understand conceptual intent. HyDE converts a short, abstract query into a dense, concrete representation.
- Vector Similarity: Finds documents based on meaning, not just terms.
- Embedding Models: Transform text into high-dimensional vectors.
- Challenge: Short queries provide limited semantic signal, which HyDE directly addresses.
Cross-Encoder Re-ranking
A two-stage retrieval refinement often paired with HyDE. HyDE performs the initial, high-recall retrieval, while a cross-encoder re-ranks the top candidates with high precision.
- Stage 1 (HyDE): Fast, approximate retrieval of ~100 candidates.
- Stage 2 (Cross-Encoder): Jointly processes the query and each candidate for an exact relevance score.
- Trade-off: Maximizes both recall and precision at the cost of added latency.
Instruction-Tuned Embeddings
Embedding models that accept task-specific instructions, allowing a single model to handle asymmetric tasks like query-document matching. This is an alternative to HyDE that bakes the transformation into the model itself.
- Task Prompting: Prefix the query with an instruction like 'Represent this question for retrieval.'
- Unified Model: One model for both query and document encoding.
- Comparison: HyDE uses an external LLM, while this uses an internal model mechanism.
Multi-Vector Retrieval
A strategy where a single document is indexed with multiple vectors representing different aspects, summaries, or hypothetical questions. This is the inverse of HyDE, where the document side is expanded.
- Query Generation: Generate likely questions a document answers and index them.
- Summary Indexing: Index a summary alongside the full text.
- Synergy: Can be combined with HyDE for a dual-expansion approach.

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