Top-k (retrieval)
The number of highest-ranked search results passed on to the next step; in RAG, how many passages go into the prompt.
A small k keeps the prompt short and cheap but risks leaving the needed passage out; a large k raises recall and adds noise, cost and latency. A common setup retrieves a wide set, for example 50, and lets a reranker keep the best few. The same term is used for a sampling setting in text generation, where the model picks the next token from the k most likely ones; that is a different thing.
Related terms
- Reranker: A model that rescores the top search results against the query, so the most relevant ones go to the language model first.
- Recall (AI metric): The share of all correct items that the system actually found: of everything it should have caught, how much it did.
- RAG (retrieval-augmented generation): Finding relevant documents first and putting them into the prompt, so the model answers from them.
- Context precision: A RAG retrieval metric: whether the passages relevant to the question are ranked at the top of what was retrieved.
