promptdojo_

Retrieval that finds the right thing — top-k, thresholds, and the rerank step everyone skips — step 6 of 9

AI wrote retrieve(scored, k=3) that takes the top-3 candidates regardless of how low their scores go. The test query has zero relevant chunks in the corpus, so the top-3 returns three garbage chunks the model would treat as real.

Add a threshold filter (>= 0.5) BEFORE the slice. The function should return an empty list when nothing clears the bar.

Expected output:

[]
The break is on line 10 — but read the whole snippet first.

full-screen editor opens — close anytime to keep reading.