Skip to content
AI Engineer Guide.

concept · concepts · intermediate · concept 32 of 57

HyDE

0 of 57 complete

Why it matters

Questions and answers are written in different registers: a question is short and interrogative, a passage is declarative and dense. Dense encoders trained on question-passage pairs narrow that gap but do not close it for specialised corpora. HyDE closes it by drafting an answer in the corpus's own style and using that draft as the query, so the vector points at the region where answers live.

Mental model

HyDE is describing a suspect from memory and then searching for people who match the description, rather than searching for the word suspect. The metaphor breaks when the description invents a detail, because the search will faithfully find someone with that invented feature.

How it works

The draft as a record, not as evidenceInteractive

Synthetic HyDE record · query r-4471

One draft · two retrieval lists · four passages

bounding boxes

Step 1/6 · Write the answer first

Step 1Write the answer first

The draft is written in the corpus register: declarative, specific and the length of a passage, because that is the region of the space retrieval has to reach.

HYDE · QUERY r-4471 · DRAFT + ORIGINAL QUERY

, running header, region 1. Select to inspect.

A hypothetical answer as the query

, title, region 2. Select to inspect.
Question

Why did renewal drop after the plan change?

, paragraph Question, region 3. Select to inspect.
Draft

Draft answer: Annual plans moved to a single renewal date, while monthly plans kept their cycle. The cancellation window narrowed from 14 days to 7, so monthly accounts on the Flex plan cancelled before renewal.

, paragraph Draft, region 4. Select to inspect.
DRAFT CHECKS
Draft detailIn passagesAction
Flex plannostrip
14 → 7 daysp3keep
single renewal datep3keep
, table DRAFT CHECKS, region 5. Select to inspect.
Draft tokens48
, form field Draft tokens, region 6. Select to inspect.
Generation1 call
, form field Generation, region 7. Select to inspect.
Encoderdocument side
, form field Encoder, region 8. Select to inspect.
TWO LISTS
PassageDraft rankQuery rank
p311
p723
p9—2
p123—
, table TWO LISTS, region 9. Select to inspect.
Fusionunion 4 · shared 2 · draft only 1 · query only 1
, form field Fusion, region 10. Select to inspect.

48 draft tokens · 3 checked · 1 stripped · 4 passages · 1 generation call

, running footer, region 11. Select to inspect.
11 regions

Step record

Draft tokens
48
Generation
1 call
Register
passage

The text version summarises this figure; select a region for its full text.

Figure. One question, one generated draft and two retrieval lists. The draft names a plan that appears in no passage, so that detail is stripped before embedding; the specifics the passages carry are kept. The draft list and the query list share two passages, which fuse to four unique passages.

What to notice. Synthetic query and draft. The draft text is authored to show the mechanism and is not a model sample; the four passages and ranks are illustrative. The figure shows what has to be separated before a generated answer becomes a query, not a measured recall gain.

Text version

A HyDE record for the question “Why did renewal drop after the plan change?” A draft answer says annual plans moved to a single renewal date while monthly plans kept their cycle, the window narrowed from 14 days to 7, and monthly accounts on the Flex plan cancelled. A table checks three draft details: the Flex plan appears in no passage and is stripped, while the 14 to 7 day window and the single renewal date appear in p3 and are kept. Fields record 48 draft tokens, one generation call and embedding on the document side. A retrieval table gives draft and query ranks for four passages: p3 is first in both, p7 is second and third, p9 appears only in the query list, p12 only in the draft list. Fusion gives a union of four, two shared and one from each list alone. Steps mark the draft, the checks, the encoder choice, both lists, the fusion and the evaluation slice.

  1. Generate a short passage that answers the question in the register and vocabulary of the target corpus.
  2. Strip or flag invented specifics such as names, figures and dates before embedding, since they are ungrounded.
  3. Embed the generated passage with the document-side encoder, not the query-side one.
  4. Retrieve nearest passages to that vector, optionally also retrieving with the original query.
  5. Fuse the two result lists so a bad generation cannot eliminate the original query's hits.
  6. Measure recall against the plain-query baseline, sliced by whether the generated draft contained invented entities.

Trade-offs

ChoiceGood forCostFails when
HyDE aloneStrong recall on terse or jargon-heavy queriesOne generation call and hallucination riskQuestions ask for exact identifiers or figures
HyDE fused with the original queryRobust to a bad draftTwo retrieval passesLatency budget is single-pass
HyDE on every queryUniform pipelinePays generation cost on easy queriesQueries are already long and specific
No HyDECheapest and deterministicQuestion-answer register gap remainsThe corpus is highly specialised
Trade-off mapInteractive

Good for

Strong recall on terse or jargon-heavy queries

Cost

One generation call and hallucination risk

Fails when

Questions ask for exact identifiers or figures

  1. Questions ask for exact identifiers or figures
  2. Latency budget is single-pass
  3. Queries are already long and specific
  4. The corpus is highly specialised

Figure. Each choice with what it buys, what it costs, and the case where it loses.

What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.

Text version

Four trade-offs: HyDE alone is good for Strong recall on terse or jargon-heavy queries, costs One generation call and hallucination risk, and fails when Questions ask for exact identifiers or figures. HyDE fused with the original query is good for Robust to a bad draft, costs Two retrieval passes, and fails when Latency budget is single-pass. HyDE on every query is good for Uniform pipeline, costs Pays generation cost on easy queries, and fails when Queries are already long and specific. No HyDE is good for Cheapest and deterministic, costs Question-answer register gap remains, and fails when The corpus is highly specialised

Failure modes

  • Invented entity anchors the search. The draft names a plausible product that does not exist and retrieval returns passages about it. Debug: diff named entities in the draft against entities in the retrieved passages and the query.
  • Register mismatch. The draft is written like a chatbot reply rather than like the corpus, so the vector is still off-distribution. Debug: compare the draft's style and length with the gold passages for a sample.
  • Generation failure treated as no result. A refusal or empty draft produces an empty vector and zero hits. Debug: validate the draft before embedding and fall back to the original query on refusal.

In production

Cache drafts by query hash and cap their length. Monitor the share of drafts containing entities absent from both the query and the retrieved passages, which is the signal for drift.

Common misconceptions

People think: The hypothetical answer must be correct.

Actually: It only needs to occupy the right region of the embedding space; correctness is not the objective.

People think: HyDE replaces the user's query.

Actually: The original query is still the ground truth of intent and should remain in the retrieval path as a fallback.

Interview angle

Explain the question-answer register gap and why an answer-shaped vector helps. Name hallucinated specifics as the main risk and fuse with the original query. Describing the generation step without saying what happens when the draft is wrong is the incomplete version.

Sources