Hits@K is a binary, rank-based metric used to evaluate the performance of link prediction models in knowledge graph completion. For a given test query (e.g., predicting the tail entity for (Paris, capitalOf, ?)), the model generates a ranked list of candidate entities. If the correct entity appears within the top K positions of this list, it scores a 'hit' (1); otherwise, it scores 0. The final metric is the average hit rate across all test queries, expressed as a percentage or decimal. Common values for K are 1, 3, or 10, with Hits@1 being the strictest measure of precision.
Glossary
Hits@K

What is Hits@K?
Hits@K is a standard evaluation metric for Knowledge Graph Completion (KGC) that measures the proportion of test triples where the correct entity is ranked among the top K predictions by the model.
This metric is favored for its intuitive interpretation and direct relevance to real-world applications where only the top few model suggestions are considered. It is often reported alongside Mean Reciprocal Rank (MRR) to provide a more complete performance picture. A key nuance is that Hits@K treats all ranks within the top K equally, unlike MRR which rewards higher ranks. The choice of K depends on the use case: Hits@1 assesses exact-match accuracy, while Hits@10 evaluates the model's ability to include the correct answer in a broader candidate set for downstream filtering.
Key Characteristics of Hits@K
Hits@K is a standard evaluation metric for Knowledge Graph Completion (KGC) that measures the proportion of test triples where the correct entity is ranked among the top K predictions by the model.
Definition and Core Purpose
Hits@K is a ranking-based metric that quantifies the success of a Knowledge Graph Completion (KGC) model by checking if the correct entity appears within the top K positions of a ranked list of candidate predictions. Its primary purpose is to evaluate the model's practical utility—in many applications, a user or downstream system only reviews the top few suggestions. A higher Hits@K score indicates a model better at surfacing correct answers early in the results.
- Core Formula: Hits@K = (Number of queries where correct entity rank ≤ K) / (Total number of queries).
- Result: A value between 0 and 1, often reported as a percentage (e.g., Hits@10 = 0.45 or 45%).
The Evaluation Protocol
Calculating Hits@K requires a standardized evaluation protocol to ensure fair comparison between models. For each missing triple in the test set (e.g., (Paris, capitalOf, ?)), the model scores all possible entities that could fill the missing position (the 'tail'). The scores are sorted to create a ranked list. The protocol must carefully handle corrupted triples to avoid false positives.
Key steps include:
- Filtered Setting (Standard): During ranking, all other known true triples present in the training, validation, and test sets are removed from the candidate list. This prevents the model from being penalized for ranking other true facts above the target.
- Raw Setting (Less Common): All entities are ranked, including those that form other known true triples. This typically yields lower, less informative scores.
Interpretation and Common K Values
The choice of K directly shapes the metric's interpretation and strictness. It acts as a utility threshold, reflecting how many predictions a user is willing to consider.
- Hits@1: The strictest measure. It asks: "Is the model's single best guess correct?" This indicates high precision and confidence.
- Hits@3 / Hits@5: Common pragmatic values. They answer: "Is the correct answer in a shortlist I might review?" Balances model confidence with practical recall.
- Hits@10: A broader, recall-oriented measure. Frequently used in academic benchmarks (e.g., FB15k-237, WN18RR). It assesses if the model can place the answer within a reasonably sized candidate pool.
A model excelling at Hits@1 demonstrates high ranking accuracy, while one with strong Hits@10 but weak Hits@1 may have good recall but lack precision in its top prediction.
Comparison with MRR
Hits@K and Mean Reciprocal Rank (MRR) are the two primary metrics for KGC, offering complementary views. Hits@K is a threshold metric, while MRR is a score metric sensitive to the exact rank position.
- Hits@K: Provides a binary, thresholded view. It does not distinguish between a correct answer ranked 1st vs. ranked Kth. It answers: "Was the answer found in the top K?"
- Mean Reciprocal Rank (MRR): Averages the reciprocal of the rank of the first correct answer (e.g., rank 1 gives 1/1=1, rank 3 gives 1/3≈0.33). It is more granular, rewarding models that place the correct answer higher.
Use Case: Hits@K is often preferred for user-facing applications where a shortlist is presented. MRR is favored for benchmarking model quality as it differentiates fine-grained ranking performance.
Advantages and Limitations
Advantages:
- Intuitive Interpretation: Easy to understand and communicate (e.g., "The model gets it right in the top 10 guesses 90% of the time").
- Application-Aligned: Directly reflects the utility in systems where users inspect only top results.
- Simple Computation: Straightforward to calculate once ranks are determined.
Limitations:
- Threshold Dependency: The score is entirely dependent on the chosen K. A model can have a high Hits@10 but a low Hits@1.
- Lack of Granularity: Does not capture the difference between a rank of 1 and a rank of K. Two models with identical Hits@K can have different MRR.
- Assumes Single Correct Answer: In some KGC tasks, multiple entities could be valid for a single query (e.g.,
(person, hasChild, ?)). Standard Hits@K typically considers only one ground truth.
Practical Considerations in Model Development
When optimizing for Hits@K during model development, engineers must consider several factors:
- Loss Function Alignment: Ranking loss functions (e.g., pairwise margin-based loss) are often more directly aligned with improving Hits@K than pointwise losses.
- Negative Sampling Strategy: The quality and difficulty of negative samples used during training critically impact the model's ability to learn discriminative rankings for evaluation.
- K Selection for Reporting: It is standard to report multiple K values (e.g., Hits@1, Hits@3, Hits@10) to give a full picture of model performance across different utility thresholds.
- Domain-Specific K: The optimal K is use-case dependent. For a high-stakes fact-checking system, Hits@1 may be critical. For a knowledge graph search assistant, Hits@5 or Hits@10 is more relevant.
Hits@K vs. Other KGC Metrics
A comparison of Hits@K against other primary metrics used to evaluate Knowledge Graph Completion (KGC) models, highlighting their distinct measurement focuses and use cases.
| Metric | Hits@K | Mean Reciprocal Rank (MRR) | Mean Rank (MR) |
|---|---|---|---|
Primary Measurement | Proportion of correct answers in top K | Average of reciprocal ranks of first correct answer | Average rank of the first correct answer |
Output Type | Binary (hit/miss) | Continuous score (0 to 1) | Continuous score (≥1) |
Interpretation | Higher is better. Measures recall at K. | Higher is better. Balances rank position. | Lower is better. Direct rank penalty. |
Sensitivity to Rank | Low (only cares about top K) | High (penalizes lower ranks sharply) | High (linear penalty with rank) |
Common Use Case | Production thresholding (e.g., top 10 recommendations) | Overall model ranking quality | Diagnosing model performance issues |
Handling of Ties | Ambiguous; depends on tie-breaking strategy. | Sensitive; requires consistent tie-breaking. | Sensitive; average rank can be skewed. |
Typical K Values | 1, 3, 5, 10 | N/A (uses full ranking) | N/A (uses full ranking) |
Robustness to Outliers | High (ignores very low ranks) | Moderate (reciprocal dampens effect) | Low (highly skewed by a few bad ranks) |
Frequently Asked Questions
Hits@K is a standard evaluation metric for Knowledge Graph Completion (KGC) that measures the proportion of test triples where the correct entity is ranked among the top K predictions by the model.
Hits@K is an evaluation metric for Knowledge Graph Completion (KGC) models that measures the proportion of test queries for which the correct entity is ranked within the top K predictions by the model. It is a standard metric used to assess the quality of link prediction models, where a higher score indicates better model performance at placing correct answers near the top of a ranked list.
For example, in a link prediction task where the model must predict the tail entity for a query (head, relation, ?), the model generates a ranked list of all possible entities. If the correct tail entity is ranked 3rd and K=10, this query contributes a 'hit' to the Hits@10 score. The final metric is the average of these binary hit/miss outcomes across all test queries.
Common values for K are 1, 3, 5, and 10. Hits@1 is the strictest, measuring the model's precision for the top prediction, while Hits@10 is more lenient, indicating the model's ability to include the correct answer in a broader candidate set.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Hits@K is a core metric for evaluating Knowledge Graph Completion models. These related concepts define the modeling techniques, complementary metrics, and broader reasoning tasks within the KGC ecosystem.
Knowledge Graph Embedding (KGE)
Knowledge Graph Embedding (KGE) is the foundational technique that enables Hits@K evaluation. It maps entities and relations into a continuous vector space, transforming symbolic triples into numerical representations.
- Purpose: Enables mathematical operations (e.g., similarity scoring) for link prediction.
- Common Models: Translational (TransE), Bilinear (DistMult), Rotational (RotatE), and Neural (ConvE).
- Connection to Hits@K: A model's Hits@K score is computed by ranking the plausibility scores generated by the KGE model for candidate entities.
Mean Reciprocal Rank (MRR)
Mean Reciprocal Rank (MRR) is a complementary evaluation metric that provides a finer-grained performance measure than Hits@K by considering the exact rank of the correct answer.
- Calculation: Averages the reciprocal of the rank of the first correct entity across all test queries.
MRR = (1/|Q|) * Σ (1 / rank_i). - Interpretation: More sensitive than Hits@K; a high MRR indicates the correct entity is consistently ranked near the top, not just within the top K.
- Use Case: Often reported alongside Hits@1, Hits@3, and Hits@10 to give a complete picture of ranking quality.
Link Prediction
Link Prediction is the core machine learning task for which Hits@K is the primary evaluation metric. It involves predicting a missing element in a triple: (head, relation, ?) or (?, relation, tail).
- Objective: To infer unobserved relationships between entities, thereby completing the knowledge graph.
- Evaluation Protocol: The model generates a ranked list of candidate entities for the missing position. Hits@K measures success if the ground-truth entity is in the top K of this list.
- Practical Impact: Directly enhances graph coverage and supports downstream applications like recommendation and QA.
Negative Sampling
Negative Sampling is a critical training technique for KGE models whose performance directly influences the final Hits@K score. It generates false triples to contrast with true facts during model optimization.
- Mechanism: For each true training triple
(h, r, t), one or more corrupted triples (e.g.,(h', r, t)or(h, r, t')) are created as negative examples. - Importance: Teaches the model to discriminate between valid and invalid facts, shaping the embedding space so that true triples score higher.
- Challenge: The quality and strategy of negative sampling (e.g., uniform vs. adversarial) significantly affect model robustness and final ranking accuracy.
Graph Neural Networks (GNNs) for KGC
Graph Neural Networks (GNNs), such as Relational Graph Convolutional Networks (R-GCNs), represent an advanced modeling paradigm for KGC that can outperform pure embedding models, impacting Hits@K benchmarks.
- Approach: Aggregate features from an entity's local graph neighborhood, capturing multi-hop relational patterns.
- Advantage: Can perform inductive learning, making predictions for entities not seen during training—a scenario where standard KGE models fail.
- Evaluation: These models are evaluated using the same Hits@K protocol, but they often leverage richer structural information beyond pairwise triples.
Knowledge Graph Question Answering (KGQA)
Knowledge Graph Question Answering (KGQA) is a key downstream application that relies on high-performing KGC models, with system quality often benchmarked using variants of Hits@K.
- Task: Answer natural language questions by reasoning over a knowledge graph (e.g., "Who directed Inception?").
- KGC's Role: A robust KGC model improves KGQA by ensuring the underlying graph is complete, providing the facts needed to answer complex, multi-hop questions.
- Metric Adaptation: In KGQA, metrics like Hits@1 are critical, as they measure the system's ability to retrieve the single, precise correct answer entity.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us