Skip to content

Yusheng-0809/coreference-resolution

 
 

Repository files navigation

Coreference resolution in NLP with AllenNLP and Huggingface

ℹ️ More theoretical background supported by examples can be found in our introductory blog post.

🤗 More details about the most popular coreference resolution libraries (followed by their strengths, weaknesses, and problems) can be found in our second blog article.

👌 Some ideas concerning mentioned libraries and improvements upon AllenNLP and Huggingface solutions are described in detail in our last blog post.

What is coreference resolution

Coreference resolution (CR) is an NLP task that aims to group expressions referring to the same real-world entity to acquire less ambiguous text. It can be very useful in such tasks as text understanding, information extraction, summarization, or question answering.

Most popular CR libraries

We provide Jupyter notebooks showing the most basic usage of Huggingface NeuralCoref and Allen Institute (AllenNLP) coreference resolution models.
➡️ huggingface_neuralcoref.ipynb
➡️ allennlp_coreference_resolution.ipynb

More details about the models and some of their most common problems can be found in our second blog post.

Installation

We've encountered some difficulties during the installation of both libraries in a single Python/Conda environment. However, finally, we've come up with the setting which seems to work for our needs:

pip install spacy==2.1.0
python -m spacy download en_core_web_sm
pip install neuralcoref --no-binary neuralcoref
pip install allennlp
pip install --pre allennlp-models

We consider the smallest spaCy model (en_core_web_sm) sufficient and not deviating from larger models but feel free to download whatever model seems best for you.

Improvements upon the libraries

We've encountered several problems with clusters resolving in a text (the last step of replacing found mentions). As AllenNLP seems to find more suitable clusters (makes significantly fewer mistakes), we've decided to focus on this model. That's why we propose several improvements regarding its replace_corefs method.

➡️ More details are provided by the improvements_to_allennlp_cr.ipynb notebook.

However, we still believe that Huggingface NeuralCoref is a valuable model that serves great as a reference. That's why we came up with a couple of intersection strategies - simply an ensemble of both models' outputs (clusters).

➡️ Their implementation and usage can be found in the intersection_strategies.ipynb.

References

We're using the two most popular coreference resolution libraries: Huggingface NeuralCoref and AllenNLP implementation of CorefResolver.

Implementation Description License
Huggingface NeuralCoref 4.0 It's a CR extension for spaCy - very popular NLP library. NeuralCoref resolves coreference clusters using neural networks. More information can be found on their blog post and the demo. License: MIT
AllenNLP coreference resolution It's an open-source project being a part of AI2 institute which introduced e.g. ELMo. Their span-ranking coreference resolution model is also premised upon a neural model. More information is provided by their demo. License

About

Coreference Resolution

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 78.7%
  • Python 21.3%