Glossary
HyDE
A retrieval technique that searches with the embedding of a language model’s hypothetical answer to a query instead of the query itself.
HyDE, short for hypothetical document embeddings, is a retrieval technique that asks a language model to write a plausible answer to a query first, then searches with the embedding of that invented answer instead of the query itself. It serves only as a better search key, because an answer-shaped passage tends to sit closer in embedding space to the real passages that hold the answer than a short question does.
How HyDE works
HyDE was introduced in 2022 by Luyu Gao and colleagues in a paper on zero-shot dense retrieval. It adds one step in front of an ordinary retriever. First, an instruction-following LLM is prompted to write a short passage that answers the query, for example “Write a paragraph from a support article that answers: how do I rotate an API key?” Second, an embedding model encodes that passage into a vector; the original paper generated several passages and averaged their embeddings together with the query’s. Third, a vector search returns the real documents nearest to that vector, and those go into the prompt as in any RAG system.
The generated passage can be wrong in its details and still help. The encoder places it among documents that discuss the same subject in a similar register, and its factual errors never reach the user because only real documents are returned.
Why it helps retrieval
Queries and documents look different. A query is a few words, often phrased as a question, while the passage that answers it is a paragraph of statements with its own vocabulary. This asymmetry is one reason a dense retriever can rank topically similar passages above the one with the answer, a problem explored in Similarity isn’t relevance. HyDE turns the comparison into document against document. The paper reported its largest gains in zero-shot settings, where no labelled query and passage pairs existed to fine-tune the encoder, across a range of information retrieval tasks.
HyDE compared with other query techniques
Technique | What changes | Extra model calls | Best for |
|---|---|---|---|
HyDE | The query is replaced by a generated answer passage | One or more per query | Short questions over long, well-written documents |
Query expansion | Related terms or queries are added | Optional | Vocabulary mismatch |
Query rewriting | The query is reworded for clarity or context | One per query | Follow-up questions in a chat |
Query decomposition | The query is split into sub-questions | One, plus a search per part | Questions that need several facts |
Query expansion broadens the search with related terms, query rewriting cleans up a vague or conversational query, and query decomposition splits a compound question, which is the usual first step in multi-hop retrieval. HyDE can be combined with any of them. Teams often run it beside the plain query and merge the two result lists with reciprocal rank fusion.
Limitations of HyDE
HyDE costs a generation call before every search, which adds latency and tokens. It also depends on the model knowing roughly what an answer looks like. On private or specialised material, such as internal product names or a niche legal domain, the model may write a confident passage about the wrong thing and the search follows it there, a retrieval-side cousin of hallucination.
It adds little for exact lookups. A query for an order number or error code is better served by keyword search or hybrid search, since an invented passage will not contain the right identifier. A reranking step scored against the original query is a common guard, though a reranker can’t fix a bad first pass. Check the gain on your own data with retrieval evaluation metrics such as recall@k before keeping it.
HyDE and Exabase
Exabase has no built-in HyDE step, so the generation runs in your own code in front of Deep Search. Generate the hypothetical passage with your model, send it as the text query to the search endpoint, and pass the matched chunks, with their page numbers or timestamps, into the prompt. Text queries are hybrid by default, so a generated passage is matched on meaning and on keywords, and a precision setting from 0 to 1 controls how many loosely related results come back. Content stored as Resources is indexed when it is written, so the document side needs no separate embedding pipeline.
For facts about users and past conversations, Memory search has query expansion built in: the expandQueries setting runs up to five related retrieval passes and combines their scores, with optional reranking, as the memory search endpoint documents. RAG accuracy covers the wider problem HyDE targets, retrieval that finds the topic but misses the fact. The RAG pipelines use case shows a full setup, and Best RAG infrastructure compares managed options.
FAQs
What is HyDE in RAG?
HyDE is a query technique for RAG in which a language model writes a hypothetical answer to the query, and the retriever searches with that answer’s embedding to find real documents that resemble it.
What does HyDE stand for?
HyDE stands for hypothetical document embeddings.
Does HyDE need a fine-tuned embedding model?
No. HyDE was designed for zero-shot retrieval with an off-the-shelf encoder and no labelled training pairs, though it can also be used with a fine-tuned encoder.
When should you not use HyDE?
Skip HyDE for exact lookups such as IDs and codes, for paths where latency matters most, and for domains the generating model knows little about, where its invented passage can steer the search off course.
Is HyDE the same as query expansion?
They are related but different. Query expansion adds terms or related queries to the original, while HyDE replaces the query with a full generated passage and searches with its embedding.
Can I use HyDE with Exabase?
Yes. Generate the hypothetical passage in your application and send it to Deep Search as a text query; the results come back as ranked chunks with page numbers or timestamps for citations.
Related pages: Retriever, Query expansion, Query rewriting, Dense retrieval, Multi-hop retrieval, Parent document retrieval, Contextual retrieval, Deep Search, RAG accuracy, RAG pipelines use case.