Coreference Resolution › Worked Example

Michael BrenndoerferNovember 17, 20263 min read
Language AI HandbookAll chapters
Part 9 of 67Coreference, Discourse, Pragmatics, and Dialogue
Chapter 56Coreference Resolution › Worked Example
Reading section 9 of 14 · Worked Example · 3 minSection 9 of 14 · 3 min

Section 9 of 14 · 3 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Before writing code, trace a tiny case completely by hand.

For the hand calculation, tokenize both periods separately. The tokens in Ana met Bo. She left. are Ana(0) met(1) Bo(2) .(3) She(4) left(5) .(6), so T=7T=7.

Step 1. Enumerate spans with W=3W=3. The three widths contribute 7, 6, and 5 spans, for WT−W(W−1)/2=21−3=18WT-W(W-1)/2=21-3=18 in total.

Step 2: prune to top-3 mentions using a toy mention scorer. Suppose it returns "Ana" 0.91, "Bo" 0.88, "She" 0.85, and assigns everything else below 0.15. The retained spans are the three single-token mentions. The span "Ana met" is gone, so no mention can ever have it as an antecedent.

Step 3: prune antecedents. "Ana" has none. "Bo" has one candidate ("Ana"). "She" has two ("Ana", "Bo").

Step 4: score pairs. Suppose the fine scorer returns s(She,Ana)=1.7s(\text{She}, \text{Ana}) = 1.7 and s(She,Bo)=0.4s(\text{She}, \text{Bo}) = 0.4, with s(She,ϵ)=0s(\text{She}, \epsilon) = 0 by definition. Then

P(Ana∣She)=e1.7e1.7+e0.4+1=5.47397.9658≈0.687,P(\text{Ana} \mid \text{She}) = \frac{e^{1.7}}{e^{1.7} + e^{0.4} + 1} = \frac{5.4739}{7.9658} \approx 0.687, P(Bo∣She)≈0.187,P(ϵ∣She)≈0.126.P(\text{Bo} \mid \text{She}) \approx 0.187, \qquad P(\epsilon \mid \text{She}) \approx 0.126.

Step 5. Select the highest-scoring option. "She" links to "Ana". For this trace, let the score of linking "Bo" to "Ana" be −0.5-0.5, so "Bo" selects null at score zero. "Ana" has only the null option.

The figure shows the three probabilities for "She" before the resolver emits a single link.

PythonIn [10]
CollapseExpand
worked_scores = {"Ana": 1.7, "Bo": 0.4, "null": 0.0}
_denom = sum(math.exp(v) for v in worked_scores.values())
antecedent_labels = list(worked_scores)
antecedent_probs = np.array(
    [math.exp(worked_scores[k]) / _denom for k in antecedent_labels]
)
VisualizationOut [11]
CollapseExpand
Ana has the highest score in the three-choice distribution for She. Bo and null both retain positive probability.
In the worked softmax for She, Ana receives probability 0.687, Bo receives 0.187, and null receives 0.126. The resolver selects Ana.

Step 6. Compute connected components. The only selected edge connects Ana and She. The components are {Ana, She} and {Bo}.

The whole trace is six steps, and each one can break:

  • If "Bo" had been pruned in step 2, the resolver could never link to it.
  • If the mention scorer had retained "met Bo" instead of "She", no antecedent decision could recover the missing pronoun span.
  • The decision in step 5 is greedy. A different threshold could leave "She" as a singleton.

That is the entire task at toy scale, and it scales up without changing shape.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy