Glossary
Hit rate
Hit rate in retrieval is the share of queries for which at least one relevant result appears in the top k, a simple pass or fail measure of whether a search system finds anything useful.
Hit rate in retrieval, usually written hit rate@k, is the fraction of test queries for which at least one relevant item appears in the top k results. Each query scores 1 if any relevant result is in the top k and 0 if none is, and the hit rate is the average of those scores. If 80 out of 100 questions have a correct passage somewhere in the top five, hit rate@5 is 0.8. It is the simplest retrieval metric in common use, and it answers one blunt question: does the system find something useful at all? Because it ignores how many relevant results were found and where they sit in the list, it works best as a quick health check alongside richer metrics.
How hit rate is calculated
For each query, look at the top k results and check whether any of them is relevant according to your judgements. Record 1 for a hit and 0 for a miss. Hit rate@k is the number of hits divided by the number of queries. The same quantity appears under other names: success@k in information retrieval papers, top-k accuracy in classification, and hit ratio (HR@k) in recommender system evaluation, where it often measures whether a single held-out item the user later chose appears in the top k recommendations.
Hit rate@1 is a special case. It is the share of queries whose very first result is relevant, which is the same as precision@1 averaged across queries. For tasks where a system acts on its top result without looking further, such as an agent that takes the first retrieved fact as true, hit rate@1 is often the most telling single number.
A worked example
A team building a knowledge base assistant for an engineering wiki runs ten test questions and records where the first relevant passage appears.
Question | First relevant result | Hit@1 | Hit@5 |
|---|---|---|---|
How do I rotate the staging API key? | 1 | 1 | 1 |
Which team owns the billing service? | 3 | 0 | 1 |
What is the on-call escalation policy? | 1 | 1 | 1 |
Where are the load test results for March? | Not in top 20 | 0 | 0 |
How do I request a new database? | 2 | 0 | 1 |
What does error PAY-221 mean? | 7 | 0 | 0 |
Who approves production deploys? | 1 | 1 | 1 |
What is the retention period for logs? | 4 | 0 | 1 |
How do I add a feature flag? | 1 | 1 | 1 |
What is the SLA for the search API? | 2 | 0 | 1 |
Hit rate@1 is 4 out of 10, or 0.4. Hit rate@5 is 8 out of 10, or 0.8. The gap tells the team that the retriever usually finds the right page but often ranks it second to fourth, so ordering is the main weakness. The two misses at k = 5 have different causes. The load test question fails because the results live in a spreadsheet that was never indexed, a coverage problem. The error code question finds the right page only at position 7, a common weakness of pure vector search with identifiers, which hybrid search usually fixes.
Why hit rate is popular
Hit rate needs very little labelling. Each test query needs only one known relevant item, not a full list of every relevant passage, which makes it a natural partner for generated test sets. A common recipe is to take each chunk in a corpus, ask a model to write a question that the chunk answers, and then check whether retrieval returns that same chunk in the top k for the generated question. The chunk is the known relevant item, so no human labelling is needed. This is a cheap form of synthetic data, and frameworks such as LlamaIndex include retriever evaluators that report hit rate and mean reciprocal rank on exactly this kind of dataset. The Exabase vs LlamaIndex comparison covers how a framework and a managed retrieval layer divide that work.
The approach has a known bias. A question written from a chunk tends to reuse its wording, so keyword matching looks better than it will on real user questions, and other chunks that also answer the question count as misses. Mixing generated questions with a sample of real queries, and checking a handful by hand, keeps the numbers honest. The post on evaluating retrieval without a labelled dataset discusses the trade-offs.
Hit rate is also easy to explain. “The right passage is in the top five for 85% of questions” is a sentence a product manager can act on, which is harder to say about an NDCG of 0.71.
What hit rate misses
Hit rate is binary per query, so it hides a lot. It does not care whether one relevant passage was found or five, so a question that needs evidence from several documents can score a hit while most of the evidence is missing; recall@k measures that coverage. It does not care about position within the top k, so a hit at position 1 and a hit at position 5 count the same; mean reciprocal rank and NDCG reward putting the best evidence first. And it does not care how much noise came along with the hit, which precision and recall and context precision capture.
Hit rate also saturates. As k grows, nearly every query eventually scores a hit, so hit rate@50 can look excellent while answers are poor because the model only reads the top five. Reporting hit rate at the depth your system passes to the model, and at a smaller depth such as 1 or 3, keeps it meaningful. Two systems with identical hit rate@10 can be far apart on every other metric, so it is a weak tool for choosing between close options.
Finally, near-duplicate content inflates it. If the same answer appears in several copies of a document, one of them is likely to land in the top k, and the hit says more about duplication than retrieval quality. Deduplication before indexing, or counting any copy as the same item, avoids the distortion.
Hit rate and cache hit rate
The term also has an unrelated meaning in AI systems. In a semantic cache, or in prompt caching, the hit rate is the share of requests served from the cache instead of a fresh model call. A high cache hit rate saves cost and latency, and it says nothing about whether retrieval found the right evidence. When a dashboard reports “hit rate”, it is worth checking which one it means.
Using hit rate well
Hit rate is most useful early and as a guardrail. Early in a project, a generated test set and hit rate@5 can show within an hour whether a RAG pipeline is broadly working, whether a new embedding model helps, or whether a change to chunking broke something. The post chunking is a workaround, not a design explains why chunk boundaries move these numbers so much. Later, hit rate works as a regression alarm in continuous integration: a drop of a few points on a fixed set of questions is a clear signal to investigate before shipping.
Hit rate@1 is also a natural test for agent memory. When an agent asks which plan a user is on or where they live, there is one current fact, and the agent will usually act on whatever ranks first. A set of single-fact lookups scored at hit rate@1 shows directly how often the current fact wins over an outdated one.
For decisions between close alternatives, such as two rerankers or two precision settings, move to metrics with more resolution. A typical stack reports hit rate@1 and hit rate@k for readability, recall@k at the candidate depth, and NDCG@k at the depth the model reads, all as part of a wider retrieval evaluation. When failures show up, reading them one by one is more useful than any average; 10 RAG failure modes and what causes each is a good checklist for classifying them.
Where Exabase fits
Exabase is the retrieval layer whose hit rate you would measure; the test questions and the scoring script are yours. The synthetic recipe above maps directly onto its APIs. Extract splits a document into text chunks, each with a sequence number and a page number (or timestamps for audio and video), and the chunks endpoint returns them in pages, which gives you the passages to generate questions from. Store the same documents as resources in a dedicated Base so the test corpus is isolated, then run each generated question through Deep Search and check whether the source passage appears among the matched chunks in the top k.
Deep Search returns sub-document chunks with page numbers and timestamps, so a hit can be checked at the passage level rather than the document level, which is the stricter and more useful test. Text queries are hybrid by default, which helps identifier-style questions like the error code example. The precision parameter (0 to 1, default 0.3) changes how many loosely related results come back, and the search endpoint supports an incognito flag so test queries stay out of search history. The RAG accuracy solution explains the retrieval approach, and the knowledge base solution covers keeping the indexed content current, which matters because stale documents turn hits into wrong answers.
Frequently asked questions
What is a good hit rate for retrieval?
It depends on k and the task. Many RAG teams aim for hit rate@5 above 0.9 on real questions; hit rate@1 is usually much lower and is a better guide to how often the top result can be trusted.
What is the difference between hit rate and recall@k?
Hit rate@k asks whether at least one relevant item is in the top k. Recall@k asks what share of all relevant items are there. With one relevant item per query they are equal; with several, hit rate is always at least as high as recall.
What is the difference between hit rate and MRR?
Hit rate counts any relevant result in the top k equally. MRR rewards the position of the first relevant result, so a hit at position 1 scores 1 and a hit at position 5 scores 0.2.
Is hit rate the same as top-k accuracy?
Yes, in practice. Hit rate@k, success@k, top-k accuracy and hit ratio all measure the share of queries with at least one correct item in the top k.
Why is my hit rate high but my answers poor?
Usually because k is larger than what the model reads, the hit is buried below irrelevant passages, or the question needs more evidence than one passage. Check hit rate at the depth you pass to the model, and add recall@k and NDCG@k.
Can I measure hit rate without labelled data?
Yes. Generate a question from each sampled chunk and check whether retrieval returns that chunk in the top k. Treat the result as an estimate, because generated questions tend to share the chunk’s wording.
Related pages: Retrieval evaluation, Recall@k, Mean reciprocal rank, NDCG, Golden dataset, Top-k retrieval, Knowledge bases use case, Best RAG infrastructure, RAG accuracy solution