---
title: Coreference and Discourse
module: Linguistic Structure
moduleNumber: 6
lessonNumber: 9
order: 609
summary: >
  A text is more than a bag of sentences: entities recur under different names.
  Coreference resolution links every mention to the discourse entity it evokes —
  the linguistic background of pronouns, definite NPs, and names; mention
  detection; the mention-pair, mention-ranking, and entity-based architectures; a
  neural end-to-end span model that scores candidate antecedents; features,
  evaluation by the CoNLL F1, gender bias, and the neural coreference lineage.
  Discourse coherence follows in the companion lesson.
topics: [Structure]
sources:
  - book: Jurafsky
    ref: "Ch. 21 — Coreference Resolution; §21.1 Coreference Phenomena; §21.3 Mention Detection; §21.4 Architectures; §21.6 A Neural Mention-Ranking Algorithm; §21.7 Evaluation; §21.9 Gender Bias"
---

Consider this passage:

> Victoria Chen, CFO of Megabucks Banking, saw her pay jump to \$2.3 million, as
> the 38-year-old became the company's president. It is widely known that she came
> to Megabucks from rival Lotsabucks.

_Her_, _the 38-year-old_, and _she_ all refer to one person; _the company_ and
_Megabucks_ refer to one organization. None of these identities is stated: the
reader infers them, maintaining a running model of _who_ and _what_ the text is
about and threading each new phrase back into it.[^jm-intro] That model tracks two
things. This lesson develops the first, **coreference**: the machinery that decides
which expressions denote the same entity. The second, **coherence** — what makes a
run of sentences a _discourse_ rather than a random pile — continues in the companion
lesson,
[coherence and discourse structure](/natural-language-processing/linguistic-structure/coherence-and-discourse-structure).
Both build directly on the entities and relations extracted by [semantic roles and
information extraction](/natural-language-processing/linguistic-structure/semantic-roles-and-information-extraction);
here we ask how those pieces get tied across a whole text.

## Mentions, entities, and the discourse model

A **mention** (or **referring expression**) is a linguistic expression the writer
uses to point at something — _her_, _Victoria Chen_, _the company_. The thing
pointed at is the **referent**, a **discourse entity**. Two mentions that point at
the same entity **corefer**.[^jm-intro] Interpreting a text means incrementally
building a **discourse model**: a set of entities, their properties, and the
relations among them.[^jm-model] The first time an entity is named, a
representation of it is **evoked** into the model; every later mention **accesses**
that same representation.

$$
% caption: Mentions in the running text (bottom) evoke or access discourse
% entities in the model (top). "Victoria Chen" evokes entity V; the later "she"
% accesses the same V. Coreference is the top-level identity between the two
% mentions; reference is the vertical link from a mention to its entity.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  ent/.style={draw, circle, minimum size=9mm, inner sep=1pt, align=center, font=\scriptsize},
  men/.style={draw, minimum width=20mm, minimum height=6mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2348F2}
  \definecolor{red}{HTML}{C0392B}
  % discourse model box
  \draw[black, thick] (-0.4,1.3) rectangle (7.9,3.3);
  \node[anchor=west, black, font=\scriptsize] at (-0.35,3.05) {discourse model};
  \node[ent, draw=acc, text=acc] (V)  at (1.4,2.2) {V};
  \node[ent] (M) at (4.0,2.2) {M};
  \node[ent] (L) at (6.6,2.2) {L};
  % mentions
  \node[men, draw=acc] (m1) at (0.6,-0.2)  {Victoria Chen};
  \node[men] (m2) at (3.1,-0.2)  {Megabucks};
  \node[men, draw=acc] (m3) at (5.2,-0.2) {she};
  \node[men] (m4) at (7.3,-0.2)  {Lotsabucks};
  % reference links
  \draw[->, acc] (m1) -- (V) node[pos=0.35, left, font=\scriptsize, text=acc] {evoke};
  \draw[->, acc] (m3) -- (V) node[pos=0.4, right, font=\scriptsize, text=acc] {access};
  \draw[->, black] (m2) -- (M);
  \draw[->, black] (m4) -- (L);
  % coreference link between the two mentions of V, arced below the mentions row
  \draw[red, thick] (m1.south) to[bend right=38] node[pos=0.5, below, font=\scriptsize, text=red] {corefer} (m3.south);
\end{tikzpicture}
$$

Reference to an entity already in the model is **anaphora**, and the accessing
expression is an **anaphor**; the earlier mention it links back to is its
**antecedent**.[^jm-model] In the passage above, _she_ is an anaphor and _Victoria
Chen_ its antecedent. An entity mentioned only once (like _Lotsabucks_) is a
**singleton**. The whole set of coreferring mentions for an entity is a
**coreference chain** (or **cluster**). Our passage yields four chains:

| # | Chain | Entity |
| --- | --- | --- |
| 1 | {Victoria Chen, her, the 38-year-old, she} | the CFO |
| 2 | {Megabucks Banking, the company, Megabucks} | the bank |
| 3 | {her pay} | a salary (singleton) |
| 4 | {Lotsabucks} | a rival (singleton) |

> **Definition (Coreference resolution).** Given a text, find all the entity
> mentions and partition them into coreference chains, so that two mentions land
> in the same chain exactly when they refer to the same discourse entity. It
> decomposes into two subtasks, usually done jointly: **mention detection** and
> **clustering**.

Note that mentions **nest**: _her_ is part of the larger mention _her pay_, which
refers to a completely different entity.[^jm-model] Deciding which real-world
individual a discourse entity denotes — is _Washington_ the state, the city, or the
person? — is a separate task, **entity linking**, typically resolved against an
ontology such as Wikipedia.[^jm-model] Coreference stops at the discourse entity;
linking maps that entity to the world.

## Linguistic background

Different kinds of referring expressions carry different loads. The choice among
them is governed by **information status**: whether the entity is already in the
discourse (given) or new, and how **salient** it is in the reader's mind.[^jm-ling]

**Indefinite NPs** (_a beautiful goose_, _some walnuts_) usually introduce entities
new to the hearer. **Definite NPs** (_the white stallion_) refer to an entity the
hearer can already identify — because it was mentioned before, or because the world
makes it unique (_the car keys_); more than half of definite NPs in newswire are
non-anaphoric, naming something for the first time.[^jm-ling] **Pronouns** (_she_,
_it_) are reserved for entities that are highly salient, so they can be recovered
from very little linguistic material. **Names** can introduce or re-access entities
(_International Business Machines_ … _IBM_).[^jm-ling]

The general principle is a trade between salience and explicitness: the more
accessible an entity, the less material is needed to refer to it. A new entity
enters with a full, informative description; as it is discussed it becomes salient,
and its mentions shrink — full name, then short name, then definite description,
then pronoun.

$$
% caption: The accessibility scale. As an entity becomes more salient in the
% discourse, the writer refers to it with progressively less material, from a
% full name down to a pronoun.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  tag/.style={draw, minimum width=27mm, minimum height=8mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2348F2}
  \node[tag] (a) at (0,0)   {full name + role\\Victoria Chen, CFO};
  \node[tag] (b) at (3.4,0) {short name\\Ms. Chen};
  \node[tag] (c) at (6.8,0) {def\/inite NP\\the 38-year-old};
  \node[tag, draw=acc, text=acc] (d) at (10.2,0) {pronoun\\she};
  \draw[->, acc, thick] (a) -- (b);
  \draw[->, acc, thick] (b) -- (c);
  \draw[->, acc, thick] (c) -- (d);
  \draw[->, black] (0,-1.15) -- (10.2,-1.15);
  \node[anchor=south, black, font=\scriptsize] at (5.1,-1.15) {increasing salience, decreasing explicitness};
\end{tikzpicture}
$$

Not every noun phrase refers. Mention detection has to screen out several
**non-referring** structures that look like mentions:[^jm-ling]

- **Appositives** — _CFO of Megabucks Banking_ describing _Victoria Chen_ — add
  a parenthetical description, they do not name a new entity.
- **Predicative / prenominal NPs** — in _her pay jumped to \$2.3 million_, the
  _\$2.3 million_ predicates a property, it is not a distinct entity.
- **Expletive (pleonastic)** pronouns — the _it_ in _it is raining_ or the cleft
  _It was Emma Goldman who…_ refers to nothing.
- **Generics** — _I love mangos. They are very tasty._ — _they_ names the class of
  mangos, not any particular set.

### Properties of the anaphor/antecedent relation

Several soft constraints and preferences shape which antecedent an anaphor
takes.[^jm-props] They are useful both as features and as a checklist for error
analysis.

| Property | What it says | Example |
| --- | --- | --- |
| Number agreement | anaphor and antecedent agree in number | _the chefs_ ↛ _she_ |
| Person agreement | agree in first/second/third person | third-person _he_ needs a third-person antecedent |
| Gender / noun class | agree in grammatical gender | _Maryam … She_ vs. _the theorem … It_ |
| Binding constraints | reflexives corefer with the local subject; non-reflexives cannot | _Janet bought herself_ (=Janet); _Janet bought her_ (≠Janet) |
| Recency | recent mentions are more salient | later map preferred as antecedent of _it_ |
| Grammatical role | subjects outrank objects outrank obliques | _he_ prefers the subject of the prior sentence |
| Verb semantics | some verbs bias toward subject or object | _John telephoned Bill. He…_ (=John) vs. _John criticized Bill. He…_ (=Bill) |
| Selectional restrictions | verbs constrain their arguments' type | _ate … it_ rules out _the bowl_, keeps _the soup_ |

These are preferences, not laws. Number agreement in particular cannot be enforced
strictly: a semantically plural organization takes _they_ (_IBM … They have been
working on it_), and **singular _they_** — _they_ used for a single individual — is
common and gender-neutral.[^jm-props] A resolver that hard-filters on agreement
throws away correct links.

### The hard cases: Winograd Schemas

Some coreference decisions need world knowledge that no amount of agreement or
distance can supply. The canonical illustration is the **Winograd Schema**: a pair
of sentences differing in a single word, where that word flips the
antecedent.[^jm-winograd]

