Coreference resolution

Group every mention of the same entity: score each span as a mention, score its earlier spans plus a dummy “no antecedent” at 0, pick by softmax, and read the clusters off the links.

8 min read671 wordsadvanced0 viewsupdated 2026-10-15

Definition

Coreference resolution is the task of finding every span of a document that refers to some entity (a mention) and partitioning the mentions into clusters, one per entity. The standard neural approach is the end-to-end span-ranking model of Lee, He, Lewis and Zettlemoyer (EMNLP 2017), which learns mention detection and antecedent linking jointly from raw text.

The task

Input: a document. Output: a set of clusters. In “Alice called Bob because she needed his car. He lent it to her.” the clusters are {Alice, she, her}, {Bob, his, He} and {his car, it}. Mentions can nest: “his” sits inside “his car” and belongs to a different entity.

It is hard because the cues are scattered. Gender and number agreement rule out some links, but choosing between two compatible candidates often needs world knowledge. In “The trophy doesn't fit in the suitcase because it is too big”, only physical knowledge says “it” is the trophy. This is the Winograd schema (Levesque et al. 2012).

Before deep learning came Hobbs' (1978) syntactic search for pronoun antecedents, then mention-pair classifiers over hand-built features (Soon, Ng and Lim 2001), then the deterministic multi-pass sieve of Stanford (Raghunathan et al. 2010). They all depended on a parser and a separate mention detector, so errors there could not be fixed later.

End-to-end span ranking

Lee et al. drop the pipeline. They consider every span up to L=10L=10 words, give each one a vector, and let one network decide both whether it is a mention and which earlier span it points to. Each span ii picks an antecedent yi∈Y(i)={ε,1,…,i−1}y_i\in\mathcal{Y}(i)=\{\varepsilon,1,\dots,i-1\}, where the dummy ε\varepsilon means “not a mention, or the first mention of its entity”.

input document, gold clusters underlined (OntoNotes marks no singletons)AlicecalledBobbecausesheneededhiscar.Helentittoher.{Alice, she, her} · {Bob, his, He} · {his car, it} (“his” sits inside “his car”: spans may nest)encoder over the document → x*_tBiLSTM over GloVe + char-CNN (2017)later: BERT / SpanBERT token states,same span-ranking head on topspan g_i = [x*_START, x*_END, x̂_i, φ]x̂_i: attention over the span's wordsall spans of ≤ 10 words; “his car” =[x*_his, x*_car, head≈car, width 2]mention score s_m(i) = w_m·FFNN(g_i)keep the top λT spans, λ = 0.4“his car” 0.7, “it” 0.4 survive;“needed his” scores low and is pruneds(i,j) = s_m(i) + s_m(j) + s_a(i,j)s_a: FFNN on [g_i, g_j, g_i∘g_j, φ(i,j)]s(it, his car) = 0.4 + 0.7 − 0.4 = 0.7s(it, Bob) = 0.4 + 1.0 − 2.4 = −1.0P(y_i) = softmax over {ε, 1, …, i−1}dummy ε fixed at s(i,ε) = 0argmax links → connected componentsloss: −log Σ P(gold antecedents)P(antecedent of “it”), 7 candidates:his car0.516ε0.256Bob0.094she→Alice, her→she, his→Bob, He→Bob,it→his car; Alice, Bob, his car → εscored with MUC, B³ and CEAFφ4; CoNLL F1 = their mean (Lee et al. 2017: 67.2 on CoNLL-2012 test)
fig.The span-ranking pipeline on the example text. Each span becomes $g_i$; a mention score prunes the candidates; each surviving span scores all earlier spans and the dummy ε at 0; argmax links form the clusters. For “it”, the pair score with “his car” is 0.4 + 0.7 − 0.4 = 0.7, which wins the softmax with 0.516.
gi=[ xSTART(i)∗,  xEND(i)∗,  x^i,  ϕ(i) ],sm(i)=wm⋅FFNNm(gi)g_i=\big[\,x^*_{\mathrm{START}(i)},\;x^*_{\mathrm{END}(i)},\;\hat x_i,\;\phi(i)\,\big],\qquad s_m(i)=w_m\cdot\mathrm{FFNN}_m(g_i)
xt∗x^*_t
contextual state of token tt (a BiLSTM in 2017; BERT or SpanBERT later)
x^i\hat x_i
attention-weighted sum of the span's word embeddings, a learned soft head word
ϕ(i)\phi(i)
embedding of the span width
sm(i)s_m(i)
mention score: how likely span ii is a mention at all
s(i,j)=sm(i)+sm(j)+sa(i,j),s(i,ε)=0,P(yi=j)=es(i,j)∑j′∈Y(i)es(i,j′)s(i,j)=s_m(i)+s_m(j)+s_a(i,j),\quad s(i,\varepsilon)=0,\qquad P(y_i=j)=\frac{e^{s(i,j)}}{\sum_{j'\in\mathcal{Y}(i)}e^{s(i,j')}}
sa(i,j)s_a(i,j)
antecedent score, wa⋅FFNNa([gi,gj,gi∘gj,ϕ(i,j)])w_a\cdot\mathrm{FFNN}_a([g_i,g_j,g_i\circ g_j,\phi(i,j)]); ϕ(i,j)\phi(i,j) holds speaker, genre and distance features
s(i,ε)=0s(i,\varepsilon)=0
fixed dummy score: a link is predicted only if some pair score is positive

