esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

What Is HyDE?

What HyDE is, how a made-up answer helps find real documents, its costs and limits, explained simply for your AI interview.

In short

HyDE, short for hypothetical document embeddings, has an AI model first write a made-up answer to the question, then searches with that answer instead of the raw question. Real documents that look like the answer come back, which helps when the question and the documents use different words.

11 min readAdvancedOccasional · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

HyDE stands for hypothetical document embeddings. When a question comes in, the model first writes a short made-up answer. The search then looks for real documents that match that made-up answer. The made-up text can have wrong details, but only real documents come back, so HyDE helps when people and documents use different words. It adds several model calls per question, because the paper samples several made-up answers and combines their vectors, so I measure it against plain search before I use it.

What is HyDE, in plain words?

HyDE is a way to search by meaning when the question and the documents use different words. Before it searches, an AI model writes a short, made-up answer to the question. The search then uses that made-up answer to find real documents that look like it.

Picture a claims handler at an insurer who gets a call: a customer's phone was smashed, and they ask whether it is covered. She doesn't flip through the policy from the first page. She first imagines the clause she expects to find, then looks for the clause that reads most like it. HyDE does the same for an AI app, with the model playing the handler.

The same thing happens in a real claims assistant. The customer types short, casual words, such as "Do I get money back if my phone gets smashed?", while the policy uses formal wording like accidental damage and waiting period. A plain search on the customer's words can miss the clause that answers them.

Key words

Embedding
A list of numbers that stands for the meaning of a piece of text. Similar meanings get similar numbers.
Hypothetical document
Made-up text that answers a question. It may be wrong, so it is only used to search.
Encoder
The model that turns a piece of text into an embedding.
Vector search
Finding the stored embeddings that sit closest to the question's embedding.
Corpus
The stored documents that the search covers, such as a policy library.

How does HyDE work, step by step?

The app runs four steps for each question. The chart shows them from left to right.

How HyDE finds the right clause

Customer's question

short, casual words

Model

writes a made-up answer

Search

Turn text into a vector

the meaning as numbers

Find the closest documents

vector similarity

Real policy clause

the text the answer points to

  1. 1The question goes to the model, which writes a made-up answer.
  2. 2The made-up answer goes to the encoder, which turns it into numbers.
  3. 3Those numbers are compared with the numbers of every stored document.
  4. 4The closest real clause comes back. The made-up text stays inside the search.
The customer's question goes to a model, which writes a made-up answer. An encoder turns that answer into a vector, and the search finds the closest stored documents. The real clause that comes back is the one the answer points to.
  1. 1

    Ask the model for a made-up answer

    The prompt is simple, such as "write a document that answers the question". No training is needed for this step.

  2. 2

    Turn that answer into a vector

    An encoder turns the made-up text into a list of numbers that stands for its meaning. The paper used Contriever, a published encoder, for this.

  3. 3

    Search the stored document vectors

    The app finds the stored document vectors closest to the made-up answer's vector. Closeness is a score for how alike two lists of numbers are, called vector similarity.

  4. 4

    Return the real documents

    The made-up text is used only for the search. The real documents are what come back, so the answer can point to text a person can check.

  • “Given a query, HyDE first zero-shot instructs an instruction-following language model (e.g. InstructGPT) to generate a hypothetical document.”

    The HyDE paper, 2022

  • “the generated document is not real, can contain factual errors but is like a relevant document”

    The HyDE paper, on the made-up document

Why does a made-up answer help the search?

The made-up answer copies the shape and wording of a real answer, even when its facts are wrong. A search that compares meanings can then land near the documents that really answer the question. The paper expects the encoder to filter out the wrong details, because it compresses the text into one vector.

  • Raw question

    Few shared words

    Only money and back match the refund note, so the search picks the refund rule and misses the damage clause.

  • HyDE's made-up answer

    Words that match the clause

    Accidental damage, repaired, waiting period and screen all match the damage clause, which is the right one.

Here is a small version in plain Python. No real model runs in it, so the made-up answer is typed in by hand, and word overlap stands in for embeddings. The marked lines are the ones that matter.

