Coreference resolution
Coreference resolution finds which textual mentions refer to the same real-world entity (clusters mentions into entity chains); this note explains definitions, common algorithms (rule-based, statistical, neural), evaluation, worked examples and exam tips.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Coreference resolution is the task of finding which words or phrases (mentions) in a text refer to the same real-world entity. Engineers use it whenever downstream systems need a correct notion of "who did what" or "what is being talked about": information extraction, question answering, summarisation, dialogue systems and machine translation.
Key ideas
Define terms first:
- Mention — a contiguous span of text that refers to some entity (examples: a name "Ravi", a pronoun "he", a noun phrase "the book").
- Entity — the real-world object, person, event or concept that mentions refer to.
- Coreference — a relation between two or more mentions that refer to the same entity. Example: in "Ravi said he left", "Ravi" and "he" are coreferent.
- Anaphora — an instance where a later mention (the anaphor) refers back to an earlier mention (the antecedent). Anaphora is one form of coreference; not all coreference is strictly anaphoric.
- Antecedent — a mention which an anaphor refers back to.
- Coreference chain / cluster — the set of all mentions that refer to the same entity.
- Singleton mention — a mention that does not corefer with any other mention in the document.
Tasks and assumptions:
- The standard task is within-document coreference resolution: cluster mentions inside one document. A harder task is cross-document coreference (same entity across documents).
- Typical datasets assume gold mention boundaries for evaluation (some systems do joint mention detection + coreference).
Types of mentions and phenomena to handle:
- Pronouns (he, she, it, they) — short, highly ambiguous.
- Named mentions (Ravi, New Delhi) — provide identity cues.
- Nominal mentions (the student, the company) — often require semantic compatibility.
- Appositives ("Ravi, the captain") — strong cues that two mentions corefer.
- Copular/predicative nominals ("Ravi is the captain") — typically coreferent and provide strong linking cues.
- Pleonastic/expletive pronouns ("It is raining", "It seems that...") — not referential; systems should detect and exclude them from coreference.
- Cataphora ("Before he left, Ravi said goodbye") — anaphor precedes antecedent; many systems restrict antecedents to preceding mentions, but be aware of this phenomenon.
- Bridging (part-whole relations, e.g., "a car" ... "the engine") — related but not coreferent; systems should avoid treating bridging as coreference.
- Zero anaphora / pro-drop — in some languages (e.g., Hindi) subjects may be dropped and must be resolved differently.
Algorithm families:
Rule-based / deterministic (sieve-based): apply a sequence of precision-ordered rules that link mentions (exact match, proper-name match, pronoun resolution rules). Example: the multi-sieve system where high-precision rules run first, then lower-precision rules. Assumes rule ordering.
Pairwise/classifier-based: treat coreference as predicting whether mention pair (i,j) corefers, then cluster pairs (e.g., via transitive closure or greedy merge). Assumes independence of pair decisions unless post-processed.
Mention-ranking models: for a mention i (anaphor), rank possible antecedents j by a learned score s(i,j), choose the top antecedent or a null antecedent (no antecedent) for singletons. This enforces exactly-one-antecedent per anaphor.
Entity-level / clustering models: model compatibility of a mention with an existing entity cluster rather than just another mention; allows global features like cluster gender/number consistency.
End-to-end neural models: jointly detect mention spans and learn mention-mention and mention-cluster scores from word embeddings and contextual encoders (e.g., LSTM, Transformer). Often use span representations, attention, and train with ranking or marginal likelihood objectives.
Important algorithmic components (what to implement/test):
- Mention detection (span enumeration, pruning): usually consider all spans up to a max width, score spans with a mentionness score and keep top-K.
- Mention representation: combine head word embedding, span boundary embeddings, attention-weighted head, and possibly speaker or sentence position features.
- Pair scoring: compute s(i,j) from concatenation of span reps, their elementwise product, distance features, and pass through an MLP.
- Decoding / inference: greedy antecedent selection, best-first merging, or global (ILP, CRF, or higher-order neural decoders).
Evaluation metrics (defined precisely below in Formulas):
- MUC: counts links needed to form gold clusters; favors larger clusters.
- B^3: computes precision/recall per mention using overlap of predicted and gold clusters.
- CEAF: aligns predicted and gold clusters to compute a similarity-based score.
- CoNLL F1: arithmetic mean of F1 scores of MUC, B^3, and CEAF_phi4 (entity-based CEAF) — standard shared metric in coreference benchmarks.
What an engineer must know for implementation:
- How to convert datasets (CoNLL format). How to generate candidate spans, prune by mention score, compute pairwise scores, and perform greedy decoding.
- Typical pretrained components: contextual encoders (BERT/Transformers) greatly improve performance by giving better span representations.
Diagrams to draw for an exam answer:
- Draw a short paragraph as three short lines, underline each mention with a unique id, then draw arrows from anaphors to antecedents. Label clusters with braces { } and show final clusters.
- For an end-to-end model: draw input tokens, a contextual encoder box, highlight span boundaries, show span representations x_i, x_j being combined into s(i,j), then a softmax or sigmoid producing probabilities, then greedy link-making.
Formulas
precision = TP / (TP + FP) — TP true positives (correct coreference links or mention-level matches per metric), FP false positives; unitless; applies to any precision calculation.
recall = TP / (TP + FN) — FN false negatives; unitless; applies to recall.
F1 = 2 * precision * recall / (precision + recall) — harmonic mean of precision and recall; unitless.
softmax(z_i) = exp(z_i) / sum_j exp(z_j) — probability distribution over choices; unitless; used when ranking antecedents among many.
sigmoid(s) = 1 / (1 + exp(-s)) — maps score to probability of binary coreference; unitless.
cross_entropy = -sum_t y_t * log(p_t) — loss for predicted distribution p_t and true one-hot y_t; unitless; used to train classifiers.
CoNLL_F1 = (F1_MUC + F1_B3 + F1_CEAF) / 3 — arithmetic mean of the three metric F1s; unitless; standard reported score on CoNLL shared tasks.
Precise coreference metric definitions:
- MUC (link-based): Let G be the set of gold clusters and P the set of predicted clusters. For each gold cluster g in G, let partitions_P(g) be the number of predicted clusters that intersect g. Recall = sum_g (|g| - partitions_P(g)) / sum_g (|g| - 1). For precision, swap roles: for each predicted cluster p in P, let partitions_G(p) be the number of gold clusters that intersect p. Precision = sum_p (|p| - partitions_G(p)) / sum_p (|p| - 1).
- B^3 (mention-based): For each mention m with gold cluster C_g(m) and predicted cluster C_p(m), contribution = |C_p(m) ∩ C_g(m)|. Precision = sum_m |C_p(m) ∩ C_g(m)| / sum_m |C_p(m)|. Recall = sum_m |C_p(m) ∩ C_g(m)| / sum_m |C_g(m)|.
- CEAF_phi4 (entity-based): Find a one-to-one alignment pi from predicted clusters P to gold clusters G that maximizes sum_{p in P} phi4(p, pi(p)), where phi4(C, G) = 2*|C ∩ G| / (|C| + |G|). Then Precision = (sum_p phi4(p, pi(p))) / |P| and Recall = (sum_p phi4(p, pi(p))) / |G|. The CoNLL scorer uses this CEAF variant.
Note: TP/FP/FN depend on metric (MUC, B^3, CEAF use different definitions for matches).
Worked examples
Example 1 — manual clustering (model-answer style):
Text: "Ravi took his book to class. He gave it to Sita after she asked for it."
Step 1: List mentions (span and token indices you would mark on an answer paper):
- "Ravi" (M1) — named
- "his" (M2) — pronoun
- "book" (M3) — nominal
- "He" (M4) — pronoun
- "it" (M5) — pronoun (object)
- "Sita" (M6) — named
- "she" (M7) — pronoun
- "it" (M8) — pronoun (refers to book)
Step 2: Resolve high-precision links (names and appositives, syntactic constraints):
- M1 "Ravi" and M4 "He" — candidate, check gender/number and sentence order: both male-singular; link M4 -> M1.
- M2 "his" likely refers to M1 "Ravi" (possessive with close syntactic relation): link M2 -> M1.
- M3 "book" and M5/M8 "it" — object pronouns usually refer to nearest compatible noun: link M5 -> M3 and M8 -> M3.
- M6 "Sita" and M7 "she" — link M7 -> M6.
Step 3: Form clusters (group linked mentions transitively):
- Cluster A: {M1: Ravi, M2: his, M4: He}
- Cluster B: {M3: book, M5: it, M8: it}
- Cluster C: {M6: Sita, M7: she}
Final answer: list clusters and briefly justify each link (agreement in gender/number, syntactic proximity, semantic compatibility).
Example 2 — toy end-to-end model with numeric scores (demonstrates greedy antecedent selection):
Assume mentions (in order) with span ids 1..5: ["Aisha" (1), "the manager" (2), "she" (3), "the team" (4), "they" (5)]. Model computes pair scores s(i,j) for antecedent j < i and a null score s(i,nil).
Given scores (higher = more likely coreferent):
- For mention 2 ("the manager"): s(2,1)= -1.0, s(2,nil)= 0.0 -> choose nil (no antecedent).
- For mention 3 ("she"): s(3,1)= 2.0, s(3,2)= 0.5, s(3,nil)= -1.0 -> choose antecedent 1 (Aisha).
- For mention 4 ("the team"): s(4,1)= -0.5, s(4,2)= 1.0, s(4,nil)= 0.0 -> choose antecedent 2 (the manager) if semantics allow (but usually "team" != manager; a good model would use semantic features to avoid this). With these numbers greedy links 4->2.
- For mention 5 ("they"): s(5,1)= -1.0, s(5,2)= 0.2, s(5,4)= 2.5, s(5,nil)= -0.5 -> choose antecedent 4 (the team).
Clusters produced by greedy linking:
- Cluster 1: {1: Aisha, 3: she}
- Cluster 2: {2: the manager, 4: the team, 5: they}
Comment: This toy shows how bad features/scores can create semantically odd clusters — motivates entity-level and semantic features.
Common mistakes
- Ignoring how singletons are handled — some corpora include singleton mentions, but OntoNotes/CoNLL do not score singletons; be explicit whether singletons are predicted/evaluated.
- Using only pairwise decisions and assuming transitivity will always fix errors; transitive closure can create error cascades.
- Mixing up evaluation metrics: do not compare MUC/B^3/CEAF scores directly without saying you mean CoNLL F1.
- For neural models: forgetting to prune spans leads to O(n^2) spans and up to O(n^4) pair scoring if all span pairs are considered; practical systems cap span width, keep top-K spans, and limit antecedents.
For your exam
Question types you will see:
- Definitions and short notes (define mention, antecedent, coreference chain, difference between anaphora and coreference).
- Algorithm descriptions (describe sieve-based, mention-ranking, or end-to-end neural approaches; draw diagrams of span scoring).
- Derivations (show how the mention-ranking objective arises from softmax over antecedents, derive cross-entropy loss expression).
- Worked examples / annotation (cluster mentions in a short paragraph; justify each decision).
- Discussion questions (compare rule-based vs neural systems; explain error sources and evaluation metrics).
What a full-marks answer includes:
- Clear definitions (bold or declarative) of terms used.
- An algorithmic description with steps or pseudo-code and a diagram for systems answers.
- One worked example by hand if asked; justify each link with syntactic/semantic cues.
- Mention evaluation metrics and their differences where asked.
Quick check
- Define a "mention" in one sentence.
- Name one difference between MUC and B^3 evaluation metrics.
- Why do end-to-end neural models prune candidate spans?
Answers: 1. A mention is a contiguous text span that refers to an entity (e.g., a name, pronoun, or noun phrase). 2. MUC measures link-based cluster merging and favours large clusters while B^3 computes precision/recall per mention based on overlap; they count corrects differently. 3. To reduce computation and memory: enumerating all spans is expensive (O(n^2) spans), so pruning keeps top-K high-scoring spans for tractable pairwise scoring.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?