Back to glossary

Term

HyDE

HyDE (Hypothetical Document Embeddings) is a RAG technique where an LLM first drafts a fake answer to a query — and then uses that answer's embedding to find real documents.

HyDE — explained in detail

Classic RAG embeds the user’s question and searches for similar documents. The problem: short, vague questions yield poor embeddings because they carry little semantic substance. HyDE addresses this by first having an LLM write a hypothetical answer document — as if the answer were already known. That generated document is embedded and used as the search vector. The embedding of a fully written answer sits closer in vector space to real answer passages than the embedding of the bare question.

Example / Practical use

Question: “What should I do about low iron levels?”. Embedding the query directly is thin. HyDE step: the model writes a short pseudo-answer about iron deficiency, symptoms, and treatment options. That pseudo-document is embedded and used as the search vector. Hits in the knowledge base are then passages that are thematically on point — even if the original question contained none of the relevant keywords. Empirical wins: recall rises notably in zero-shot scenarios and on vague or cross-lingual queries.

HyDE belongs to the query transformation family, alongside query expansion and multi-query RAG. Difference: query expansion produces additional search phrasings, while HyDE produces a full pseudo-document. Weaknesses: weaker LLMs hallucinate pseudo-documents that send retrieval the wrong way; in narrow technical domains without tuning, the pseudo-document misses the real style of the source. Latency increases, because an extra LLM call runs before retrieval.

Entdecke mehr

Themenuebersicht