Coreferee is a custom spaCy pipeline extension for coreference resolution: it groups mentions such as “Gebru” and “she” when they refer to the same entity. Its transformer-based models address difficult cases, including cataphora, where a pronoun appears before its antecedent. section 11.5.1 section 11.5
A practical setup and integration path is:
- Create a separate virtual environment because Coreferee requires spaCy 3.0.0–3.5.4 and may conflict with environments using spaCy 3.7.5. section 11.5.1
- Install a transformer language model, add the Coreferee pipeline to spaCy, and process text with the resulting NLP object. section 11.5.1
- Inspect results through the document’s `_.coref_chains` extension and its printable chain representation. section 11.5.1
- Treat predictions as a difficult natural-language-understanding capability rather than automatic proof of commonsense reasoning. section 11.5
Resolving mentions in a Wikipedia excerpt
Load `en_core_web_trf`, add `coreferee`, and process a Timnit Gebru excerpt. The resulting chains can identify `Gebru(13), she(16), she(26), she(34)` and `advice(51), it(56)`, making the model’s intermediate output inspectable. section 11.5.1
Listing 11.4 Coreference chains from Wikipedia text
>>> import spacy, coreferee #1
>>> nlptrf = spacy.load('en_core_web_trf')
>>> nlptrf.add_pipe('coreferee')
<coreferee.manager.CorefereeBroker at 0x...>
>>> doc_gebru = nlptrf(text_gebru) #2
>>> doc_gebru._.coref_chains
[0: [13], [16], [26], [34],
1: [51], [56]]
>>> doc_gebru._.coref_chains.print()
0: Gebru(13), she(16), she(26), she(34) #3
1: advice(51), it(56)
Browse the runnable spaCy setup and printed coreference chains for a concrete integration pattern. section 11.5.1
