Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

HyDE

Topic: Retrieval and RAGAlso called Hypothetical Document Embeddings

Definition

Hypothetical Document Embeddings: a model writes a fake answer to the query, and that answer's embedding is used to search for real documents.

In more detail

Questions and answers are phrased differently, so a question's embedding may not land near the passages that answer it. HyDE, from a 2022 paper by Gao and colleagues, generates a plausible answer first. Even if its facts are wrong, it uses the vocabulary and shape of a real answer, and its embedding tends to sit closer to relevant documents.

It helps most when queries are short and documents are long or technical, and costs one extra model call per query. The generated text is only used for search, never shown to the user.

  • Embedding

    A vector representation of text or other data that places items with similar meaning close together, so they can be searched by similarity.

  • Query rewriting

    Using a model to turn a user's question into one or more better search queries before retrieval, to find more relevant results.

  • Retrieval-augmented generation (RAG)

    Retrieving relevant documents and adding them to the prompt before the model generates an answer from them.

  • Retrieval-augmented generation

    Fetching relevant documents and adding them to a prompt to ground answers.

    SkillIntermediate

  • Embeddings and vector search, hands on

    Embed documents, store them in Postgres with pgvector, index them and run similarity and hybrid search.

    TutorialIntermediate45 min

  • Query rewriting

    Using a model to turn a user's question into one or more better search queries before retrieval, to find more relevant results.

    Glossary