Measure retrieval before you tune it
Put a number on how often the right page is found, then change one thing and see if the number moves.
You build: evalset.jsonl with 20 questions, eval.py, and a before and after table.
- Python 3.11 or newer and uv
- Lab 21 done
-
01Write 20 questions, each with the file that holds the answer
wc -l evalset.jsonlYou pass when: 20 lines. Include five that use different words from the page.
-
02Print recall at 4 and the mean reciprocal rank
Recall at 4: how often the right page is in the four chunks you fetch. Reciprocal rank: 1 if it is first, 1/2 if second, and so on.
uv run --with requests --with "psycopg[binary]" eval.py evalset.jsonlYou pass when: Two numbers between 0 and 1, and a list of the questions that missed.
-
03Change one thing: chunk size, overlap, or a rerank step
uv run --with requests --with "psycopg[binary]" eval.py evalset.jsonl --label afterYou pass when: The same two numbers for the new setup.
-
04Write the before and after in a table and keep or revert the change
cat RESULTS.mdYou pass when: Two rows and a one-line decision. A change that does not move the number is reverted.
The check runs on the computer, not on your word: a step passes when its command exits with 0 there.
Computers are not set up on this site yet. Run each command on your own machine and compare with "You pass when".
Commands run in labs/22-rag-evals and may take up to 60 seconds each. Every command starts a new shell: put keys and settings in a .env file there, it is loaded each time.