There is no gold antecedent for each span, only gold clusters. So the loss marginalises over every correct choice:

L=−∑ilog⁡ ⁣ ⁣∑y^∈Y(i)∩GOLD(i) ⁣ ⁣P(y^)\mathcal{L}=-\sum_{i}\log\!\!\sum_{\hat y\in\mathcal{Y}(i)\cap\mathrm{GOLD}(i)}\!\!P(\hat y)
GOLD(i)\mathrm{GOLD}(i)
earlier spans in the gold cluster of ii; {ε}\{\varepsilon\} if ii is not a mention or opens its cluster

Scoring all pairs of all spans would be O(T4)O(T^4) in document length TT. Two prunes make it tractable: keep only the λT\lambda T spans with the highest sms_m (λ=0.4\lambda=0.4), and let each consider at most K=250K=250 antecedents. Clusters are the connected components of the argmax links.

Data, metrics and reference scores

Benchmark
CoNLL-2012 shared task on English OntoNotes 5.0 (Pradhan et al. 2012): 2,802 train, 343 dev, 348 test documents across news, broadcast, conversation, web and other genres. Singletons are not annotated.
MUC
Vilain et al. 1995. Link-based: counts the links needed to join the response's pieces of each key cluster.
B³
Bagga and Baldwin 1998. Mention-based: per-mention precision and recall of its cluster's overlap, averaged.
CEAF$_{\phi_4}$
Luo 2005. Entity-based: best one-to-one alignment of key and response clusters, similarity ϕ4=2∣K∩R∣/(∣K∣+∣R∣)\phi_4=2|K\cap R|/(|K|+|R|).
CoNLL F1
Mean of the three F1 scores, the headline number.
Test CoNLL F1
Lee et al. 2017: 67.2 (single), 68.8 (ensemble). Lee et al. 2018 (coarse-to-fine, ELMo): 73.0. BERT-large (Joshi et al. 2019): 76.9. SpanBERT-large (Joshi et al. 2020): 79.6.
shift Δ = 0.00 on every s_m · 3 predicted clusters · CoNLL F1 100.0AlicecalledBobbecausesheneededhiscar.Helentittoher.m0m1m2m3m4m5m6m7bars: predicted cluster · arcs: argmax antecedent · gold {Alice she her} {Bob his He} {his-car it}P(antecedent of “it”) = softmax over ε and the 6 earlier mentionsε (no antecedent)s=0.000.256m0 Alices=-2.100.031m1 Bobs=-1.000.094m2 shes=-2.300.026m3 hiss=-2.000.035m4 his cars=0.700.516 gold ← argmaxm5 Hes=-1.800.042s(i,j) = s_m(i) + s_m(j) + s_a(i,j), s(i,ε) = 0 · loss −log Σ P(gold) = 0.662precisionrecallF1MUC100.0100.0100.0B³100.0100.0100.0CEAFφ4100.0100.0100.0CoNLL F1 = mean of the three F1 = 100.0predicted clusters{m0 m2 m7}{m1 m3 m5}{m4 m6}Δ = 0: every mention's argmax matches a gold antecedent (or ε for m0, m1, m4)
mention
fig.The span-ranking decision on the example text with hand-set scores. At shift Δ = 0 every argmax matches gold and CoNLL F1 is 100; “it” puts 0.516 on “his car” and 0.256 on ε (loss 0.662). Δ = +0.25 lets “his car” link to Bob (0.7 + 1.0 − 2.0 + 0.5 = 0.2 > 0), merging two entities: MUC F1 90.9, B³ 82.4, CEAFφ4 70.0, CoNLL 81.1. Δ = +0.75 merges everything into one cluster (CoNLL 53.9) while MUC recall stays 100. Δ = −0.5 drops the it → his car link (CoNLL 84.9).

