# 假设文档嵌入

假设文档嵌入（Hypothetical Document Embeddings，HyDE）是一种查询时检索技术。在这项技术中，大型语言模型首先生成一份针对用户查询的假设性答案文档，然后对这份生成的文档——而不是原始查询——进行嵌入，并用它来搜索向量索引。该技术由高鲁豫（Luyu Gao）、马学广（Xueguang Ma）、林俊明（Jimmy Lin）和杰米·卡兰（Jamie Callan）在论文《无需相关性标签的精确零样本稠密检索》（"Precise Zero-Shot Dense Retrieval without Relevance Labels"，arXiv:2212.10496，2022年12月）中提出，旨在不微调编码器、不使用相关性标签的情况下改进零样本稠密检索。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>

该技术已在 Haystack 和 [LangChain](https://www.edgepedia.org/zh/langchain) 等主流 RAG 框架中实现。<sup>[2](https://docs.haystack.deepset.ai/docs/hypothetical-document-embeddings-hyde)</sup><sup> • </sup><sup>[3](https://lagnchain.readthedocs.io/en/stable/modules/chains/index_examples/hyde.html)</sup>

| 关键事实 | 细节 |
|---|---|
| 起源 | 高鲁豫、马学广、林俊明、杰米·卡兰，《无需相关性标签的精确零样本稠密检索》，arXiv:2212.10496，2022<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup> |
| 机制 | 大语言模型在查询时生成一份假设性答案文档；该文档用对比编码器（如 Contriever）进行嵌入，并用于最近邻搜索<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup> |
| 标志性结果 | TREC DL19 上 HyDE（Contriever+LLM）的 nDCG@10 为 61.3，而 BM25 为 50.6，无监督 Contriever 为 44.5<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup> |
| MS MARCO 结果 | nDCG@10 为 56.6，而未微调的 DPR 为 43.3<sup>[4](https://github.com/rohinp/atomic-rag/blob/main/docs/techniques/hyde.md)</sup> |
| 成本 | 每次查询增加一次大语言模型推理调用，带来额外延迟和 token 成本<sup>[4](https://github.com/rohinp/atomic-rag/blob/main/docs/techniques/hyde.md)</sup> |
| 2026年现状 | 被报道为一种根据查询类别有条件使用的工具而非默认方案，与现代嵌入模型相比增益正在收窄（厂商报告，未经核实）<sup>[5](https://futureagi.com/glossary/hypothetical-document-embeddings/)</sup> |

## HyDE 是什么

从机制上看，HyDE 在查询时分三步工作。第一步，用提示引导一个指令遵循型大语言模型撰写一份能够回答用户问题的假设性文档。第二步，用对比编码器（如 Contriever，与语料库所用的编码器相同）对该文档进行嵌入。第三步，用得到的向量从索引中检索最接近的真实文档。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup><sup> • </sup><sup>[6](https://www.freecodecamp.org/news/what-is-hyde-how-to-improve-rag-with-hypothetical-documents/)</sup>

这种方法之所以能胜过直接嵌入原始查询，原因在于形状不匹配。稠密检索器将简短的问题与较长的答案段落进行比较，而比较的双方位于嵌入空间的不同区域。生成的假设性段落与真实答案文档具有相同的形状、词汇和术语，因此比较是在同类之间进行的。正如 freeCodeCamp 的教程所说，HyDE 通过“让比较的双方具有相同的形状”来弥合这一差距。<sup>[6](https://www.freecodecamp.org/news/what-is-hyde-how-to-improve-rag-with-hypothetical-documents/)</sup>

假设性文档是一座桥梁，而非答案。它不被视为最终答案，仅用作用户查询与知识库中存储的真实文档之间的桥梁。<sup>[6](https://www.freecodecamp.org/news/what-is-hyde-how-to-improve-rag-with-hypothetical-documents/)</sup>生成文本中的事实性错误不如其主题和术语模式重要，因为检索取决于嵌入，而非内容的真实性。论文作者将这种嵌入描述为捕获了“所需信息的本质”，尽管它们并不对应实际文档。<sup>[7](https://www.educative.io/courses/advanced-rag-techniques/hypothetical-document-embeddings-hyde-simulating-context)</sup>

## 起源与原始论文

HyDE 由高鲁豫、马学广、林俊明和杰米·卡兰于2022年12月在《无需相关性标签的精确零样本稠密检索》（arXiv:2212.10496）中提出。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup><sup> • </sup><sup>[7](https://www.educative.io/courses/advanced-rag-techniques/hypothetical-document-embeddings-hyde-simulating-context)</sup>它针对的场景是零样本稠密检索：在新领域或语料库上使用经对比训练的编码器（如 Contriever），而不使用任何相关性标签或微调。论文将该方法描述为一种将大语言模型中的相关性知识“注入”这一场景的方式，而无需调整编码器。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>

论文报告结果中使用的评估语料库为 TREC 深度学习赛道（DL19 和 DL20）、BEIR 基准的子集，以及多语言 Mr.TyDi 数据集（斯瓦希里语、韩语、日语和孟加拉语）。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>

## 实测效果

最强的报告结果来自原始论文的设定，以下数据经由二手来源转述，而非论文本身。

**TREC 深度学习。** 在 DL19 上，使用 Contriever 的 HyDE 的 nDCG@10 达到 61.3，而 BM25 为 50.6，无监督 Contriever 为 44.5。在 DL20 上，对应数字分别为 57.9、48.0 和 42.1。按完整行数据来看，HyDE 在 DL19 上得分为 41.8 mAP / 61.3 nDCG@10 / 88.0 Recall@1k，在 DL20 上为 38.2 / 57.9 / 84.4。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>

**BEIR。** 在报告的 BEIR 子集上，HyDE 的 nDCG@10 得分为：Scifact 69.1、ArguAna 46.6、TREC-COVID 59.3、FiQA 27.3、DBPedia 36.8、TREC-NEWS 44.0、Climate-FEVER 22.3。它在七个中的六个上胜过了 BM25，但在 TREC-COVID 上基本持平（59.3 对 59.5）。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>一份从业者来源声称 HyDE 在零样本设定下于“11/11”个 BEIR 基准上优于标准稠密检索，在查询较短且词汇差距较大的低资源领域增益最大；<sup>[4](https://github.com/rohinp/atomic-rag/blob/main/docs/techniques/hyde.md)</sup>而上述从论文衍生的子集显示在 TREC-COVID 上持平，这是更为保守的表述，两者并不完全吻合。

**MS MARCO。** 在 MS MARCO 段落检索上，据报道 HyDE 的 nDCG@10 达到 56.6，而未微调的 DPR 为 43.3。<sup>[4](https://github.com/rohinp/atomic-rag/blob/main/docs/techniques/hyde.md)</sup>

**多语言。** 相对于 mContriever，HyDE 在多语言 Mr.TyDi（sw/ko/ja/bn）上提升了 MRR@100。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>

**成本。** HyDE 每次查询增加一次大语言模型推理调用。如果生成器较慢，例如本地 7B 模型，这会带来明显的延迟，建议使用快速或小型模型进行假设生成。<sup>[4](https://github.com/rohinp/atomic-rag/blob/main/docs/techniques/hyde.md)</sup>

## 与其他方案的比较

**查询扩展**向查询中添加词项。HyDE 则生成一整份准文档，这与稠密编码器更为对齐，因为扩展内容与索引段落的形状相匹配。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>

**doc2query / docTTTTTquery** 在索引前用合成查询扩展文档。HyDE 在查询时即时扩展查询，因此无需重新索引语料库。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>

**重排序器**是互补而非竞争的。在 RAG 流水线中，HyDE 用作第一检索阶段，通常后续接 BERT 级[交叉编码器重排序](https://www.edgepedia.org/zh/cross-encoder-reranking)、ColBERT 后期交互，或[倒数排名融合](https://www.edgepedia.org/zh/reciprocal-rank-fusion)（k≈60）以合并混合 BM25 和向量结果。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>

**多查询扩展**也可组合使用：生成多个假设并对其嵌入取平均，Haystack 和 LangChain 均如此实现。<sup>[2](https://docs.haystack.deepset.ai/docs/hypothetical-document-embeddings-hyde)</sup><sup> • </sup><sup>[3](https://lagnchain.readthedocs.io/en/stable/modules/chains/index_examples/hyde.html)</sup>与 query2doc 或直接微调嵌入器的定量比较在本文保留的来源中不可得。

## 局限与失效模式

论文自身指出的局限包括：假设性文档中的幻觉、在高度专业化领域和低资源语言上增益递减，以及大语言模型生成带来的额外延迟和 token 成本。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>大语言模型可能引入事实性错误；以编码器和真实语料库为依据进行锚定可降低这一风险，但无法消除。<sup>[1](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))</sup>

一个更具体的失效模式是自信的错误假设。如果大语言模型生成了一个看似合理但错误的答案，嵌入会将向量搜索导向索引的错误区域。对于高风险检索，推荐的缓解措施是将 HyDE 与多[查询扩展](https://www.edgepedia.org/zh/query-expansion)结合使用，以便同时搜索原始查询。<sup>[4](https://github.com/rohinp/atomic-rag/blob/main/docs/techniques/hyde.md)</sup>

当块较短（三句或更少）且查询与文档的词汇已经重叠时，HyDE 的增益也较小；在这些情况下，基线嵌入通常已经足够。<sup>[4](https://github.com/rohinp/atomic-rag/blob/main/docs/techniques/hyde.md)</sup>一份2026年的从业者指南补充说，HyDE 在广泛的自然语言问题上提升召回率，但在精确查找任务上可能恶化相关性，并建议分别追踪这些查询类别，以免平均分掩盖了退化（厂商报告，未经核实）。<sup>[5](https://futureagi.com/glossary/hypothetical-document-embeddings/)</sup>

## 在 RAG 工具中的采用

HyDE 已内置于至少两个主流 RAG 框架中。Haystack 的实现方式是：提示一个指令遵循型大语言模型生成假设性文档五次，将每次编码为嵌入向量，取平均，然后用单个平均嵌入进行向量相似度检索；检索到的文档随后可送入下游 RAG 生成器。Haystack 将该技术定位为对许多嵌入检索器在新颖、未见领域泛化不佳这一问题的回应。<sup>[2](https://docs.haystack.deepset.ai/docs/hypothetical-document-embeddings-hyde)</sup>

LangChain 提供了一个 HyDE 类，接受基础嵌入模型加上用于生成假设性文档的 LLMChain，默认提示来自论文；多个生成的文档（例如 n=4）通过对其嵌入取平均来组合。<sup>[3](https://lagnchain.readthedocs.io/en/stable/modules/chains/index_examples/hyde.html)</sup>

## 到2026年发生了什么变化

记录中唯一涉及2024–2026年发展的来源是 FutureAGI 的一份厂商术语表，且明确未经核实。根据该指南，截至2026年5月，随着混合搜索和更强的嵌入模型（如 Voyage-3、Cohere Embed v4 和 OpenAI text-embedding-4）的出现，HyDE 在大多数生产语料库上的边际提升已经收窄，现在被描述为一种根据查询类别有条件使用的工具而非默认方案。同一来源指出，原始论文报告 HyDE 在多个 BEIR 任务上以 5–20 个 nDCG@10 点的优势击败稠密检索，而2026年用前沿嵌入模型重跑显示，在大多数任务上差距缩小到 1–4 个点，在实体密集的语料库上甚至变为负值。<sup>[5](https://futureagi.com/glossary/hypothetical-document-embeddings/)</sup>

这些数字应谨慎对待。记录中没有独立的学术复现来验证收窄的说法，原始 arXiv 论文本身也不在本文检索的来源之中，因此上述所有数字均为二手数据。

## References

1. [Hypothetical Document Embeddings (HyDE) — systems analysis](https://systems-analysis.ru/eng/Hypothetical_Document_Embeddings_(HyDE))
2. [Hypothetical Document Embeddings (HyDE) — Haystack Documentation](https://docs.haystack.deepset.ai/docs/hypothetical-document-embeddings-hyde)
3. [Hypothetical Document Embeddings — LangChain docs](https://lagnchain.readthedocs.io/en/stable/modules/chains/index_examples/hyde.html)
4. [HyDE technique notes (atomic-rag docs)](https://github.com/rohinp/atomic-rag/blob/main/docs/techniques/hyde.md)
5. [What Is HyDE? Definition, Examples & FutureAGI Guide (2026)](https://futureagi.com/glossary/hypothetical-document-embeddings/)
6. [What Is HyDE? How to Improve RAG with Hypothetical Documents — freeCodeCamp](https://www.freecodecamp.org/news/what-is-hyde-how-to-improve-rag-with-hypothetical-documents/)
7. [Hypothetical Document Embeddings (HyDE): Simulating Context — Educative](https://www.educative.io/courses/advanced-rag-techniques/hypothetical-document-embeddings-hyde-simulating-context)

---
*Initially written Sep 17, 2026 · Edited: Oct 11, 2026; Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › 基础模型方法与训练 › 提示、推理与智能体

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/hypothetical-document-embeddings

English original: https://www.edgepedia.org/hypothetical-document-embeddings
