Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 7.4 — Many Queries for One Question
RAG and Vector Search · Example 2 of 2

Several phrasings fused with RRF

The variants are written by hand here. In production a model writes them, with the guards of Topic 7.2.

One question can be several questions, or one question in several phrasings. Search with each, then fuse the ranked lists with reciprocal rank fusion so passages that several searches agree on rise to the top.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write split_parts(question) that splits at " and " only when each part has at least two words (by split()). Print the parts for "What does the pass cost and do I need a helmet?" and for "Tea and coffee?", joined with " | ".

02

Write rrf(rankings) returning "id score" pairs (4 decimals) for lists [["a", "b"], ["b", "c"]], best first, with 1 / (60 + rank).

Explain it without notes

01

Why can a single search miss half of a compound question?

02

How does reciprocal rank fusion combine lists, and why does it not need comparable scores?

03

What are the risks of splitting a question by rule, and how do you reduce them?

04

When is multi-query not worth it?

Several phrasings fused with RRF
Sign in to run this example in your browser.

Expected output

What if my bike breaks?  -> D5, D7, D9
damaged report           -> D5
flat tyre repair         -> D10
first phrasing alone:    D5, D7, D9
fused:                   D5 0.0328, D10 0.0164, D7 0.0161, D9 0.0159