Python
# A simplified HyDE step. The made-up answer is typed in, because no real model runs here.
# Word overlap stands in for embeddings, so the code runs with no libraries.
CHUNKS = {
    "damage": "Accidental damage, such as a cracked screen, is repaired after a 30-day waiting period.",
    "refunds": "Refunds: money is paid back only in the first 14 days of the plan.",
    "upgrades": "Upgrades to a newer model are not covered by the plan.",
}

def words(text):
    return set(text.lower().replace("?", "").replace(",", "").replace(".", "").replace(":", "").split())

def best(text):
    return max(CHUNKS, key=lambda name: len(words(text) & words(CHUNKS[name])))

question = "Do I get money back if my phone gets smashed?"
hypothetical = "A smashed phone screen is accidental damage. Accidental damage is repaired or replaced after the 30-day waiting period has passed."

print("raw question ->", best(question))
print("hypothetical ->", best(hypothetical))

Output

raw question -> refunds
hypothetical -> damage

The raw question shares only two words with the refund note and none with the damage clause, so it picks the wrong passage. The made-up answer shares ten words with the damage clause. A real system swaps word overlap for embeddings, which catch meaning rather than exact words.

What are the trade-offs and limits?

HyDE is attractive because it needs no training. The paper says so directly, and it reports that a bigger generating model helped more:

  • “No model is trained in HyDE: both the generative model and the contrastive encoder remain intact.”

    The HyDE paper, on training

  • “with larger models bringing larger improvements”

    The HyDE paper, on model size

The costs are simple to name. Each question needs several extra model calls, one per sampled made-up answer, which adds delay and cost to every search. The made-up answer is only as good as the model that writes it, and it can state false facts, so it must only steer the search and never become the answer.

Where it fits best is early in a project. The paper says HyDE is more powerful and irreplaceable when few relevance labels are present, meaning when nobody has yet marked which documents answer which questions. As a search log grows with labelled examples, a trained retriever can take over more of the work.

How would you use HyDE in a claims assistant?

A mid-size insurer wants its assistant to answer policy questions from 40,000 pages of wording. In a test run with made-up numbers, plain search misses about one question in five. I would not switch everything to HyDE on day one. I would run it as a second search beside keyword search, merge the two lists, and keep the made-up answer out of the reply.

  1. 1

    Build a labelled test set

    About 200 real customer questions, each with the clause that answers it. The labels are the ground truth the search is judged on.

  2. 2

    Compare the three search lists

    Measure plain search, HyDE and the merged list on the same questions before choosing one.

  3. 3

    Watch cost and delay

    Each question adds several model calls. Set a budget per question and alert the team when the average rises.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: the model writes a made-up answer, and search uses it.
  • Why it works: the made-up answer uses the wording of real documents.
  • The trade-off: several extra model calls per question, and possibly wrong details.
  • Why the encoder matters: it turns the text into a vector and filters detail.
  • When to use it: few labelled questions, and a test against plain search.
  • Honesty: the paper's results come from public benchmarks such as TREC DL and BEIR, so measure on yours.

Common traps

  • Trap"The model answers the question, then we return that answer."

    BetterThe made-up answer only drives the search. The real documents are what come back, so the answer can cite them.

  • Trap"HyDE makes the search more accurate in every case."

    BetterThe paper reports gains on public benchmarks, such as TREC DL and BEIR. Measure on your questions before you trust it.

  • Trap"Retrain the embedding model on our questions first."

    BetterHyDE needs no training. That is its appeal, so start there and add training only if the numbers ask for it.

Can you spot the problem?

Spot the problem

Your team builds a HyDE step for an insurer's claims search. Which setup is the risky one?

Quick check

Why does HyDE search with a made-up answer instead of the raw question?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q127What are query rewriting and expansion?11 min
  2. Q123What is hybrid search (BM25 + vectors)?11 min
  3. Q126Rerankers: cross-encoder vs bi-encoder?12 min
  4. Q131Retrieval metrics: recall@k, MRR, nDCG?12 min
  5. Q120How does HNSW work?11 min
  6. Q129What is metadata filtering?10 min

Learn it in depth

Last updated on 27 November 2026

Building search over your own documents?

I design and build AI products and agents, including the UI and the system behind them. Book a short call and tell me what your search needs to find.