Retrieval: Picking the Best Notes, and Admitting When None Fit

Cap retrieval at the top k chunks and drop anything below a similarity threshold, so the model gets relevant context or none.

Part of: Personal Notes Brain

Ranking every chunk in lesson 2 is not retrieval on its own. It just orders everything. A real retriever also decides how many chunks to hand the model and whether any of them are good enough to send. That second decision matters more than it sounds. Forcing through the best match when even the best match scores 0.1 is how RAG apps confidently answer questions their notes never covered. Two knobs: k and threshold - k caps how many chunks you send. Keep it small; 3 to 5 is typical. More chunks means more tokens, more cost, and more room for the model to get distracted by a weaker chunk. - threshold is a minimum similarity score. A chunk that ranks first among bad options is still a bad option if its score is 0.12. Anything below the threshold gets dropped, even when it would otherwise make the top k. Filter before you slice to k, not after. Slice first and you might keep three barely-relevant chunks because nothing better existed. Filter first and an empty or short result becomes the honest signal that nothing in the vault matches. Tuning the threshold There is no universal right number. It depends on your embedding model and how tightly your notes are written. Start around 0.3 to 0

Challenge: Retrieve the Top-K Above Threshold