
HyDE and Query Expansion: Do They Still Help?
An examination of HyDE and query expansion techniques in modern retrieval systems, assessing their continued relevance and performance benchmarks.
In the early days of vector search, practitioners faced a fundamental mismatch: queries are short, sparse, and often ambiguous, while documents are long, dense, and specific. To bridge this gap in NLP, two techniques dominated the conversation: Query Expansion (QE) and hypothetical document embeddings (HyDE). HyDE, introduced by Gao et al. in 2022, asked an LLM to generate a hypothetical document answering the query, then embedded that document instead of the query itself. Query Expansion involved augmenting the query with related terms derived from initial retrieval results or thesauri.
Today, as dense retrieval models like E5 and BGE achieve near-human performance on benchmarks like MTEB, and as context windows expand, the value proposition of these techniques has shifted. They are no longer essential infrastructure but rather targeted interventions for specific failure modes. For most modern systems, the latency cost and error propagation risks outweigh the marginal accuracy gains.
The Mechanism of HyDE
HyDE operates on the premise that a model’s embedding space is better aligned with full sentences than with fragmented queries. When a user asks, "Why is the sky blue?", a direct embedding might struggle to capture the causal relationship if the training data lacks similar short phrases. HyDE bypasses this by prompting an LLM: "Generate a short paragraph explaining why the sky is blue." The LLM produces a coherent text block. This block is then embedded using the same vector encoder used for the corpus.
The mechanism relies on semantic alignment. If the hypothetical document closely mirrors the language and structure of the relevant source documents, the vector distance shrinks. However, this introduces a critical dependency: the quality of the retrieval is now bounded by the LLM’s ability to generate plausible but accurate content that matches the corpus style. If the LLM hallucinates details not present in the corpus, the resulting embedding may point to unrelated documents that share similar surface-level terminology.
Query Expansion: Pseudo-Relevance vs. LLM Generation
Query Expansion comes in two primary flavors, each with distinct failure modes.
Pseudo-Relevance Feedback (PRF) retrieves an initial set of top-K documents, extracts frequent terms from them, and adds them to the original query. For example, searching for "Jaguar" might initially retrieve car reviews. PRF would add terms like "sedan," "engine," and "fuel efficiency" to the query vector. The risk here is catastrophic failure if the initial retrieval is poor. If the first pass returns sports car reviews when the user wanted the animal, the expansion injects noise that pushes the vector away from relevant biological texts.
LLM-Based Expansion uses an LLM to generate synonyms or related concepts. While more flexible than PRF, it suffers from the same issue as HyDE: latency and cost. Each query now requires an additional LLM call or at least a complex prompt engineering step. Furthermore, expanding a query increases the noise of the semantic signal. If the expansion terms are irrelevant, they dilute the core intent, reducing the cosine similarity score for truly relevant documents.
The Modern Baseline: Strong Encoders
The rise of specialized dense retrievers has diminished the need for these workarounds in vector search. Models like E5 (EmbEddings from bidirEctional Encoder rEpresentations) and BGE (BAAI General Embedding) are trained on massive datasets that include both short queries and long documents. They learn to map short queries to the same vector space as long paragraphs effectively.
Recent benchmarks suggest that for general-purpose retrieval, HyDE and QE offer minimal improvement over strong baselines. For instance, independent evaluations by Jina AI and others have shown that while HyDE can improve recall on specific, difficult queries (particularly those with vocabulary mismatch), it often underperforms on standard benchmarks like MS MARCO or BEIR when compared to optimized E5 embeddings. The "magic" of HyDE is largely absorbed by the encoder’s ability to understand context within the query itself, a core NLP challenge.
Consider a scenario where a user searches for "API rate limiting best practices." A direct embedding from a modern encoder will likely capture the intent of "rate limiting" and "best practices" and retrieve relevant documentation. HyDE would generate a hypothetical answer about rate limiting, which might introduce specific algorithms (e.g., "token bucket") not present in the target documents. If the target documents discuss "exponential backoff" instead, the HyDE embedding might misalign.
When to Use Them
Despite their declining general utility, HyDE and QE remain valuable in specific contexts:
- Vocabulary Mismatch: When the query uses highly colloquial or slang terms that are absent from the formal documentation, HyDE can translate the query into standard technical language.
- Ambiguous Queries: For very short queries (e.g., "Java"), expansion can disambiguate based on the corpus domain.
- Legacy Systems: If upgrading the encoder is not feasible, HyDE offers a path to improvement without changing the vector database or index structure.
However, the cost is significant. HyDE adds latency equivalent to an LLM generation step (often 500ms–2s depending on the model). Query Expansion adds computational overhead for term extraction and re-ranking. In high-throughput systems, these costs are prohibitive.
Conclusion
HyDE and Query Expansion are no longer the default solution for retrieval challenges. They are specialized tools for handling specific semantic gaps that modern encoders cannot bridge alone. For most ML and search engineers, the priority should be optimizing the encoder choice, fine-tuning on domain-specific data, and improving chunking strategies. These interventions provide more predictable, scalable, and cost-effective improvements than the fragile, latency-heavy mechanisms of HyDE and expansion. The era of "magic" retrieval hacks is over; the era of engineered embeddings has begun.
Related posts
Fine-Tuning an Embedding Model for Domain Retrieval
A guide to fine-tuning sentence transformers using hard negatives and contrastive learning for improved domain adaptation in retrieval systems.
The Lost-in-the-Middle Problem and How to Route Around It
An examination of the lost-in-the-middle phenomenon in large language models and practical strategies for routing and reordering context to improve retrieval accuracy.
Choosing an Embedding Model in 2026
A practical guide for ML engineers on selecting the right embedding model for RAG systems in 2026, covering MTEB benchmarks, Matryoshka representations, and multilingual support.