Entity Linking: Disambiguation and Knowledge Base Population
Module: Natural Language Processing | Difficulty: Advanced
What You'll Learn
- 1Break entity linking into mention detection, candidate generation, and disambiguation
- 2Rank candidates with a prior, a context similarity, and a coherence term
- 3Score mention detection and disambiguation jointly as end to end F1
- 4Handle the NIL case when the mention has no knowledge base entry
Entity linking anchors a text span to a knowledge base identifier, so that "Washington" in one paragraph resolves to a state and in another to a president. The task is what turns unstructured text into queryable structure, and it fails in ways that are easy to misdiagnose: a missed mention, an absent candidate, and a wrong choice among valid candidates look identical in a downstream query. This lesson separates the three stages, gives the standard scoring function, and covers the NIL case that most evaluations quietly exclude.
The Three Stages
Mention detection finds spans that name something in the knowledge base. It resembles named entity recognition but must also catch ambiguous common nouns, pronouns with resolvable antecedents, and aliases such as "IBM" that NER tags consistently while "Big Blue" it misses entirely.
Candidate generation proposes the knowledge base entries the mention could mean. The usual sources are alias tables built from redirect pages and disambiguation pages, anchor text statistics from millions of hyperlinks, and fuzzy string match against entity names. The target is recall near one, because a candidate that never enters the list cannot be selected later.
Disambiguation chooses among the candidates. The classical score combines three terms:
The prior is estimated from how often the anchor text links to that entity across Wikipedia, the similarity compares the mention's local context with the candidate's description, and the coherence term rewards candidates that are related to the entities already chosen for the same document.
Coherence is what makes the decision collective rather than local:
On the AIDA corpus, which annotates 1,393 Reuters articles with 34,956 mentions, a baseline that uses only the prior reaches about 66.6 micro F1, while the full combination of prior, similarity, and coherence reaches 82.29 with precision 88.08 and recall 77.39. The average mention presents roughly 21 candidates, so the decision is a ranking problem over a small set rather than a classification over the whole knowledge base.
Evaluation
End to end evaluation scores the pipeline rather than the ranker. A predicted mention counts as correct when its boundaries match a gold mention and its identifier matches too, which makes mention detection errors and disambiguation errors land in the same metric:
| Corpus | Documents | Mentions | Reported signal |
|---|---|---|---|
| AIDA train | 946 news articles | part of 34,956 | main training resource |
| AIDA testb | 231 news articles | about 4,500 | headline micro F1 |
| MSNBC | 208 documents | about 4,400 | out of domain news |
| AQUAINT | 394 documents | about 3,800 | different wire service |
| ACE 2004 | 57 documents | about 2,500 | small, noisy, widely used |
Micro averaging lets frequent mentions dominate, so a system that resolves organizations well and struggles with ambiguous locations can post a strong score. Macro reporting by entity popularity is the honest complement: performance on rare entities is where the knowledge population problem actually lives.
The NIL Case and Knowledge Population
New entities appear before any alias table knows them. A NIL threshold handles this: if the best score falls below a calibrated cutoff, or if no candidate clears a minimum similarity, the system emits NIL rather than forcing a wrong link.
The cutoff is tuned against the cost of a wrong link, which in a knowledge population pipeline is much higher than the cost of a missed one. A wrong link pollutes every downstream query, while a NIL simply leaves a gap for a human to fill.
Collecting new entities uses the same machinery in reverse. Clusters of NIL mentions that share context and describe the same event are proposed as candidates for creation, with the coherence score serving as a clustering objective.
Worked Examples
Worked Code
def prior_rank(anchor, counts, context, descriptions, lam=(0.3, 0.4, 0.3)):
total = sum(counts.values())
best, best_score = None, -1.0
for entity, n in counts.items():
p = n / total
sim = jaccard(set(context.split()), set(descriptions[entity].split()))
score = lam[0] * p + lam[1] * sim
if score > best_score:
best, best_score = entity, score
return best, round(best_score, 3)
def jaccard(a, b):
return len(a & b) / len(a | b) if a | b else 0.0
counts = {"Barack_Obama": 180, "Washington_DC": 60, "George_Washington": 30}
descriptions = {
"Barack_Obama": "the president spoke in chicago",
"Washington_DC": "the capital hosted the summit",
"George_Washington": "the general crossed the river",
}
print(prior_rank("Washington", counts,
"the president spoke to reporters", descriptions))
def span_metrics(gold, pred, correct_links):
tp = len(gold & pred)
precision = tp / len(pred) if pred else 0.0
recall = tp / len(gold) if gold else 0.0
f1 = 2 * precision * recall / (precision + recall) if precision + recall else 0.0
accuracy = correct_links / tp if tp else 0.0
return round(precision, 3), round(recall, 3), round(f1, 3), round(accuracy, 3)
gold = {("Barack_Obama", "Washington", "Barack_Obama"), ("Washington", "capital", "Washington_DC")}
pred = {("Barack_Obama", "Washington", "Barack_Obama"), ("Washington", "capital", "Washington_DC"),
("Washington", "state", "Washington_state")}
correct = 1
print("precision, recall, f1, link accuracy:", span_metrics(gold, pred, correct))
Real-World Applications
- Knowledge base population - News and filings are linked nightly, with NIL clusters queued for human entity creation.
- Financial entity resolution - Ticker symbols and subsidiary names must map to one canonical issuer before any risk calculation runs.
- Search and question answering - A linked entity unlocks structured facts, which is what lets an answer include a date instead of a sentence.
- Content recommendation - Documents cluster by the entities they mention, giving a topic signal that survives heavy paraphrase.
đĄReport NIL performance explicitly
Common Mistakes
Evaluating the ranker alone
Fix: Report end to end F1, since missed mentions and absent candidates never reach the ranker and vanish from its metric.
Trusting the prior on rare anchors
Fix: Low count priors are noise, so fall back to context similarity whenever the anchor appears fewer than a handful of times.
Ignoring document level coherence
Fix: Scoring mentions independently breaks coreferent chains, so add a coherence term over entities already linked in the same document.
Best Practices
- Build alias tables from redirects, disambiguation pages, and anchor statistics together
- Tune the NIL threshold against the cost of a wrong link rather than against F1 alone
- Report micro F1 and a breakdown by entity popularity so rare entity behavior stays visible
Key Takeaways
- Linking is mention detection, candidate generation, and disambiguation, and each stage has its own error budget
- The scoring function combines a prior, a context similarity, and a document coherence term
- AIDA holds 34,956 mentions over 1,393 Reuters articles, with 82.29 micro F1 from the full system
- End to end F1 falls sharply from mention only F1 because identifier errors count as misses
Frequently Asked Questions
Why is entity linking harder than named entity recognition?
NER only needs a type from a small closed set. Linking needs a specific identifier from millions of candidates, and two entities of the same type can differ in the one fact a downstream query depends on.
How are new entities handled?
Mentions below the NIL threshold are clustered by shared context, and a cluster with enough evidence becomes a proposal for a new entry whose alias table is seeded from the observed surface forms.
Does neural disambiguation make the prior obsolete?
No. The prior stays the strongest single feature on high frequency anchors, and neural models add the most value on low frequency mentions where context has to carry the decision.
Interview Questions
Q1: Your end to end F1 is far below your ranker accuracy. Where do you look first?
At mention detection recall and candidate generation recall, because both stage failures present as ranking errors downstream. I would measure candidate recall directly, since a missing gold identifier can never be recovered.
Q2: How would you set the NIL threshold?
On a development slice with a stated cost ratio, then revalidated on a slice containing emerging entities, because a threshold tuned on a static benchmark is too permissive once the knowledge base lags reality.