What is HyDE?
HyDE is a retrieval technique that, instead of searching the user's question directly, first has a language model write a hypothetical answer, then embeds that answer for vector search to get a query vector closer to real documents.
The name stands for Hypothetical Document Embeddings. Unlike query expansion, which adds terms to the original query, HyDE replaces the query with new text in document form. The hypothetical answer is used only for search and is never shown to the user.
- Topic
- Embeddings, document processing and RAG
- Also known as
- Hypothetical Document Embeddings
- Origin
- 2022, Gao, Ma, Lin and Callan
How HyDE works
- The question goes to a language model, which writes, without context, a short document that might answer it.
- This hypothetical document is turned into a vector by the embedding model.
- The vector is matched against real chunks in the index and the nearest are retrieved.
- The answer is generated from the retrieved real chunks, not the hypothetical text.
In more detail
Multiple hypothetical documents and vector averaging
In the original Gao et al. (2022) formulation, the LLM generates multiple (N) diverse hypothetical documents for a query and their embedding vectors are averaged, optionally alongside the original query vector, to reduce single-sample hallucination variance. Single-document HyDE is a lower-latency simplification.
Where HyDE falls short and the BM25 caveat
HyDE is designed for dense semantic retrieval and works poorly when queries contain exact identifiers (error codes, SKUs, clause numbers) or proprietary internal acronyms unfamiliar to the LLM; in such cases, feeding hallucinated hypothetical text into BM25 keyword search can actually harm precision.
Where it stands against modern asymmetric embedding models
Modern instruction-tuned asymmetric embedding models (trained on massive query-to-passage datasets) already bridge much of the gap HyDE addressed in 2022. As a result, HyDE is often reserved selectively for short, underspecified or cross-style queries rather than applied unconditionally to every request.
Commonly confused terms
| Term | How it differs |
|---|---|
| Query rewriting | Query rewriting clarifies, resolves coreferences or decomposes an ambiguous user question into cleaner search queries, whereas HyDE transforms the question into an answer-shaped passage to bridge query-document embedding asymmetry. |
Why HyDE matters for on-premises AI
Short, informal questions can sit far in vector space from formal company documents; HyDE bridges this gap with intermediate text in document form. The hypothetical answer may be wrong, but it only serves as a search vector, so its content never reaches the user. The price is an extra generation call per query, adding latency and GPU load. A model unfamiliar with the domain can pull the search the wrong way, so the effect is measured on the organisation's question set.
In an insurer's assistant the question “is a hire car covered after an accident” is turned into a hypothetical policy clause; searching with it finds the replacement vehicle clause more easily.
Common questions
Does HyDE give invented information to users?
No. The hypothetical answer only produces a search vector. The answer users get is generated from retrieved real documents.
When does HyDE help?
When questions are short and informal while documents are long and formal. It needs an extra model call, so weigh the cost in latency-sensitive systems.
Related terms
- Query expansion
- Query rewriting
- Dense retrieval
- Retrieval-Augmented Generation
- Embedding model
- Multi-query retrieval
Sources
In the glossary: Glossary, D to L