CourseRetrieval-Augmented Generation: The Complete Course · Module 7: Query Understanding and Transformation · part 52 of 95
Part 52 · Module 7: Query Understanding and Transformation

Lab: Rewrite and route every incoming message

63 min read·13 Oct 2026
Module 7 · Lab · About 80 minutes · Needs: lessons 1 to 3 of this module, and the Module 6 lab (or the cells in Step 1)

What you are building

HOLLIN/QUERY/, IN FRONT OF MODULE 6'S SEARCH a message and its chat prepare rewrite.py route rules, then the model documents one index case SQL, session user price calculator none no retrieval measured on 32 questions, tested, committed
The lab's piece: every message is prepared (blue, your code) and routed by rules or the model (amber, uncertain) to one of four places; lookups by the session user are green.

On Friday 9 October Ellie sends four messages: "Is it covered?" after her E7 chat, where her blender is, what a jar and blades cost with delivery, and thanks. Module 6 would search all four as typed. This lab puts hollin/query/ in front. rewrite.py merges Lessons 1 and 2: the code guard, free fixes, condensing and multi-query, each falling back to the question as asked. router.py is Lesson 3: rules first, the model only when needed, a session-scoped case lookup, a calculator and a cache. Documents go to one filtered index, as Lesson 3 measured. Then you measure each transformation on the 32 labelled questions and commit.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.