HyDE bridges the query-document language gap

Luyu Gao and coauthors introduced HyDE in 2022 for zero-shot dense retrieval. A user query may be too short or phrased unlike the documents that answer it.

Generating a plausible document gives the encoder a richer representation that may sit closer to relevant corpus passages.

The system embeds the generated text, retrieves real documents, and answers from those sources. The hypothetical text has done its job once it has improved the search query.

Acronym-heavy documentation creates a useful case

For “why does my login expire?”, a hypothetical passage might mention session lifetime, refresh tokens, and token revocation. Those terms can retrieve the correct authentication documentation even when the original question contains none of them.

The hypothetical passage should resemble the kind of document the index contains. Generating a conversational answer for a corpus of terse reference entries can create a new representation mismatch instead of closing the old one.

Query expansion may generate terms; HyDE generates a document

Traditional query expansion adds related words or alternate queries. HyDE generates answer-shaped prose and embeds it.

Self-querying retrieval instead extracts structured filters and a semantic query from the request.

The hybrid search guide covers another way to handle vocabulary mismatch. HyDE is a poor fit when invented specifics can pull retrieval toward the wrong domain, and the common misuse is quoting the hypothetical document as though a source had said it.

The generated text must remain outside the evidence set

A safe implementation labels the hypothetical document internally and keeps it separate from retrieved sources. If the generation invents a product name or technical term, retrieval may follow that invention and return a coherent but irrelevant neighborhood.

Evaluation should compare retrieval with and without HyDE on the same queries, then inspect both gains and regressions. The method earns its extra model call only when it improves access to real answer-bearing documents.

Continue with these glossary entries: