Session 6. A retrieval baseline — Mon 21 Sep
Quick quiz (ungraded)
Q1: A file in the corpus directory has no title header. What should load_corpus do?
A corpus that is quietly one document short produces retrieval scores that look completely normal. Nothing downstream can detect it.
A document with no title is not a document with a blank title. The empty string travels on and fails somewhere with no connection to the cause.
Correct. The whole directory or nothing, and the message names the file so the fix takes seconds.
Q2: retrieve("vector embeddings cosine similarity", documents) returns []. What is the fix?
That converts a visible failure into an invisible one: the same nothing, now dressed as an answer with a score above it.
Correct. No query token appears in any chunk, so the empty list is honest, and the agent refuses before spending a model call.
The model was never shown the passage. No instruction recovers a passage that never reached the prompt.
Q3: A document sits on disk, loads fine by hand, and no query ever returns it. What happened?
Correct. The index is a value computed once, and it is right about the world it was built from. Nothing raises, which is what makes it the dangerous failure.
A low score still appears when you print the scored chunks. This document appears nowhere, at any k.
Then the load would have raised CorpusError and named the file. A rejection is loud; this failure is silent.
Q4: what is a good chunk size returns one hit, structured-outputs#2, scoring 3.18. Why?
It is about parsing failures and retries. Closeness in meaning is exactly what this retriever cannot measure.
Correct. rag-basics writes chunking and chunks, never chunk, and there is no stemming. One shared everyday word carries the whole score.
3.18 sits in the same range as scores from queries that work. The number cannot tell you it is wrong.
Q5: The answer is wrong. Which question do you ask before changing anything?
Correct. No means retrieval — chunking, index, query. Yes means generation — instructions, schema, model. One print answers it.
That assumes generation before checking retrieval. Never prompt-engineer a retrieval failure; a better instruction cannot recover a passage the model never saw.
It would answer the same question from the same context. If the passage was missing, the bigger model invents more fluently.