$$
% caption: A Winograd Schema. The two sentences differ in one word (large vs.
% small); a human resolves "it" to the trophy in the first and the suitcase in
% the second, using knowledge that a larger object cannot fit inside a smaller one.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  s/.style={draw, minimum width=64mm, minimum height=9mm, align=left, font=\scriptsize, inner sep=4pt},
  ans/.style={draw, minimum width=26mm, minimum height=7mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2348F2}
  \definecolor{red}{HTML}{C0392B}
  \node[s] (s1) at (0,1.1)  {The trophy didn't f\/it into the suitcase\\because \textbf{it} was too \textbf{large}.};
  \node[s] (s2) at (0,-1.1) {The trophy didn't f\/it into the suitcase\\because \textbf{it} was too \textbf{small}.};
  \node[ans, draw=acc, text=acc] (a1) at (5.6,1.1)  {it = the trophy};
  \node[ans, draw=red, text=red] (a2) at (5.6,-1.1) {it = the suitcase};
  \draw[->, acc] (s1) -- (a1);
  \draw[->, red] (s2) -- (a2);
  \node[black, font=\scriptsize, anchor=west] at (3.35,0) {one word f\/lips it};
\end{tikzpicture}
$$

By design these resist selectional restrictions and word association; the original
_city council … demonstrators … they feared/advocated violence_ turns on social
stereotypes, others on physics or turn-taking.[^jm-winograd] The Winograd Schema
Challenge was proposed precisely to push NLP toward common-sense reasoning. Large
pretrained language models, fine-tuned on such sentences, now solve a large
fraction of the original set (they have absorbed a great deal of world knowledge),
which has driven the field to build harder successor datasets.[^jm-winograd]

## Mention detection

The first stage of a coreference system finds the spans that constitute
mentions.[^jm-mention] Detectors are deliberately **high-recall**: they over-propose
and filter later. A common recipe runs a parser and a named-entity tagger and takes
every NP, possessive pronoun, and named entity. On the running passage this yields
about 13 candidates:

$$
% caption: Mention detection over-generates. From the passage, a high-recall pass
% proposes every NP, possessive, and named entity (13 candidates); a
% referentiality filter discards non-referring spans (pleonastic "It", the
% appositive "CFO of ...", the predicate "the company's president") leaving 9.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  keep/.style={draw, minimum width=32mm, minimum height=6mm, align=center, font=\scriptsize},
  drop/.style={draw, dashed, minimum width=32mm, minimum height=6mm, align=center, font=\scriptsize, text=black}]
  \definecolor{acc}{HTML}{2348F2}
  \definecolor{red}{HTML}{C0392B}
  \node[anchor=south, font=\scriptsize] at (0,2.7) {13 candidates};
  \node[keep] (k1) at (0,2.2)  {Victoria Chen};
  \node[keep] (k2) at (0,1.5)  {Megabucks Banking};
  \node[keep] (k3) at (0,0.8)  {her pay};
  \node[keep] (k4) at (0,0.1)  {the 38-year-old};
  \node[keep] (k5) at (0,-0.6) {she};
  \node[drop] (d1) at (0,-1.3) {CFO of Megabucks Banking};
  \node[drop] (d2) at (0,-2.0) {the company's president};
  \node[drop] (d3) at (0,-2.7) {It};
  \node[anchor=south, text=acc, font=\scriptsize] at (7.4,2.7) {9 mentions kept};
  \node[keep, draw=acc, text=acc] (r1) at (7.4,2.2)  {Victoria Chen};
  \node[keep, draw=acc, text=acc] (r2) at (7.4,1.5)  {Megabucks Bank};
  \node[keep, draw=acc, text=acc] (r3) at (7.4,0.8)  {her pay};
  \node[keep, draw=acc, text=acc] (r4) at (7.4,0.1)  {the 38-year-old};
  \node[keep, draw=acc, text=acc] (r5) at (7.4,-0.6) {she};
  \node[black, font=\scriptsize, align=center] at (3.7,-2.0) {referentiality\\f\/ilter};
  \draw[->, acc] (k1) -- (r1);
  \draw[->, acc] (k5) -- (r5);
  \draw[->, red] (d3) -- ++(2.2,0) node[right, font=\scriptsize, text=red] {discarded};
\end{tikzpicture}
$$

More recent detectors are even more generous: the span-based neural model below
enumerates _all_ n-gram spans up to length 10 and prunes them later.[^jm-mention]
Most of these are not referring expressions, so every detector needs a way to
filter pleonastic pronouns, appositives, and predicate nominals. Some filtering is
rule-based — regular expressions catch pleonastic _it_ in _It is likely that…_ or
_It seems that…_.[^jm-mention] But rules alone are insufficient, so modern systems
add a learned component: a **referentiality**, **anaphoricity** (is this NP an
anaphor?), or **discourse-new** classifier, using features of the candidate — head
word, definiteness, animacy, length, position.[^jm-mention]

Hard filtering, though, hurts: set the anaphoricity threshold high and recall
collapses; set it low and precision collapses.[^jm-mention] Modern systems
therefore skip the separate filtering stage and fold mention detection,
anaphoricity, and coreference into one **end-to-end** model with a single loss —
the design developed below. Even so, wrongly marking pleonastic _it_ and other
non-referential NPs as coreferent remains a leading error source, so referentiality
detection is still an open problem.[^jm-mention]

## Architectures for coreference

Given the mentions, how do we cluster them? Three classic architectures differ
along two axes: whether a decision is made **per mention** or **per entity**, and
whether candidate antecedents are compared against each other by **ranking**.[^jm-arch]

### The mention-pair model

The simplest architecture trains a binary classifier on a **pair** of mentions — a
candidate anaphor and a candidate antecedent — that outputs the probability they
corefer.[^jm-mp]

$$
% caption: The mention-pair classifier. For the anaphor "she" it scores each
% earlier mention independently, giving p(coref) for each pair. Actual
% antecedents (Victoria Chen, her) should score high; others low. Decisions are
% local to a pair.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  m/.style={draw, minimum width=24mm, minimum height=7mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2348F2}
  \definecolor{red}{HTML}{C0392B}
  \node[m, draw=acc, text=acc] (an) at (9.4,0) {she};
  \node[m] (a) at (0,2.4)  {Victoria Chen};
  \node[m] (b) at (0,1.2)  {Megabucks Banking};
  \node[m] (c) at (0,0.0)  {her};
  \node[m] (d) at (0,-1.2) {her pay};
  \node[m] (e) at (0,-2.4) {the 38-year-old};
  \draw[->, acc] (a) -- (an) node[pos=0.62, above, font=\scriptsize, text=acc] {0.9};
  \draw[->, black] (b) -- (an) node[pos=0.55, above, font=\scriptsize, text=black] {0.1};
  \draw[->, acc] (c) -- (an) node[pos=0.6, below, font=\scriptsize, text=acc] {0.8};
  \draw[->, black] (d) -- (an) node[pos=0.5, below, font=\scriptsize, text=black] {0.1};
  \draw[->, acc] (e) -- (an) node[pos=0.66, below, font=\scriptsize, text=acc] {0.7};
\end{tikzpicture}
$$

Training needs a heuristic to avoid drowning in negatives (most mention pairs do
not corefer). The standard choice: for each anaphor $m_i$, one **positive** pair
$(m_i, m_j)$ with $m_j$ the closest antecedent, and one **negative** pair for each
mention between $m_j$ and $m_i$.[^jm-mp] At test time, the trained classifier runs
over prior mentions and links, then transitive closure of the pairwise links gives
the clusters. Two clustering rules are common:

> **Definition (Closest-first vs. best-first clustering).** In **closest-first**
> clustering the classifier runs right to left from $m_{i-1}$ down to $m_1$ and
> links the _first_ antecedent scoring above $0.5$. In **best-first** clustering it
> scores all $i-1$ prior mentions and links the single _most probable_ one above
> threshold. If none clears threshold, $m_i$ starts a new chain.

The mention-pair model is simple but has two flaws. It never directly compares two
candidate antecedents, so it cannot be trained to pick the _better_ of two plausible
ones; and it looks only at mention pairs, ignoring the entity (the rest of the
cluster).[^jm-mp] The next two models each repair one flaw.

### The mention-ranking model

The **mention-ranking** model compares all candidate antecedents at once and picks
the single best.[^jm-mr] For anaphor $i$ it introduces a variable $y_i$ ranging over
$\{1, \ldots, i-1, \epsilon\}$: every prior mention plus a special dummy $\epsilon$
that means "$i$ has no antecedent" — either discourse-new or non-referential.
Folding $\epsilon$ into the choice set is what lets anaphoricity be learned jointly
with coreference instead of by a separate classifier.[^jm-mr]

$$
% caption: The mention-ranking model computes one softmax over all prior mentions
% plus a dummy epsilon. One or more true antecedents should get high probability;
% the rest, including epsilon, low. Choosing epsilon means "no antecedent".
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  m/.style={draw, minimum width=24mm, minimum height=7mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2348F2}
  \definecolor{red}{HTML}{C0392B}
  \node[m, draw=acc, text=acc] (an) at (9.4,0) {she};
  \node[m] (a) at (0,2.4)  {Victoria Chen};
  \node[m] (b) at (0,1.2)  {Megabucks Banking};
  \node[m] (c) at (0,0.0)  {her};
  \node[m] (d) at (0,-1.2) {the 38-year-old};
  \node[m, draw=red, text=red] (e) at (0,-2.4) {epsilon (none)};
  \draw[->, acc] (a) -- (an);
  \draw[->, black] (b) -- (an);
  \draw[->, acc] (c) -- (an);
  \draw[->, acc] (d) -- (an);
  \draw[->, red] (e) -- (an);
  \node[anchor=west, black, font=\scriptsize, align=left] at (2.9,2.0) {softmax over all};
  \node[anchor=west, black, font=\scriptsize, align=left] at (2.9,-2.2) {these should be low};
\end{tikzpicture}
$$

Training is trickier than the mention-pair case: the gold data gives the whole
cluster, not the single "correct" antecedent, so the best antecedent is
**latent**.[^jm-mr] The standard solution gives credit to _any_ legal antecedent by
summing their probabilities in the loss — the objective we write out for the neural
model below. At test time one softmax per anaphor yields a distribution over
antecedents; transitive closure of the argmax links produces the clustering.[^jm-mr]

### Entity-based models

Both models above decide about _mentions_. **Entity-based** models instead link a
mention to a previous **entity** (cluster), which lets a decision use the whole
cluster's evidence.[^jm-entity] A mention-ranking model becomes an entity-ranking
model by ranking over clusters rather than mentions. Feature-based versions add
cluster features: the cluster **size**, or its **shape** — the sequence of mention
types, so {Victoria, her, the 38-year-old} has shape `P-Pr-D` for
Proper-Pronoun-Definite. Neural versions learn cluster representations, e.g. with an
RNN over the cluster's mentions.[^jm-entity] Entity-based models are more expressive,
but in practice the cluster-level information has not bought large gains, so
mention-ranking remains the most common choice today.[^jm-entity]

## Features

Before neural representation learning, coreference classifiers ran on hand-built
features, and these still complement neural models.[^jm-features] For an anaphor and
a candidate antecedent, features come in three groups: features of the anaphor,
features of the antecedent, and features of the **pair**. The table shows
representative values for the pair (_Victoria Chen_, _she_):

| Feature | Value | Meaning |
| --- | --- | --- |
| Head word | Victoria / she | head (or head embedding) of antecedent / anaphor |
| Attributes | Sg-F-A-3-PER / Sg-F-A-3-PER | number, gender, animacy, person, NE type |
| Length | 2 / 1 | length in words |
| Grammatical role | Sub / Sub | subject, object, or oblique |
| Mention type | P / Pr | Proper / Definite / Indefinite / Pronoun |
| Sentence distance | 1 | sentences between the two |
| Mention distance | 4 | mentions between the two |
| Exact string match | F | strings identical |
| Head match | T | shared head word |
| Cosine | — | cosine between antecedent and anaphor embeddings |

The features prior work finds most useful are **exact string match**, **head-word
agreement**, and **mention distance**, plus **attribute match** and _i-within-i_ for
pronouns, and **word inclusion** and **cosine** for nominals and names.[^jm-features]
**Conjunctions** of features matter: moving from single features to conjunctions
raised F1 by about 4 points in one study.[^jm-features] Neural systems
with contextual embeddings no longer benefit from shallow lexical features like
string or head match, but they still gain from mention length, distance, and
genre.[^jm-features]

## A neural mention-ranking algorithm

The state-of-the-art `e2e-coref` family does mention detection and coreference in
one span-based network.[^jm-neural] Given a document of $T$ words it considers all
$\tfrac{T(T-1)}{2}$ spans (in practice up to width $\approx 10$) and assigns each
span $i$ an antecedent $y_i \in \{1, \ldots, i-1, \epsilon\}$. For a pair of spans
$(i, j)$ the model produces a coreference **score** $s(i,j)$ that decomposes into
three parts — whether $i$ is a mention, whether $j$ is a mention, and whether $j$ is
$i$'s antecedent:

$$
s(i, j) = m(i) + m(j) + c(i, j), \qquad s(i, \epsilon) = 0.
$$

Fixing the dummy score $s(i, \epsilon) = 0$ gives a clean abstain rule: predict the
highest-scoring antecedent if any non-dummy score is positive, otherwise take
$\epsilon$ and start a new chain.[^jm-neural] The antecedent distribution is a
softmax over the choice set $Y(i)$:

$$
P(y_i) = \frac{\exp\!\big(s(i, y_i)\big)}{\sum_{y' \in Y(i)} \exp\!\big(s(i, y')\big)}.
$$

### Span representations

Both $m$ and $c$ need a vector for a span. The representation captures three
tokens: the span's **first** word, its **last** word, and its most important
(head) word.[^jm-neural] Run the document through an encoder (e.g. BERT) to get
token embeddings $h_t$, and represent span $i$ as

$$
g_i = \big[\, h_{\text{START}(i)},\; h_{\text{END}(i)},\; h_{\text{ATT}(i)} \,\big],
$$

where $h_{\text{ATT}(i)}$ is an **attention-weighted** sum of the span's tokens that
learns to concentrate on the head word. The attention weight for token $t$ comes
from a learned vector $w_\alpha$ and a feedforward net, normalized over the span:

$$
\alpha_t = w_\alpha \cdot \text{FFNN}_\alpha(h_t),
\qquad
a_{i,t} = \frac{\exp(\alpha_t)}{\sum_{k=\text{START}(i)}^{\text{END}(i)} \exp(\alpha_k)},
\qquad
h_{\text{ATT}(i)} = \sum_{t=\text{START}(i)}^{\text{END}(i)} a_{i,t}\, w_t.
$$

$$
% caption: Computing the span representation g and mention score m in the
% e2e-coref model. An encoder produces per-token vectors; a head-finding
% attention picks the important word; the first, last, and attended vectors
% concatenate into g, which a feedforward net maps to a mention score m.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  tok/.style={draw, minimum width=15mm, minimum height=6mm, align=center, font=\scriptsize},
  op/.style={draw, minimum width=30mm, minimum height=7mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2348F2}
  \def\dx{1.75}
  \foreach \i/\w in {0/the, 1/Postal, 2/Service} \node[tok] (t\i) at (\i*\dx,0) {\w};
  \node[anchor=east, black, font=\scriptsize] at (-0.6,0) {tokens};
  \node[op, fill=black!5] (enc) at (1.75,1.2) {Encoder (BERT)};
  \foreach \i in {0,1,2} \draw[->, black] (t\i.north) -- (enc.south);
  \node[op, draw=acc, text=acc] (att) at (-0.4,2.6) {head attention $h_{ATT}$};
  \node[op] (g) at (3.6,2.6) {span rep $g$};
  \draw[->, acc] (enc.north) .. controls (0.6,2.0) .. (att.south);
  \draw[->, black] (enc.north) -- (g.south);
  \draw[->, acc] (att.east) -- (g.west);
  \node[op, draw=acc, text=acc] (m) at (3.6,3.9) {mention score $m$};
  \draw[->, acc] (g.north) -- (m.south);
\end{tikzpicture}
$$

### Mention and antecedent scores

Two feedforward nets turn spans into scores. The mention score reads one span; the
antecedent score reads a pair and includes the **element-wise product**
$g_i \circ g_j$ as an explicit similarity signal (plus a feature vector
$\phi(i,j)$ for distance, speaker, and genre):

$$
m(i) = w_m \cdot \text{FFNN}_m(g_i),
\qquad
c(i, j) = w_c \cdot \text{FFNN}_c\big([\, g_i,\; g_j,\; g_i \circ g_j,\; \phi(i,j) \,]\big).
$$

At inference, $m(i)$ prunes the candidate list to a manageable few high-scoring
mentions before any antecedent scores are computed — the pruning that makes the
$O(T^4)$ span-pair problem tractable.[^jm-neural]

$$
% caption: Scoring the antecedents of "the company". The coreference score s of
% each candidate pair sums the two mention scores and the pairwise antecedent
% score; a softmax over the candidates and the fixed-zero dummy epsilon gives
% the antecedent distribution.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  sp/.style={draw, minimum width=26mm, minimum height=7mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2348F2}
  \definecolor{red}{HTML}{C0392B}
  \node[sp, draw=acc, text=acc] (q) at (8.6,0) {the company};
  \node[sp] (a) at (0,1.8)  {General Electric};
  \node[sp] (b) at (0,0.0)  {the Postal Service};
  \node[sp, draw=red, text=red] (c) at (0,-1.8) {epsilon = 0};
  \draw[->, acc] (a) -- (q) node[pos=0.55, above, font=\scriptsize] {$s = m + m + c$};
  \draw[->, black] (b) -- (q);
  \draw[->, red] (c) -- (q);
  \node[anchor=south, black, font=\scriptsize] at (4.3,2.2) {softmax over candidates};
\end{tikzpicture}
$$

### Learning

Because the gold labels give clusters, not single antecedents, the model uses a
**latent-antecedent** loss: for span $i$ it maximizes the total probability of _any_
legal gold antecedent. Let $\text{GOLD}(i)$ be the mentions in $i$'s gold cluster and
$Y(i)$ the spans before $i$; the correct antecedents are $Y(i) \cap \text{GOLD}(i)$.
Summing the negative log of that total probability over all mentions gives the
training loss:[^jm-neural]

$$
\mathcal{L} = \sum_{i=2}^{N} -\log \!\!\sum_{\hat{y} \in Y(i) \cap \text{GOLD}(i)} P(\hat{y}).
$$

If span $i$ is in no gold cluster, its only legal antecedent is $\epsilon$. A forward
pass then gives each document's antecedent distribution, and transitive closure over
the argmax links yields the final clustering. The learned head-finding attention
tends to land on the true syntactic head, even though no head supervision is
provided — the model discovers that head words are useful for coreference purely
from the clustering signal.[^jm-neural]

#### The latent-antecedent loss on numbers

The summed loss differs from an ordinary softmax cross-entropy in a way that is
easy to miss. Resolve _she_ against the choice
set $\{\text{Victoria Chen},\ \text{Megabucks},\ \text{her},\ \epsilon\}$, where the
gold cluster for _she_ contains _both_ Victoria Chen and _her_. Suppose the model's
scores $s(i,j)$ produce this softmax over the four candidates:

$$
P(\text{Victoria}) = 0.5,\quad P(\text{her}) = 0.3,\quad P(\text{Megabucks}) = 0.15,\quad P(\epsilon) = 0.05.
$$

$$
% caption: The latent-antecedent loss for "she". Two of the four candidates
% (Victoria Chen and her) are legal gold antecedents; the loss sums their
% probabilities (0.5 + 0.3 = 0.8) before the log, so the model is rewarded for
% putting mass on EITHER, not forced to pick one.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  bar/.style={draw, minimum height=6mm, anchor=west, font=\scriptsize}]
  \definecolor{acc}{HTML}{2348F2}
  \definecolor{red}{HTML}{C0392B}
  \node[anchor=east, font=\scriptsize] at (-0.2,0)    {Victoria Chen};
  \node[anchor=east, font=\scriptsize] at (-0.2,-0.8)  {her};
  \node[anchor=east, font=\scriptsize] at (-0.2,-1.6)  {Megabucks};
  \node[anchor=east, font=\scriptsize] at (-0.2,-2.4)  {epsilon};
  \node[bar, fill=acc!25, minimum width=50mm] at (0,0)    {0.5  gold};
  \node[bar, fill=acc!25, minimum width=30mm] at (0,-0.8) {0.3  gold};
  \node[bar, fill=black!10, minimum width=15mm] at (0,-1.6) {0.15};
  \node[bar, fill=black!10, minimum width=5mm]  at (0,-2.4) {0.05};
  \node[text=acc, anchor=west, font=\scriptsize] at (0,-3.2) {loss = -log(0.5 + 0.3) = -log 0.8 = 0.22};
