AI Wiki中文/EN

Entity linking: which Mercury does this mention mean?

实体链接

Use aliases and context to rank candidates, then separate missing candidates from uncertain decisions.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

The same mention points to different entities

“Mercury has an unusual orbit” and “Mercury is a toxic liquid” use the same spelling. Linking both mentions to a planet would preserve the text while corrupting its meaning. Entity linking associates a mention in context with an entity identifier in a target knowledge base. Detecting the mention span is a separate problem.

Hogan and colleagues describe both sides of the ambiguity: one entity can have multiple aliases, and one mention can refer to different entities. PDF 51 BLINK studies linking with given mentions, retrieves candidates with a bi-encoder, and reranks with a cross-encoder. Its reported task assumes that a correct entity exists in the knowledge base; NIL prediction is explicitly left outside that scope. PDF 2–3

Our inspectable baseline uses an alias table and entity descriptions. It fits TF-IDF statistics, combines context similarity with alias frequencies, and can abstain. That last action means “this baseline will not choose,” not “the real entity definitely does not exist in the knowledge base.”

The same Mercury mention selects different candidates with context; missing candidates and low-evidence decisions remain visible.
The same Mercury mention selects different candidates with context; missing candidates and low-evidence decisions remain visible.

Separate retrieval, evidence and the final decision

For mention m, the alias table supplies candidates C(m) and positive counts n(m,e). We normalize these counts into a mention-conditioned prior:

p(e∣m)=n(m,e)∑j∈C(m)n(m,j).p(e\mid m)=\frac{n(m,e)}{\sum_{j\in C(m)}n(m,j)}.

This prior expresses the table’s frequency evidence, not the current context. Our authored Mercury counts are 60 for the planet, 30 for the metal and 10 for the messenger. Without contextual evidence, the planet wins even in a sentence about poisoning.

Fit inverse document frequencies on N entity descriptions. For term w, df(w) counts descriptions containing it; tf(w,d) is its occurrence count in description or context d. We use:

idf⁡(w)=1+log⁡N+1df⁡(w)+1,vw(d)=tf⁡(w,d)idf⁡(w).\operatorname{idf}(w)=1+\log\frac{N+1}{\operatorname{df}(w)+1},\qquad v_w(d)=\operatorname{tf}(w,d)\operatorname{idf}(w).

The constants smooth rare terms. Context words outside this vocabulary contribute nothing. Normalize each nonzero vector to unit length. Then its dot product is cosine similarity; an empty or all-unknown vector receives zero similarity by our convention:

