liveBook · Manning

HyDE

As explained in Grokking AI Applications

A query-transformation technique that generates hypothetical answer text and uses its embedding for document retrieval.

When a user’s wording does not resemble the language in stored documents, direct vector search can miss useful chunks. HyDE addresses this by asking an LLM to generate a hypothetical answer, then embedding and searching with that synthetic text. section 4.3

A practical HyDE workflow:

  • Receive the user’s question. section 4.3
  • Prompt an LLM to generate a paragraph that answers the question. section 4.3
  • Use the generated text for vector similarity search in the database. section 4.3

From thirst to drinks

A user asks, “What should I order if I’m thirsty?” Although a menu’s drinks section may not match those exact words, a generated answer about suitable drinks can provide a closer semantic search representation. section 4.3

How Grokking AI Applications covers it

How deep it goes
Defines HyDE and gives Langflow wiring and a prompt, but stops short of implementation internals or evaluation.
Examples
Uses a thirsty customer and drinks menu, plus a Langflow Prompt Template between Chat Input and ChromaDB.
What you can do after
Apply it via Langflow by generating answer-like text, then searching the database with that synthetic text.
How it connects
Connects query transformation, query rewriting, LLMs, embeddings, vector similarity search, Langflow, and ChromaDB.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Applications. The section links point to the parts of the book it draws on.