\end{tikzpicture}
$$

An ordinary classifier would have to name one target and pay a penalty for the
probability it put on the other correct antecedent — but _her_ and _Victoria Chen_
are equally correct, and forcing a choice between them is arbitrary. The
latent-antecedent loss instead sums the gold probabilities _before_ the log:
$\mathcal{L}_{\text{she}} = -\log(0.5 + 0.3) = -\log 0.8 \approx 0.22$. Mass on
either legal antecedent reduces the loss identically, so the model is never told
which of the two to prefer; it only has to keep total mass off _Megabucks_ and
$\epsilon$. This is the numerical meaning of "the best antecedent is latent": the
objective marginalizes over the unknown correct link rather than committing to one.

## Evaluation

Coreference is scored **model-theoretically**: compare the system's hypothesis
chains $H$ against gold reference chains $R$ and report precision and recall. There
is no single obvious way to do this, so several metrics coexist — each measuring a
slightly different notion of "same clustering".[^jm-eval]

| Metric | Unit compared | Character |
| --- | --- | --- |
| **MUC** | coreference **links** (pairs) | link-based; ignores singletons; biased toward large chains |
| **B³** | **mentions** | per-mention precision/recall, summed with weights |
| **CEAF** | **entities** | aligns hypothesis and gold entities |

