Expand description
Link prediction evaluation with filtered ranking.
Computes MRR and Hits@k in the filtered setting: for each test triple
(h, r, t), rank all entities as head replacements and tail replacements,
excluding other known-true triples from the ranking.
“Filtered” means that when computing the rank of a correct entity, we remove all other entities that also form known-true triples from the candidate set. This prevents penalizing a model for ranking another correct answer above the target. See Bordes et al. (2013) for the original protocol.
§Tie-breaking
This implementation uses optimistic tie-breaking: only entities with strictly better (lower) scores than the target increase the rank. Entities with the same score as the target do not count. This gives the best-case rank among tied entities.
§Parallelism
Evaluation is parallelized across test triples via rayon. Each test triple is scored independently against all entities.
Structs§
- Eval
Result - Evaluation results with optional per-relation breakdown.
- Metrics
- Link prediction metrics.
Functions§
- evaluate_
link_ prediction - Evaluate link prediction on test triples in the filtered setting.
- evaluate_
link_ prediction_ detailed - Evaluate link prediction with per-relation breakdown.
- evaluate_
link_ prediction_ sampled - Fast approximate evaluation using random negative sampling.