Where we left off

Lessons 6-7 built one rewrite strategy: ask Gemini to rephrase a query when everything graded not-relevant. That's one tool for one job. This lesson names three distinct strategies, useful for different failure shapes:

  • Broadening: a question too specific to match a passage that discusses the same idea in more general terms.
  • Narrowing: a question too vague to distinguish between passages, adding concrete, likely-relevant terms.
  • Decomposing: a question that's actually two (or more) questions at once, split it, retrieve each part separately.

Tuning signal, stated explicitly

Per this course's cross-course convention (see docs/RAG-SERIES-PLAN/README.md's eval-methodology note), any lesson that tunes something needs to say plainly whether that tuning came from a held-out signal or from the same labeled set Lesson 17 reports its score against. This lesson's heuristic is safe: which strategy to try for which failure shape (compound → decompose, vague → narrow, over-specific → broaden) was chosen by inspecting the failure shapes Lessons 6-12 already demonstrated by hand, not by sweeping strategies against Lesson 17's five labeled questions and keeping whichever scored best there. If it had been tuned that way, Lesson 17's score would be measuring how well the heuristic was fit to the five questions it's also graded on, not whether the heuristic actually generalizes.

The code, piece by piece

sub_questions = [
line.strip() for line in call_model(DECOMPOSE_PROMPT.format(question=compound_question)).splitlines()
if line.strip()
]

Decomposition, unlike the other two strategies, changes how many queries get retrieved, one compound question becomes several simple ones, each retrieved independently, then whatever downstream step needs both answers (generation, usually) sees results from both.

Checkpoint

  • Three rewrite strategies for three different failure shapes: broadening, narrowing, decomposing.
  • Decomposing a compound question and retrieving each part separately produces a stronger, less-averaged signal per source, even when a combined query already happens to work on a small corpus.
  • This lesson's strategy-selection heuristic is tuned against Lessons 6-12's hand-inspected failure shapes, a signal separate from Lesson 17's labeled evaluation set, not against that set itself.

If anything here still feels unclear, ask before moving to Lesson 15.