Skip to main content

Module predict

Module predict 

Source
Expand description

Link prediction: rank candidate entities for an incomplete triple, and the standard ranking metrics (mean rank, MRR, Hits@k). This is the cheap, always-on path — given a trained EmbeddingTable, answer “which tail best completes (h, r, ?)” by scoring candidates and ranking by plausibility.

Enums§

RankFilter
Whether to use the filtered ranking protocol (Bordes et al. 2013): known-true triples other than the target are removed from the candidate set before ranking, so a model is not penalised for ranking another genuine answer above the target.

Functions§

hits_at_k
Hits@k — fraction of test triples whose true tail ranks within the top k.
mean_rank
Mean rank over a set of (h, r, t) test triples, each ranked against candidates (typically all entities). Lower is better.
mean_reciprocal_rank
Mean reciprocal rank (MRR) — mean(1/rank). Higher is better, in (0, 1].
rank_tail
Rank of the true tail t among candidates for (h, r, ?). Rank 1 is best. The rank is 1 + (#candidates scoring strictly higher than the true tail); ties are broken pessimistically by also counting equal-scoring different candidates at half weight is avoided — we use the strict-greater convention (optimistic ties), which is the common reporting choice. Fails closed on bad indices.