Top-K Retrieval
Grabbing the k best-matching chunks for a query — where k is how many you decide to pull.
Think of it like
Asking for the top five recommendations, not the entire ranked list of everything.
Example
With k set to 5, a question retrieves the five most relevant document chunks to stuff into the prompt.
How it actually works
K is one of the most consequential knobs in retrieval: too small and you miss the chunk with the answer, too large and you flood the context with noise and cost. There’s no universal right number — it depends on chunk size, model context, and how scattered the answer is. Because raw top-k by similarity is often imperfect, teams frequently over-retrieve and then rerank down to the truly best few.
For product teams
K trades recall against noise and cost — tuning it is one of the cheapest wins in a retrieval system.
For engineers
Return the k highest-scoring items from the retriever, k being a tunable recall-versus-noise parameter.
Related
- Similarity Search — How the matches are ranked.
- RAG — What the retrieved chunks feed.
- Reranking — Cleaning up the top-k before use.
Read anything AI without the jargon
Look up any term in plain English, or save terms as you read with the free Chrome extension.
Open DecoderAdd to Chrome