MUC precision is common links over links in $H$, recall is common links over links
in $R$; because it counts only links, singletons never contribute, and merging
everything into few big chains inflates the score.[^jm-eval] B³ fixes this by working
per mention: for mention $i$ with reference chain $R$ and hypothesis chain $H$,
precision is $\tfrac{|H \cap R|}{|H|}$ and recall is $\tfrac{|H \cap R|}{|R|}$,
weighted and summed over all mentions.[^jm-eval]

#### Scoring MUC and B³ on a worked example

Take one gold chain of four mentions, $R = \{a, b, c, d\}$, and a system that
correctly groups the first three but splits off the fourth into its own singleton:
$H_1 = \{a, b, c\}$, $H_2 = \{d\}$. Compute both metrics on this one error.

$$
% caption: One gold chain {a,b,c,d} versus a system output that splits d into a
% singleton. MUC counts coreference links (pairs in a spanning chain); B-cubed
% counts per mention. The split costs recall under both, but by different amounts.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  men/.style={draw, circle, minimum size=7mm, font=\scriptsize}]
  \definecolor{acc}{HTML}{2348F2}
  \definecolor{red}{HTML}{C0392B}
  \node[font=\scriptsize\bfseries, anchor=west] at (-0.3,1.4) {gold R};
  \node[men, draw=acc] (a) at (0.4,0.4) {a};
  \node[men, draw=acc] (b) at (1.6,0.4) {b};
  \node[men, draw=acc] (c) at (2.8,0.4) {c};
  \node[men, draw=acc] (d) at (4.0,0.4) {d};
  \draw[acc] (a)--(b); \draw[acc] (b)--(c); \draw[acc] (c)--(d);
  \node[font=\scriptsize\bfseries, anchor=west] at (6.3,1.4) {system H};
  \node[men] (a2) at (7.0,0.4) {a};
  \node[men] (b2) at (8.2,0.4) {b};
  \node[men] (c2) at (9.4,0.4) {c};
  \node[men, draw=red, text=red] (d2) at (10.8,0.4) {d};
  \draw[black] (a2)--(b2); \draw[black] (b2)--(c2);
  \node[font=\scriptsize, text=red, anchor=west] at (10.4,-0.55) {split o\/f\/f};
