Skip to main content

What are query rewriting and HyDE, and when do they help?

RAG · Intermediate 3

Short answer

Users ask short, vague or conversational questions that do not match how documents are written. Query rewriting has a model turn it into a clearer standalone query, or several variants. HyDE, hypothetical document embeddings, asks the model to write a fake answer and searches with its embedding, because an answer looks more like the documents than the question does.

Deeper answer

Rewriting is essential in chat, where 'what about for seniors?' only makes sense with history. Multi-query retrieval searches with several phrasings and merges the results, improving recall.

Both add a model call, so latency and cost go up, and a bad rewrite can drift from the user's intent. Measure on your eval set; for keyword-heavy queries such as error codes, hybrid search may help more.

What a strong answer covers

Answer it out loud in the mock interview about 1.5 min

Follow-ups to expect

Common mistakes

Learn it

Query rewriting, HyDE and parent-child chunks

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.