prompt-eng
Glossary ↗Hypothetical Document Embeddings (HyDE)
Hypothetical Document Embeddings (HyDE) is a retrieval trick that improves search by embedding a fake answer instead of the raw question. Introduced by Gao et al. (2022), the flow is: ask an LLM to write a plausible document that would answer the user's query, embed that hypothetical text, and use its vector to find real documents nearby. The intuition is that a full hypothetical answer sits closer, in embedding space, to genuine answer passages than a short, keyword-poor question does — closing the 'question vs. answer' vocabulary gap that hurts dense retrieval. It works zero-shot, without training a retriever on your data, which makes it attractive early in a RAG project. For builders, it's a drop-in step ahead of your vector search; the generated draft is thrown away, only its embedding is used. Caveats: it adds an LLM call (latency and cost) before every search, and if the model hallucinates an off-topic 'answer,' retrieval can drift — so it helps most when the model has real domain competence.
Related terms