Precise Zero-Shot Dense Retrieval without Relevance Labels

Luyu Gao, Xueguang Ma, Jimmy Lin, Jamie Callan

Abstract: While dense retrieval has been shown effective and efficient across tasks and languages, it remains difficult to create effective fully zero-shot dense retrieval systems when no relevance label is available. In this paper, we recognize the difficulty of zero-shot learning and encoding relevance. Instead, we propose to pivot through Hypothetical Document Embeddings (HyDE). Given a query, HyDE first zero-shot instructs an instruction-following language model (e.g. InstructGPT) to generate a hypothetical document. The document captures relevance patterns but is unreal and may contain false details. Then, an unsupervised contrastively learned encoder (e.g. Contriever) encodes the document into an embedding vector. This vector identifies a neighborhood in the corpus embedding space, where similar real documents are retrieved based on vector similarity. This second step grounds the generated document to the actual corpus, with the encoder's dense bottleneck filtering out the incorrect details. Our experiments show that HyDE significantly outperforms the state-of-the-art unsupervised dense retriever Contriever and shows strong performance comparable to fine-tuned retrievers, across various tasks (e.g. web search, QA, fact verification) and languages (e.g. Swahili, Korean, Japanese).

Introduction

Dense retrieval—finding relevant documents by comparing semantic embeddings—has traditionally relied on supervised learning. To achieve high performance, these models require thousands of labeled query-document pairs to learn the nuances of "relevance." However, in many real-world scenarios, such labels are unavailable, leading to the "zero-shot" challenge.

Existing unsupervised dense retrievers often struggle because queries and documents are fundamentally different: a query is typically a short question, while a document is a long, detailed answer. Mapping these two distinct types of text into the same vector space without explicit supervision is notoriously difficult. Traditional keyword-based methods like BM25 remain robust but lack semantic depth.

The HyDE Framework

HyDE (Hypothetical Document Embeddings) addresses the query-document asymmetry by decomposing the retrieval task into two distinct steps: generation and grounding.

  1. Generation (The "Hypothesis"): Instead of embedding the query directly, HyDE feeds the query into an instruction-following large language model (LLM). It instructs the model to "write a document that answers the question." This produces a hypothetical document. While this document might contain "hallucinations" or false facts, it captures the essential terminology, structure, and semantic patterns of a relevant answer.
  2. Encoding (The "Grounding"): HyDE then uses an unsupervised contrastive encoder (such as Contriever) to turn this hypothetical document into a vector. This vector is used to search a pre-computed index of real documents.
The HyDE pipeline: An LLM generates a hypothetical document which is then encoded to retrieve real documents.

The key insight is that the encoder acts as a lossy compressor. Because it was trained on document-to-document similarity, it effectively filters out the specific, potentially incorrect details hallucinated by the LLM, focusing instead on the broader semantic neighborhood to find real documents in the corpus.

Experimental Evaluation

HyDE was evaluated across several diverse benchmarks, including web search (TREC DL19/20), domain-specific tasks (BEIR), and multilingual retrieval (Mr. TyDi).

Key Results

  • Outperforming Unsupervised Baselines: On the TREC DL19 benchmark, HyDE achieved a Mean Average Precision (MAP) of 41.8, significantly higher than the standard Contriever (24.0) and BM25 (30.1).
  • Rivaling Supervised Models: Surprisingly, HyDE's zero-shot performance is comparable to models specifically fine-tuned on thousands of labels, such as DPR and ANCE.
  • Robustness Across Domains: As shown in the BEIR benchmark results, HyDE consistently improves over the base Contriever model across various domains, including scientific fact verification and financial QA.
Performance comparison of HyDE against BM25, Contriever, and supervised models across various BEIR datasets.
  • Multilingual Success: Using a multilingual encoder (mContriever), HyDE improved retrieval performance in languages as diverse as Swahili and Korean, demonstrating that the semantic patterns captured by the LLM translate effectively across languages.

Discussion and Insights

HyDE turns a common AI weakness—hallucination—into a feature. The LLM does not need to be factually accurate; it only needs to generate text that looks like a relevant document. By transforming a query into a document-like object, HyDE turns an asymmetric task (query-to-document) into a symmetric one (document-to-document), playing to the strengths of unsupervised encoders.

Furthermore, HyDE is a "plug-and-play" system. It requires no training on the target task and uses off-the-shelf, frozen models. Its performance relies heavily on the instruction-following nature of modern LLMs, allowing it to adapt to different domains (e.g., "write a scientific paper passage") without code changes.

Limitations and Future Work

Despite its effectiveness, HyDE introduces higher computational costs and latency because it requires running an LLM for every search query. Performance can also be sensitive to the specific instructions (prompts) used. Future research may explore "multi-hypothesis" retrieval—sampling multiple documents from the LLM—and techniques to distill HyDE's capabilities into smaller, more efficient models for production environments.

Summary updated

BibTeX
@inproceedings{gao2023precise,
  author = {Luyu Gao and Xueguang Ma and Jimmy Lin and Jamie Callan},
  title = {{Precise Zero-Shot Dense Retrieval without Relevance Labels}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.99},
}
Figure