Query rewriting: transform the user's query before retrieval. Expansion: generate multiple related queries and retrieve for each. Both address the mismatch between how users write queries and how documents are worded.
- 01Describe HyDE (hypothetical document embeddings).
- 02Distinguish rewriting from expansion.
- 03State the cost/quality tradeoff.
Rewriting
Ask an LLM to rephrase the query for retrieval: expand abbreviations, add context, disambiguate. Cheap, effective for short conversational queries. HyDE: generate a hypothetical answer document, embed it, retrieve documents similar to that — retrieval matches document distributions rather than query distributions.
Expansion
Generate 3-5 related queries and retrieve for each; union the results. Improves recall at 3-5x the retrieval cost. Combine with reranking to prune the expanded candidate set.
- Users write queries; documents are written differently.
- HyDE bridges the gap by embedding hypothetical answers.
- Gao et al., 'Precise Zero-Shot Dense Retrieval without Relevance Labels' (HyDE, 2022)