\end{tikzpicture}
$$

**MUC** counts coreference _links_, where a chain of $k$ mentions contributes $k-1$
links (a spanning tree over the cluster). Gold has $4-1 = 3$ links; the system's
chains have $2 + 0 = 2$ links, and both of those ($a$–$b$, $b$–$c$) are also gold
links. So MUC recall is $\tfrac{2}{3}$ (two of three gold links recovered) and MUC
precision is $\tfrac{2}{2} = 1$ (both proposed links are correct), giving
$F_1 = \tfrac{2\cdot 1 \cdot \frac{2}{3}}{1 + \frac{2}{3}} = 0.8$.

**B³** works per mention. For each mention it computes precision
$\tfrac{|H\cap R|}{|H|}$ and recall $\tfrac{|H\cap R|}{|R|}$ from _its own_
hypothesis and reference chains, then averages over all four mentions. For $a$, $b$,
$c$: their hypothesis chain is $\{a,b,c\}$ and reference chain $\{a,b,c,d\}$, so
$|H\cap R| = 3$, precision $\tfrac{3}{3}=1$, recall $\tfrac{3}{4}$. For $d$: its
hypothesis chain is $\{d\}$, reference $\{a,b,c,d\}$, so $|H\cap R|=1$, precision
$\tfrac{1}{1}=1$, recall $\tfrac{1}{4}$. Averaging: precision $=1$, recall
$=\tfrac{1}{4}(\tfrac{3}{4}+\tfrac{3}{4}+\tfrac{3}{4}+\tfrac{1}{4}) = \tfrac{10}{16}
= 0.625$, so $B^3\,F_1 = \tfrac{2\cdot 1\cdot 0.625}{1.625} \approx 0.77$. The single
split costs slightly more under B³ than MUC here, because B³ makes the three
correctly-grouped mentions each pay a recall penalty for the missing $d$, whereas MUC
charges only the one missing link — the reason a single metric misleads and the CoNLL
average is reported.

