Lesson 3.3

Query rewriting and expansion

In a conversation, a follow-up like "what about the second one" contains almost nothing to match on.

6mAdvanced4.6k students

Overview

The question as asked is often not searchable

In a conversation, a follow-up like "what about the second one" contains almost nothing to match on. Rewriting it against the history into a standalone question is what makes multi-turn retrieval work at all.

Expansion generates several phrasings of the same question, retrieves for each, and merges the results. It rescues queries whose vocabulary happens not to match the corpus.

Rewriting can also destroy intent. Always retrieve for the original query alongside the rewrites, so an over-eager reformulation cannot lose the answer entirely.

In this lesson you will:

  • Resolve pronouns from conversation history
  • Expand a short query into several
  • Avoid rewriting away the user intent

Resources

Previous Lesson
Next Lesson
Query rewriting and expansion — Retrieval-Augmented Generation in Practice — Vertex