Skip to content

What is HyDE in RAG?

HyDE generates a hypothetical document from a question and uses its numerical representation to retrieve similar real documents from an indexed text collection.

HyDE, short for Hypothetical Document Embeddings, is a search technique that generates a hypothetical document from a question and uses that text to find similar real documents. A language model, a system that generates text, produces a possible answer; an encoder converts it into an embedding, a numerical representation of the text. The system then retrieves the documents whose representations are closest to that embedding. The generated text may contain errors and should not be cited: its job is to steer the search. HyDE can serve as one component of a RAG pipeline, where a model writes an answer from retrieved documents. In the original paper, Gao and colleagues propose the technique as a way to search without training a new model on relevance labels. Results still need to be checked against the actual collection and questions.

See also: RAGRAG combines search and generation: it retrieves external sources relevant to a question and passes them to a language model, which draws on them to answer.

How it compares with direct search

Direct vector search compares the question's representation with document representations. HyDE instead writes a passage that resembles a possible answer and starts the search from that passage's representation. The authors also average the representations of the generated documents and the original question, so the question is not always excluded from the search. The choice of model, prompt, and encoder can change the results.

In the original evaluation on TREC DL19, HyDE scored 61.3 on nDCG@10, a measure of ranking quality in the top ten results, versus 44.5 for Contriever without HyDE. On TREC-COVID, however, lexical search using BM25 scored 59.5 versus 59.3 for HyDE. These benchmark scores do not predict results on a company's own documents. The BEIR benchmark study also identifies BM25 as a robust baseline across different tasks.

An enterprise example

A team needs to search internal procedures for the checks required before approving a new supplier. With HyDE, the team generates a possible description of the checks and searches the approved documents with that description's vector. The generated paragraph might invent a requirement or omit an exception: the system needs to show the passages actually retrieved, and the person in charge must check that they support the answer. This is an illustrative scenario, not a measured result.

A study of retrieval methods for enterprise RAG used fiction in place of proprietary documents, so the model could not know the answers: in every configuration tested, the study's HyDE variant retrieved the right passage less often than the original question did. For internal procedures, measure any gain before adopting HyDE.

Why it matters for decision makers

Generation adds a step before search, with costs and response times that need measurement. The original paper notes limitations for applications requiring low response times or high request volumes. To decide, compare HyDE with direct and lexical search on the same real questions, checking how many relevant documents are found, what errors occur, and what each request costs. Hybrid search and reranking operate at different stages of the pipeline and can be compared or combined with HyDE. If the gain does not justify the time, cost, and model processing of every question, direct search remains the simpler choice.

Frequently asked questions

No. It may contain made-up information; its job is to steer the search, and any claim in the final answer must be checked against the real documents retrieved.

No. Results depend on the collection, the questions, and the models used; test HyDE against alternatives on real queries.
  • RAGRAG combines search and generation: it retrieves external sources relevant to a question and passes them to a language model, which draws on them to answer.
  • EmbeddingsAn embedding is a numerical representation of content, which lets a system compare it with other content based on the similarity an AI model has learned.
  • Hybrid search and rerankingHybrid search combines lexical and semantic results; reranking reorders the candidates by relevance before showing them or passing them to a language model.
  • Agentic RAGAgentic RAG uses an AI agent to decide how to retrieve information and, if needed, search again based on the results before answering with cited sources.

See it in the universe

If you need the AI in production, not in a demo, that is my job.

See AI integrations

Or write to me.