Worked example: the antecedent of “it”

candidate jsm(j)s_m(j)sa(it,j)s_a(\text{it},j)s(it,j)s(\text{it},j)P(y=j)P(y=j)
ε\varepsilon——0 (fixed)0.256
Alice1.0−3.5−2.10.031
Bob1.0−2.4−1.00.094
she0.8−3.5−2.30.026
his0.6−3.0−2.00.035
his car0.7−0.40.70.516
He0.8−3.0−1.80.042
s_m(it) = 0.4, shift Δ = 0. P is the softmax over the seven scores.

The argmax is “his car”, the gold antecedent, so the loss for this span is −ln⁡0.516=0.662-\ln 0.516=0.662. For “her” two gold antecedents exist, Alice (0.377) and she (0.508). The loss sums them, −ln⁡0.885=0.122-\ln 0.885=0.122, so the model is not penalised for spreading mass across correct choices. Averaged over all eight mentions the loss is 0.299.

Scoring the over-merged output at Δ = +0.25

  1. 1Response: {Alice, she, her} and {Bob, his, his car, He, it}. Key: {Alice, she, her}, {Bob, his, He}, {his car, it}.
  2. 2MUC: no key link is missing, so recall is 5/5=15/5=1. The big response cluster spans 2 key clusters, so it has 5−2=35-2=3 of its 4 links right. Precision is (2+3)/(2+4)=0.833(2+3)/(2+4)=0.833 and F1 is 0.909.
  3. 3B³: recall is 1. Precision is (32/3+(32+22)/5)/8=5.6/8=0.700\big(3^2/3+(3^2+2^2)/5\big)/8=5.6/8=0.700, so F1 is 0.824.
  4. 4CEAFϕ4_{\phi_4}: the best alignment pairs {Alice, she, her} with itself (ϕ4=1\phi_4=1) and {Bob, his, He} with the big cluster (ϕ4=6/8=0.75\phi_4=6/8=0.75). The total is 1.75, so recall is 1.75/3=0.5831.75/3=0.583, precision is 1.75/2=0.8751.75/2=0.875, and F1 is 0.700.
  5. 5CoNLL F1 =(90.9+82.4+70.0)/3=81.1=(90.9+82.4+70.0)/3=81.1.
