A user asks a RAG-based support bot 'my payment keeps bouncing,' but the underlying documents describe the same problem using the phrase 'transaction declined by issuing bank.' A dense-embedding search using the literal query text sometimes misses these documents because of this vocabulary mismatch. A technique called HyDE (Hypothetical Document Embeddings) was designed to address exactly this kind of mismatch. How does it work?
- It expands the query by appending every synonym of each query word found in a static thesaurus, then searches using the combined, longer query text
- It retrains the embedding model on the specific vocabulary of the document collection immediately before each individual query is issued
- It prompts a language model to generate a hypothetical answer to the query first, then embeds that generated hypothetical answer, rather than the original query, and uses that embedding to search the index, on the theory that a plausible answer is likely to use vocabulary closer to the real documents than the short original query does
- It translates the query into several other languages and searches the index once per language before merging all of the results together
Why C? And why not the others?
Correct answer: C. It prompts a language model to generate a hypothetical answer to the query first, then embeds that generated hypothetical answer, rather than the original query, and uses that embedding to search the index, on the theory that a plausible answer is likely to use vocabulary closer to the real documents than the short original query does
HyDE addresses the vocabulary mismatch by having a language model first write a hypothetical answer to the query, essentially imagining what a document that answers the question might say, and then embedding that generated passage instead of the original short query; because a fabricated answer written in the style of the domain is likely to use phrasing closer to the actual documents, such as 'declined by issuing bank' rather than the user's own words, the resulting embedding lands closer to the relevant real documents in vector space than the original query's embedding would have. The option describing thesaurus-based synonym expansion is wrong because it is a much older, purely lexical technique that appends related words to the query text itself rather than generating and embedding a hypothetical document with a language model. The option describing per-query retraining of the embedding model is wrong because retraining a model before every individual query is computationally infeasible, and HyDE deliberately leaves the embedding model untouched. The option describing multilingual translation and per-language search is wrong because that addresses a mismatch between different languages, not the same-language vocabulary mismatch described here, and it is not what HyDE does at all.
Source: Gao, Ma, Lin & Callan, 'Precise Zero-Shot Dense Retrieval without Relevance Labels' (2022), arXiv:2212.10496