Skip to content
AI360XpertBeta

Coreference Resolution

Coreference resolution groups every mention of the same entity into one chain, so Mira, She and her count as one person instead of three strangers.

Mira links to She and pup links to it, forming two chains, so She joins Mira with probability 0.74.
Mira links to She and pup links to it, forming two chains, so She joins Mira with probability 0.74.

Why Does This Exist?

Read this: "Mira adopted a stray pup. She named it Biscuit." You never wonder who She is or what it means. A pipeline without coreference does. It sees separate strings where you see two entities, so question answering answers "Who named Biscuit?" with nothing, and counts of people and pets come out doubled.

That is the concrete breakage. Pronouns carry no meaning on their own. Without a step that clusters mentions into chains, every downstream counter miscounts. A sentiment system credits "it" to nobody. An extractor emits two people named Mira and She.

This page covers the clustering step itself: finding mentions, scoring pairs, and linking chains. Finding the spans in the first place belongs to named entity recognition. Turning chains into rows belongs to information extraction. The one prerequisite is small: a mention is any span that could refer to an entity, usually a proper noun, a noun phrase, or a pronoun. Everything else on this page builds on that.

Think of It Like This

Cloakroom tags at a busy event

You hand your coat to a cloakroom and get ticket 14. Your friend hands over a scarf and gets ticket 27. Later you return ticket 14 and expect your coat, not any coat. The ticket means nothing by itself. It works because the attendant clipped it to your item when you arrived.

Mentions are tickets. "Mira" is the first time the coat is handed over. "She" is ticket 14 coming back. The model is the attendant, matching each ticket to the item it was clipped to. Two tickets clipped to one coat form a chain, just as two mentions of one person do.

Where it stops: a cloakroom never has two identical coats fighting over one ticket. Text does. "She" after two women is genuinely ambiguous, and no attendant can resolve it without asking. That is when the model must guess from distance and agreement cues, and sometimes it guesses wrong.

How It Actually Works

Modern systems do three things in order: detect mentions, score pairs, then cluster.

Mention detection

Every span up to some width (often 10 tokens) gets a mention score m(i)m(i) from an encoder. Spans below a cutoff are dropped. So "Mira", "a stray pup", "She", "it", and "Biscuit" survive, while "adopted a" does not. This keeps the pair step quadratic in mentions, not in all spans.

Pairwise scoring

For a later mention jj and each earlier candidate ii, the model computes an antecedent score s(i,j)s(i, j). Here hih_i and hjh_j are the span vectors from a transformer, ∘\circ is elementwise product, ϕ(i,j)\phi(i, j) holds distance and agreement features, and FFNN is a small feedforward net:

s(i,j)=FFNN([hi,hj,hi∘hj,ϕ(i,j)])s(i, j) = \text{FFNN}([h_i, h_j, h_i \circ h_j, \phi(i, j)])

In plain words: hih_i says what the earlier span means in context, hjh_j says what the later span means, their product says how similar they are, and ϕ\phi says whether linking them is plausible (close together, same number and gender). Each mention also gets a no-link score s(ϵ,j)s(\epsilon, j) for starting a new entity. The model links jj to the best scorer among earlier mentions and ϵ\epsilon.

Worked example with real numbers

Take "Mira adopted a stray pup. She named it Biscuit." Focus on j=j = "She" with candidate i=i = "Mira", 5 tokens apart, both singular and feminine.

Suppose the trained weights produce s=2.0×sim−0.1×dist+0.5×agrees = 2.0 \times \text{sim} - 0.1 \times \text{dist} + 0.5 \times \text{agree}, with cosine similarity 0.820.82, distance 55, agreement 11:

s=2.0×0.82−0.1×5+0.5×1=1.64−0.50+0.50=1.64s = 2.0 \times 0.82 - 0.1 \times 5 + 0.5 \times 1 = 1.64 - 0.50 + 0.50 = 1.64

Against "a stray pup" the similarity is 0.050.05, distance 33, agreement 00:

s=2.0×0.05−0.1×3+0.5×0=0.10−0.30=−0.20s = 2.0 \times 0.05 - 0.1 \times 3 + 0.5 \times 0 = 0.10 - 0.30 = -0.20

Softmax over {1.64,−0.20,0.0}\{1.64, -0.20, 0.0\} for the no-link option gives exponentials 5.165.16, 0.820.82, 1.001.00, summing to 6.986.98. So P(Mira)=5.16/6.98≈0.74P(\text{Mira}) = 5.16 / 6.98 \approx 0.74. "She" joins Mira with probability 0.740.74, which is exactly the link the diagram draws. The same arithmetic on "it" favors the pup, giving the second chain.

Code

The snippet below clusters mentions with a union-find pass over scored pairs, using only the standard library. Scores mirror the worked example.

def cluster(mentions: list[str], pairs: dict[tuple[int, int], float], cutoff: float = 0.5) -> list[list[str]]:    parent = list(range(len(mentions)))    def find(x: int) -> int:        while parent[x] != x:            parent[x] = parent[parent[x]]            x = parent[x]        return x    for (i, j), s in pairs.items():        if s >= cutoff:            parent[find(j)] = find(i)    out: dict[int, list[str]] = {}    for k, m in enumerate(mentions):        out.setdefault(find(k), []).append(m)    return sorted(out.values(), key=len, reverse=True)ms = ["Mira", "pup", "She", "it"]sc = {(0, 2): 0.74, (1, 3): 0.81, (0, 3): 0.12}print(cluster(ms, sc))  # -> [['Mira', 'She'], ['pup', 'it']]

Watch Out For

Trusting the nearest noun

The closest matching noun is often wrong. In "Mira told Ana that she passed", "she" sits next to Ana but frequently refers to Mira. Proximity is one feature, not the decision. If your chains keep attaching to the nearest candidate, your distance weight is swamping agreement and similarity, so retune on examples with two same-gender entities before shipping.

Scoring singular they as a mismatch

"They" with a singular antecedent ("Alex said they won") looks like a number mismatch to older agreement features and gets downweighted. Modern style guides accept singular they, and dialogue data is full of it. Treat number agreement as a soft cue with an exception for they and them, or those chains will split one person into two.

The Quick Version

  • Coreference resolution clusters mentions of one entity into a chain, so Mira, She and her resolve to a single person.
  • The pipeline is mention detection, pairwise antecedent scoring with similarity plus distance and agreement features, then clustering.
  • The score s(i,j)s(i, j) blends span vectors, their product, and metadata; each mention links to its best antecedent or starts a new entity.
  • In the worked example, She links to Mira with probability about 0.74 from a score of 1.64 against weaker rivals.
  • Chains feed question answering, summarization and extraction; broken chains mean miscounted entities downstream.