Lesson 05.05 · Phase 05 · Retrieval & Agentic RAG

Query rewriting & decomposition

Users write questions; documents contain answers. Put a model between them that turns the question into better searches, and for multi-hop questions, into a sequence of searches where each answer shapes the next.

Learning objectives

  • Implement four query transformations: rewriting, multi-query with rank fusion, HyDE (search with a hypothetical answer), and decomposition into dependent steps.
  • Explain which failure each one targets: chatty phrasing, vocabulary mismatch, and multi-hop questions.
  • Implement sequential decomposition where a step's answer is substituted into the next step's query.
  • Compare strategies fairly, and recognise that no single one wins everywhere.

Lesson 1 sent the user's question straight to the retriever. Users don't write search queries. They write "hey so my kettle smashed when it fell off the counter, will you replace it for free?" The handbook says "The warranty does not cover damage from dropping the appliance." The two share one useful word.

Loading the full lesson…