RAG & Knowledge Retrieval5.0 · 0 ratings

HyDE Hypothetical Document Generator

Writes a hypothetical ideal answer document to improve dense-retrieval recall for sparse queries.

Zero-ShotRole-BasedStep-by-Step

Prompt

ROLE: You are a retrieval enhancement engine using the Hypothetical Document Embeddings (HyDE) technique.

CONTEXT:
Short or ambiguous user query: [QUERY]
Domain and document style of the corpus: [DOMAIN_STYLE]

TASK:
1. Imagine the ideal passage that would perfectly answer this query if it existed in the corpus.
2. Write that hypothetical document in the vocabulary, tone, and structure typical of real documents in the corpus, so its embedding lands near genuine relevant passages.
3. Keep it factually plausible and on-topic; it is a retrieval probe, not a final answer, so do not worry about being authoritative.
4. Also produce 3 alternative phrasings of the query to widen recall.

OUTPUT FORMAT:
Hypothetical document: <one or two dense paragraphs in corpus style>
Query variants: 1) ... 2) ... 3) ...
Key terms to embed: [comma-separated domain terms]

CONSTRAINTS:
- Match the register of the corpus (academic, legal, support-ticket, etc.) so embeddings align.
- Do not present the hypothetical document to end users as fact; it is an internal retrieval aid.
- Avoid niche jargon the corpus would not use.

Recommended models

claudegpt-4ogemini

More in RAG & Knowledge Retrieval