Coreference Resolution › Worked Example
Language AI HandbookAll chapters 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 .
Step 1. Enumerate spans with . The three widths contribute 7, 6, and 5 spans, for 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 and , with by definition. Then
Step 5. Select the highest-scoring option. "She" links to "Ana". For this trace, let the score of linking "Bo" to "Ana" be , 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]Expand
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]Expand

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!