Abstract
Dense retrieval typically requires extensive human-labeled relevance data, which is costly to produce. We present HyDE (Hypothetical Document Embeddings), a zero-shot retrieval method that leverages Large Language Models (LLMs) to generate hypothetical answers to queries. By encoding these "hallucinated" documents rather than the queries themselves, HyDE captures the semantic patterns of relevant information. Our experiments demonstrate that HyDE significantly outperforms unsupervised baselines and rivals supervised models across diverse benchmarks and languages without requiring any training labels.
Introduction
Dense retrieval uses vector embeddings to match queries with relevant documents. However, the performance of these systems often hinges on the availability of large-scale relevance labels (e.g., MS MARCO). In zero-shot scenarios, where such labels are absent, dense retrievers struggle because short queries and long documents occupy different regions of the vector space. Traditional unsupervised methods attempt to bridge this gap directly but often fail to capture the nuances of relevance.
Methodology: Hypothetical Document Embeddings (HyDE)
HyDE introduces a "pivot" strategy to bypass the need for relevance labels. The process consists of three main stages:
- Generation: A query is fed into an instruction-following LLM (e.g., InstructGPT) to generate a hypothetical document that answers the prompt. While this document may contain factual inaccuracies, it adheres to the structural and semantic patterns of a relevant response.
- Encoding: This hypothetical document is processed by an unsupervised contrastive encoder (e.g., Contriever). The encoder's "dense bottleneck" serves as a filter, retaining the broad semantic theme while discarding specific hallucinated details.
- Retrieval: The resulting vector is used to perform a nearest-neighbor search against the actual document corpus, grounding the LLM's generation in real-world facts.
Experimental Setup
HyDE was evaluated across several benchmarks to test its generalizability:
- Web Search: TREC DL19 and DL20 benchmarks.
- Low-Resource Retrieval (BEIR): A suite of seven diverse datasets including SciFact (scientific claims), FiQA (finance), and TREC-COVID.
- Multilingual Retrieval (Mr.TyDi): Evaluation in languages such as Swahili, Korean, Japanese, and Bengali.
The system utilizes off-the-shelf models (InstructGPT and Contriever) "out of the box," requiring no additional training.
Results
HyDE consistently outperforms traditional unsupervised baselines and the long-standing keyword-based BM25 algorithm.
On the TREC DL19 benchmark, HyDE achieved an nDCG@10 of 61.3, a substantial improvement over the 44.5 achieved by the standalone Contriever model. Furthermore, HyDE's zero-shot performance is competitive with supervised models like DPR and ANCE, which are trained on over 100,000 manual labels. In multilingual settings, HyDE successfully improved retrieval even when prompted in English for low-resource languages, demonstrating robust cross-lingual capabilities.
Discussion and Insights
The success of HyDE suggests that generating a relevant-looking answer is easier for current models than directly encoding query-document relevance. The "hallucinations" typical of LLMs act as a feature rather than a bug; as long as the generated text resides in the correct semantic neighborhood, the dense encoder's bottleneck effect filters out noise and maps the vector to relevant real-world documents.
Limitations
Despite its performance, HyDE faces challenges regarding latency and cost, as invoking an LLM for every query is computationally expensive. Additionally, the system's effectiveness is tied to the quality of the underlying LLM and may inherit its inherent biases. Future work may involve using HyDE to generate synthetic training data for smaller, more efficient retrieval models.
Summary updated