> **Note (CoNLL F1).** No single metric captures everything, so the CoNLL shared
> tasks — and most papers since — report the **CoNLL F1**: the unweighted average of
> the MUC, B³, and CEAF F-measures. Use the reference implementations rather than
> reimplementing; the metrics have subtle edge cases.[^jm-eval]

A subtlety in comparing systems: datasets differ in whether they annotate
singletons. OntoNotes, the most-used English corpus, does **not**, which raises
scores because singletons — 60–70% of all entities — are the hardest mentions to
tell apart from non-referential NPs.[^jm-tasks]

## Gender bias in coreference

Coreference models inherit the biases of their embeddings and training data.[^jm-bias]
The **WinoBias** dataset adapts the Winograd paradigm to expose this: each sentence
pairs a stereotypically male and a stereotypically female occupation with a gendered
pronoun that _cannot_ be disambiguated by gender, only by the coreference structure.

$$
% caption: A WinoBias pair. "him" links to "the physician" in both sentences; a
% biased model resolves the pro-stereotypical case (male pronoun, male-stereotyped
% job) more accurately than the anti-stereotypical one, a gap of about 21 F1.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  s/.style={draw, minimum width=70mm, minimum height=9mm, align=left, font=\scriptsize, inner sep=4pt},
  tag/.style={minimum width=30mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2348F2}
  \definecolor{red}{HTML}{C0392B}
  \node[s] (s1) at (0,0.9)  {The secretary called the physician\\and told \textbf{him} about a new patient.};
  \node[s] (s2) at (0,-1.1) {The secretary called the physician\\and told \textbf{her} about a new patient.};
  \node[tag, text=acc] (t1) at (6.2,0.9)  {pro-stereotypical};
  \node[tag, text=red] (t2) at (6.2,-1.1) {anti-stereotypical};
  \draw[->, acc] (s1) -- (t1);
  \draw[->, red] (s2) -- (t2);
  \node[black, font=\scriptsize, anchor=west] at (3.55,-0.1) {him/her = the physician};
\end{tikzpicture}
$$

Systems of _every_ architecture — rule-based, feature-based, and end-to-end
neural — resolve pro-stereotypical pronouns more accurately than anti-stereotypical
ones, on average about **21 F1 points** worse in the anti-stereotypical
case.[^jm-bias] One root cause is that female entities are underrepresented in
OntoNotes. A **gender-swapping** augmentation — build a copy of the corpus with every
male entity swapped to female and vice versa, and retrain on the union, with
debiased embeddings — removes the WinoBias gap without hurting OntoNotes accuracy.[^jm-bias]
The **GAP** dataset provides a gender-balanced benchmark of ambiguous pronouns drawn
from Wikipedia, on which modern systems still resolve feminine pronouns worse than
masculine ones.[^jm-bias]

## The neural coreference lineage

The `e2e-coref` model began a line of work in which each successive paper removed a
specific bottleneck.

**Lee et al. (2017)** introduced the end-to-end span model itself: no external mention
detector, no separate anaphoricity classifier, just the span enumeration, the
first/last/head-attention span representation, and the summed latent-antecedent loss
of this lesson.[^lee2017] It was the first system to jointly learn mention detection
and coreference and reached about 67 CoNLL F1 on OntoNotes, then state of the art.

**Lee et al. (2018)** attacked the model's central inefficiency: with a first-order
scorer, whether span $i$ links to $j$ ignores what $j$ already links to, so the model
cannot enforce cluster-level consistency, and enumerating all span pairs is $O(T^4)$.
Their **coarse-to-fine** pruning scores pairs cheaply, keeps only the top antecedents
per span, then rescores those with the expensive model; a **higher-order** inference
step then refines each span's representation using its current antecedent
distribution, iterated a few times, which lets a decision see the emerging
cluster.[^lee2018] This pushed OntoNotes past 73 F1.

**Joshi et al. / SpanBERT (2019)** swapped the encoder. Replacing the ELMo/LSTM stack
with BERT, and then with **SpanBERT** — a variant pretrained by masking and predicting
contiguous _spans_ rather than individual tokens, which matches coreference's
span-centric structure — lifted OntoNotes to roughly 79 F1 with no change to the
coreference architecture.[^joshi2019] The result underlined a theme from the
dependency-parsing lesson: much of the recent gain came from the representation, not
the clustering algorithm.

**Wu et al. / CorefQA (2020)** reframed the task entirely. Instead of scoring span
pairs, it treats each mention as a **question** ("who does _she_ refer to?") and runs
a span-extraction question-answering model to find its antecedents in the
document.[^wu2020] Posing coreference as QA lets it inherit large QA pretraining data
and a bidirectional scoring of the mention and candidate, and it reached about 83 F1
on OntoNotes. The trajectory — from hand-built mention detectors and pairwise
classifiers to a single span network, to pruning and higher-order inference, to
span-pretrained encoders, to a QA formulation — is a compression of the whole
architecture into the encoder plus a light scoring head, exactly the direction the
mention-ranking model pointed toward.

## Where this continues

Coreference resolution is a running tally of _who_ and _what_ a text is about. We
detected mentions, walked through the mention-pair, mention-ranking, and
entity-based architectures, built the neural end-to-end span model that scores
candidate antecedents directly off a pretrained encoder, scored it with the CoNLL
F1, and traced the gender bias and the neural lineage that compress the whole
pipeline into an encoder with a light scoring head.

That is only the entity half of tracking a discourse. What makes a run of sentences
_cohere_ — the relations between clauses, the continuity of salient entities, and
shared topic — continues in
[coherence and discourse structure](/natural-language-processing/linguistic-structure/coherence-and-discourse-structure),
where coherence is measured, in part, _over_ the coreference chains recovered here.