c(d,e)={v(d)⊤v(e)∥v(d)∥2∥v(e)∥2∥v(d)∥2∥v(e)∥2>0,0otherwise.c(d,e)=\begin{cases}\dfrac{v(d)^\top v(e)}{\|v(d)\|_2\|v(e)\|_2}&\|v(d)\|_2\|v(e)\|_2>0,\\0&\text{otherwise}.\end{cases}

The toy ranker uses a declared convex mixture, not a learned BERT score:

s(e;m,d)=(1−α)c(d,e)+αp(e∣m),α=0.15.s(e;m,d)=(1-\alpha)c(d,e)+\alpha p(e\mid m),\qquad\alpha=0.15.

Descriptions contain four distinct words each. With three matching context words, the cosine is √3/2. The resulting scores for the correct planet, metal and messenger contexts are approximately 0.826122, 0.781122 and 0.751122. The context can overcome the more frequent planet alias. In general, the same score formula would need validation before choosing α.

Let e₁ and e₂ be the two highest-scoring candidates, τ an absolute threshold and δ a margin threshold. Our decision rule is:

e^={e1C(m)≠∅, s1≥τ, s1−s2≥δ,abstainotherwise,τ=0.35,δ=0.08.\widehat e=\begin{cases}e_1&C(m)\ne\varnothing,\ s_1\ge\tau,\ s_1-s_2\ge\delta,\\\mathrm{abstain}&\text{otherwise},\end{cases}\qquad \tau=0.35,\quad\delta=0.08.

For a single candidate, the margin is treated as infinite, but the absolute threshold still applies. Empty candidate sets get a separate no-candidate reason. Scores are not calibrated probabilities; a high relative margin with almost no evidence should not force a decision.

Candidate retrieval places a hard ceiling on a reranker that can choose only from its candidate set. On a dataset whose gold entities are in the knowledge base:

accuracy⁡end-to-end≤recall⁡candidate=1M∑i=1M1[ei∗∈C(mi)].\operatorname{accuracy}_{\rm end\text{-}to\text{-}end}\le\operatorname{recall}_{\rm candidate}=\frac1M\sum_{i=1}^{M}\mathbf1[e_i^*\in C(m_i)].

The inequality follows because a correct output requires candidate inclusion. It does not equate recall with accuracy: an included entity may still be misranked or rejected. BLINK’s bi-encoder/cross-encoder separation addresses these distinct stages with learned representations. PDF 3

Make candidate failure visible

Run the complete program with Python 3.12 and its standard library. Mentions are given; descriptions and frequency counts are authored examples. English words are tokenized with a small regular expression. The Chinese alias 水星 is an exact alias string, not evidence of a Chinese tokenizer.

"""Authored alias/TF-IDF linking baseline, not BLINK or a NIL classifier.

Mention spans are given. Threshold abstention does not prove out-of-KB status.
"""
import json
import math
import re
from collections import Counter


def tokens(text):
    return re.findall(r"[a-z]+", text.casefold())


def fit(descriptions):
    if not descriptions:
        raise ValueError("Need entity descriptions")
    counts = {e: Counter(tokens(text)) for e, text in descriptions.items()}
    df = Counter(w for c in counts.values() for w in c)
    idf = {w: math.log((1 + len(counts)) / (1 + d)) + 1 for w, d in df.items()}

    def vector(text_counts):
        v = {w: c * idf[w] for w, c in text_counts.items() if w in idf}
        norm = math.sqrt(sum(x*x for x in v.values()))
        return {w: x/norm for w, x in v.items()} if norm else {}
    return idf, {e: vector(c) for e, c in counts.items()}


def rank(mention, context, aliases, model, prior_weight=0.15):
    if not math.isfinite(prior_weight) or not 0 <= prior_weight <= 1:
        raise ValueError("Prior weight must lie in [0,1]")
    idf, entities = model
    candidates = aliases.get(mention.casefold(), {})
    if not candidates:
        return []
    if any(e not in entities or not math.isfinite(c) or c <= 0 for e, c in candidates.items()):
        raise ValueError("Positive alias counts and known entity descriptions required")
    counts = Counter(tokens(context))
    v = {w: c*idf[w] for w, c in counts.items() if w in idf}
    norm = math.sqrt(sum(x*x for x in v.values()))
    v = {w: x/norm for w, x in v.items()} if norm else {}
    total = sum(candidates.values())
    scores = [(e, (1-prior_weight)*sum(x*entities[e].get(w, 0) for w, x in v.items())
               + prior_weight*c/total) for e, c in candidates.items()]
    return sorted(scores, key=lambda row: (-row[1], row[0]))


def decide(scores, threshold=0.35, margin=0.08):
    if not math.isfinite(threshold) or not math.isfinite(margin) or margin < 0:
        raise ValueError("Finite threshold and nonnegative margin required")
    if not scores:
        return None, "no-candidate"
    ordered = sorted(scores, key=lambda row: (-row[1], row[0]))
    if any(not math.isfinite(s) for _, s in ordered):
        raise ValueError("Scores must be finite")
    gap = ordered[0][1]-ordered[1][1] if len(ordered) > 1 else math.inf
    if ordered[0][1] < threshold or gap < margin:
        return None, "abstain"
    return ordered[0][0], "linked"


def demo():
    descriptions = {"planet": "planet orbit sun space", "metal": "metal liquid element toxic",
                    "messenger": "roman god winged messenger"}
    aliases = {"mercury": {"planet": 60, "metal": 30, "messenger": 10}, "水星": {"planet": 5}}
    model = fit(descriptions)
    contexts = ["orbit planet sun", "toxic liquid metal", "winged roman god", "unknown news"]
    results = []
    for context in contexts:
        scores = rank("Mercury", context, aliases, model)
        entity, reason = decide(scores)
        results.append(dict(context=context, scores=scores, entity=entity, reason=reason))
    truncated = {"mercury": {"planet": 60, "messenger": 10}}
    return dict(results=results, missing_alias=decide(rank("Vulcan", "planet", aliases, model)),
                removed_gold=decide(rank("Mercury", "toxic liquid metal", truncated, model)),
                scope="Synthetic descriptions and counts; thresholds not calibrated probabilities")


if __name__ == "__main__":
    print(json.dumps(demo(), indent=2))

Orbit, toxic-liquid and winged-god contexts select three different entities. “Unknown news” yields no matching vocabulary and is rejected. Vulcan has no alias entry, so it produces no-candidate. Removing the metal from Mercury’s candidates makes the toxic-liquid case abstain; the ranker does not invent the missing identifier.

Fitting vocabulary statistics takes O(T) expected time for T token occurrences, followed by sparse normalization. For a context vector with q nonzero terms and c alias candidates, the current similarity loop costs O(cq); sorting costs O(c log c). A large knowledge base needs indexed retrieval instead of scanning every entity. Stored entity vectors may be reused until descriptions or the weighting model change.

An abstention needs interpretation

Low evidence may mean an unfamiliar wording, missing alias, short context, ambiguous passage or genuinely absent entity. These possibilities require different repairs. Measure candidate recall, linking accuracy and decision coverage separately; accuracy only on accepted cases can look good while rejecting difficult examples.

The alias prior may overfavor popular entities. Descriptions may omit the decisive attribute, and matching words can support the wrong sense. A local mention model also misses document-wide coherence. The point of this baseline is to expose those mechanisms. It neither reproduces BLINK training nor turns a threshold into a validated open-set detector. Hogan’s account of aliases and contextual ambiguity supplies the broader integration problem. PDF 51

Locate the error before improving the model

  1. Does recognizing the span “Mercury” identify the entity? Answer: No. Mention detection locates text; linking must choose an identifier using candidates and context.
  2. What is the planet’s score when the cosine is √3/2 and its alias share is 0.6? Answer: 0.85×√3/2+0.15×0.6≈0.826122. The frequency term contributes 0.09.
  3. Correct entities enter the candidates in 80 of 100 in-KB cases. Can this candidate-only reranker achieve 90% end-to-end accuracy? Answer: No. It cannot exceed 80% on those cases without changing retrieval or allowing outputs beyond the candidate set.
  4. A system reports high accuracy but rejects half the mentions. What else should be reported? Answer: Coverage, candidate recall, correctness of accepted links and behavior on rejected/in-KB/out-of-KB cases. Thresholds should be chosen on suitable validation data, not after inspecting test labels.

A neural retriever changes the representation, not the bookkeeping

BLINK independently encodes mention context and entity descriptions for retrieval, then jointly encodes candidate pairs for reranking. The present TF-IDF implementation uses different features and no neural training. The same questions remain useful: Was the gold candidate retrieved? Was the mention boundary supplied or predicted? Does the evaluation include entities outside the knowledge base? Continue with two-tower models for reusable encodings and knowledge graphs for how identifiers affect downstream claims.

Make a prediction, then check

The correct entity is absent from every candidate. Can a reranker choose it?

Choose one answer

Learning objectives

  • Distinguish mention detection, candidate recall, disambiguation and abstention; compute a transparent baseline.
  • Calculate the candidate-recall ceiling and report coverage separately from accepted-link accuracy.

Prerequisites & connections

Explore related knowledge →

References

  1. Scalable Zero-shot Entity Linking with Dense Entity Retrieval
    Ledell Wu; Fabio Petroni; Martin Josifoski; Sebastian Riedel; Luke Zettlemoyer · 2020
  2. Knowledge Graphs — arXiv v6
    Aidan Hogan; Eva Blomqvist; Michael Cochez; Claudia d’Amato; Gerard de Melo; Claudio Gutierrez; José Emilio Labra Gayo; Sabrina Kirrane; Sebastian Neumaier; Axel Polleres; Roberto Navigli; Axel-Cyrille Ngonga Ngomo; Sabbir M. Rashid; Anisa Rula; Lukas Schmelzeisen; Juan Sequeda; Steffen Staab; Antoine Zimmermann · 2021

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-23 · Single AI author. Scoped reading: Read PDF1 identity and PDF2–3 text: given mentions, candidate retrieval/ranking, independent encoders, in-KB assumption and explicit exclusion of NIL prediction. No BERT training, speed claims or benchmark reproduction. Read PDF1 identity/version date, PDF2,13,25,50–51 text: inclusive definition, schema, interpretation, open/closed world, extraction and entity linking. No full-survey reading, empirical reproduction or diagram reuse. 6 paired equations and four explained exercises. Checked hand TF-IDF cosine, alias priors, context reversal, no-candidate cases, omitted gold entities, thresholds and abstention. Given mentions and English word tokenizer; not BLINK training or a validated NIL classifier.

  • Checked hand TF-IDF cosine, alias priors, context reversal, no-candidate cases, omitted gold entities, thresholds and abstention. Given mentions and English word tokenizer; not BLINK training or a validated NIL classifier.
  • Four computed SVG variants per topic;14 numeric/geometry tests and36 responsive cases passed. Twelve selected current captures visually checked: seven identical to previously viewed images and five re-viewed final captures; TransE arrow revision retained. Full article acceptance recorded separately.

Source locations checked:

  • Scalable Zero-shot Entity Linking with Dense Entity Retrieval · Read PDF1 identity and PDF2–3 text: given mentions, candidate retrieval/ranking, independent encoders, in-KB assumption and explicit exclusion of NIL prediction. No BERT training, speed claims or benchmark reproduction.
  • Knowledge Graphs — arXiv v6 · Read PDF1 identity/version date, PDF2,13,25,50–51 text: inclusive definition, schema, interpretation, open/closed world, extraction and entity linking. No full-survey reading, empirical reproduction or diagram reuse.

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.