python
1import torch
2import torch.nn.functional as F
3
4def antecedent_loss(s_m, s_a, gold):
5 """s_m: (N,) mention scores; s_a: (N, N) antecedent scores, only j < i used;
6 gold: (N, N+1) bool, column 0 = dummy antecedent. Returns loss and argmax links."""
7 N = s_m.size(0)
8 pair = s_m[:, None] + s_m[None, :] + s_a # s(i, j)
9 earlier = torch.ones(N, N).tril(-1).bool()
10 pair = pair.masked_fill(~earlier, float("-inf"))
11 scores = torch.cat([torch.zeros(N, 1), pair], dim=1) # s(i, eps) = 0
12 logp = F.log_softmax(scores, dim=1)
13 marg = torch.logsumexp(logp.masked_fill(~gold, float("-inf")), dim=1)
14 return -marg.mean(), scores.argmax(dim=1) - 1 # -1 means eps
15
16# Alice Bob she his "his car" He it her
17s_m = torch.tensor([1.0, 1.0, 0.8, 0.6, 0.7, 0.8, 0.4, 0.8])
18lower = [[-3.2], [0.5, -2.5], [-2.5, 0.2, -2.8], [-3.0, -2.0, -3.0, -3.5],
19 [-2.6, 0.4, -3.0, 0.6, -3.2], [-3.5, -2.4, -3.5, -3.0, -0.4, -3.0],
20 [0.1, -2.8, 0.6, -2.9, -3.5, -3.1, -3.6]]
21s_a = torch.zeros(8, 8)
22for i, row in enumerate(lower, start=1):
23 s_a[i, :i] = torch.tensor(row)
24
25gold = torch.zeros(8, 9, dtype=torch.bool)
26for cluster in [[0, 2, 7], [1, 3, 5], [4, 6]]:
27 for k, i in enumerate(cluster):
28 gold[i, 0] = k == 0 # first mention: eps is correct
29 for j in cluster[:k]:
30 gold[i, j + 1] = True
31
32loss, ante = antecedent_loss(s_m, s_a, gold)
33print(ante.tolist()) # [-1, -1, 0, 1, -1, 1, 4, 2]
34print(round(loss.item(), 3)) # 0.299
The antecedent softmax and marginal loss in PyTorch, on the toy scores above (torch was not available, so this was not run; the printed values were checked with the same maths in plain Python)

Use when

  • +No parser or separate mention detector; one model, one loss
  • +Swapping the encoder (BiLSTM → BERT → SpanBERT) lifted CoNLL F1 from 67.2 to 79.6 with the same head
  • +Marginal loss needs only gold clusters, not one chosen antecedent per mention

Avoid when

  • −Span enumeration is quadratic in length, so long documents need pruning or segmenting
  • −Decisions are local (one antecedent per span); a cluster can become inconsistent through chains of links
  • −Winograd-style cases still need world knowledge that local features lack

Check yourself

A span has pair scores −0.3, −1.2 and −2.0 to its three candidate antecedents. What does the model predict?

Check yourself

Why does the loss sum P over all gold antecedents instead of picking the nearest one?

Remember

  • ✓Each span picks an antecedent from {ε,1,…,i−1}\{\varepsilon,1,\dots,i-1\} by softmax over s(i,j)=sm(i)+sm(j)+sa(i,j)s(i,j)=s_m(i)+s_m(j)+s_a(i,j), with s(i,ε)=0s(i,\varepsilon)=0.
  • ✓Spans are [xstart∗,xend∗,x^,ϕ][x^*_{\text{start}},x^*_{\text{end}},\hat x,\phi]; pruning keeps λT\lambda T spans (λ=0.4\lambda=0.4) and up to K=250K=250 antecedents.
  • ✓Loss: −log of the total probability on correct antecedents, so only gold clusters are needed.
  • ✓Evaluated on CoNLL-2012 (OntoNotes 5.0) by the mean F1 of MUC, B³ and CEAFφ4; 67.2 in 2017, 79.6 with SpanBERT.
  • ✓Each metric has a bias (MUC favours merging), which is why the three are averaged.
← back to Deep Learning roadmap