[^jm-intro]: **Jurafsky & Martin**, _Speech and Language Processing_ (3rd ed.), Ch. 21 — Coreference Resolution: mentions (referring expressions) and referents; two mentions corefer when they denote the same discourse entity, as with _Victoria Chen_ and _she_.
[^jm-model]: **Jurafsky & Martin**, Ch. 21 intro — the discourse model: mentions evoke an entity into the model on first use and access it thereafter; anaphora, anaphor, antecedent, singleton, coreference chain; nested mentions; entity linking maps a discourse entity to a real-world individual (e.g. Wikipedia).
[^jm-ling]: **Jurafsky & Martin**, §21.1 — Coreference Phenomena: Linguistic Background: indefinite, definite, pronoun, and name referring expressions; information status and the given–new/accessibility scale; non-referring appositives, predicatives, expletives, and generics.
[^jm-props]: **Jurafsky & Martin**, §21.1.4 — Linguistic Properties of the Coreference Relation: number/person/gender agreement, binding constraints, recency, grammatical role, verb semantics, selectional restrictions; the difficulty of enforcing number agreement, and singular _they_.
[^jm-tasks]: **Jurafsky & Martin**, §21.2 — Coreference Tasks and Datasets: OntoNotes does not label singletons, which are 60–70% of entities and hard to distinguish from non-referential NPs, raising scores relative to corpora that include them.
[^jm-mention]: **Jurafsky & Martin**, §21.3 — Mention Detection: high-recall proposal of NPs, possessives, and named entities (or all n-gram spans); rule-based filters for pleonastic _it_; learned referentiality/anaphoricity/discourse-new classifiers; hard filtering hurts, so systems fold detection into an end-to-end model.
[^jm-arch]: **Jurafsky & Martin**, §21.4 — Architectures for Coreference Algorithms: the Ng (2010) categorization by mention- vs. entity-based decisions and by whether ranking is used.
[^jm-mp]: **Jurafsky & Martin**, §21.4.1 — The Mention-Pair Architecture: a binary coreference classifier over a candidate anaphor/antecedent pair; the Soon et al. training-sample heuristic; closest-first vs. best-first clustering; its two flaws (no comparison of candidates, no entity view).
[^jm-mr]: **Jurafsky & Martin**, §21.4.2 — The Mention-Rank Architecture: a softmax over all prior mentions plus a dummy $\epsilon$ for "no antecedent", learning anaphoricity jointly with coreference; latent gold antecedents; transitive closure to cluster.
[^jm-entity]: **Jurafsky & Martin**, §21.4.3 — Entity-based Models: linking a mention to a prior entity/cluster; cluster size and shape features; learned cluster representations; entity-based models are more expressive but have not yielded large gains, so mention-ranking remains most common.
[^jm-features]: **Jurafsky & Martin**, §21.5 — Classifiers using hand-built features: features of the anaphor, antecedent, and pair (head word, attributes, length, grammatical role, mention type, distance, string/head match, cosine); the importance of feature conjunctions; which features still help neural models.
[^jm-neural]: **Jurafsky & Martin**, §21.6 — A neural mention-ranking algorithm (the Lee et al. 2017 `e2e-coref` model): all spans up to width $\approx 10$; the score $s(i,j) = m(i)+m(j)+c(i,j)$ with $s(i,\epsilon)=0$; span representation $g_i$ from first/last/head-attention vectors; feedforward mention and antecedent scores with $g_i \circ g_j$; the latent-antecedent (summed) loss; learned head attention.
[^jm-eval]: **Jurafsky & Martin**, §21.7 — Evaluation of Coreference Resolution: model-theoretic comparison of hypothesis and reference chains; the link-based MUC, mention-based B³, and entity-based CEAF metrics; the CoNLL F1 as their average, computed with reference implementations.
[^jm-winograd]: **Jurafsky & Martin**, §21.8 — Winograd Schema problems: minimal pairs differing in one word that flip the preferred antecedent; the Winograd Schema Challenge; pretrained language models now solve much of the original set, motivating harder datasets.
[^jm-bias]: **Jurafsky & Martin**, §21.9 — Gender Bias in Coreference: the WinoBias paradigm; systems of all architectures do ~21 F1 worse in the anti-stereotypical case; gender-swapping data augmentation with debiased embeddings removes the gap; the GAP gender-balanced benchmark.
[^lee2017]: **Lee et al. (2017)**, "End-to-end Neural Coreference Resolution," EMNLP 2017. The `e2e-coref` model: enumerate spans up to a width bound, represent each by first/last/head-attention vectors, score $s(i,j)=m(i)+m(j)+c(i,j)$ with $s(i,\epsilon)=0$, and train with the summed latent-antecedent loss; the first system to learn mention detection and coreference jointly, ~67 CoNLL F1 on OntoNotes.
[^lee2018]: **Lee et al. (2018)**, "Higher-order Coreference Resolution with Coarse-to-fine Inference," NAACL 2018. Coarse-to-fine antecedent pruning to tame the $O(T^4)$ span-pair cost, plus higher-order inference that iteratively refines each span's representation from its antecedent distribution to enforce cluster-level consistency; raised OntoNotes past ~73 F1.
[^joshi2019]: **Joshi et al. (2019)**, "BERT for Coreference Resolution: Baselines and Analysis," EMNLP 2019, and **Joshi et al. (2020)**, "SpanBERT: Improving Pre-training by Representing and Predicting Spans," TACL. Replacing the encoder with BERT and then SpanBERT (pretrained by masking contiguous spans) lifted OntoNotes to roughly 79 F1 without changing the coreference architecture.
[^wu2020]: **Wu et al. (2020)**, "CorefQA: Coreference Resolution as Query-based Span Prediction," ACL 2020. Reformulates coreference as question answering — each mention becomes a query and a span-extraction QA model finds its antecedents — inheriting QA pretraining data and bidirectional scoring; about 83 F1 on OntoNotes.
