Command Palette

Search for a command to run...

Hectal
Phase 0: Start Here: What RAG Is and What You Will Build
RAG and Vector Search · Exercise 2 of 5 PreviousNext
Beginner

Retrieve the top k above a minimum score

HANDBOOK is a list of (doc_id, text) pairs and score(question, text) is given.

Write retrieve(question, k, min_score) that returns a list of (doc_id, score) pairs: only passages with score >= min_score, best first, ties kept in handbook order, at most k of them.

What Check tests

  1. The monthly pass question finds D8 then D10
  2. Ties keep handbook order
  3. At most k results
  4. Nothing above the bar gives an empty list

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.