Skip to main content

Coreference-Resolution library

Project description

This is a coreference resolution utility package that supports multiple transformer-based coreference resolvers. The current version supports an improved version of the AllenNLP SPANBERT model and a GPT3 (text-davinci-003) based resolver that supports few-shot prompts. Coreference resolution is the task of identifying all expressions (e.g., pronouns, names, definite descriptions) in a text that refer to the same entity. This is a crucial task for many natural language processing applications such as question answering, summarization, and sentiment analysis.

Our tool is designed to help researchers and developers experiment with different transformer-based coreference resolvers and compare their performance. The package is currently under experimentation and cannot be readily used. However, we aim to make it publicly available in the future.

The AllenNLP SPAN-BERT model is a state-of-the-art coreference resolution model that is based on the popular BERT architecture. We have made improvements to the model by handling nested coreferent mentions and cataphoras. The GPT3-based resolver, on the other hand, is a cutting-edge model that is capable of few-shot learning, meaning that it can adapt to new variations with a few example prompts.

Our Python package is designed to be easy to use and integrate with existing NLP pipelines. It provides a simple interface for loading and using different coreference resolvers, and supports various input formats such as raw text and pre-processed text. We believe that our tool will be a valuable resource for researchers and developers working on coreference resolution and related NLP tasks.

Examples of using CorefTools

Here are a few examples of how to use CorefTools, a Python package for coreference resolution.

Example 1: Using the SpanBERTResolver

Note that by default we use spanbert-large model, you can alter the model by passing the corresponding model_url while initializing the SpanBERTResolver class

from coreftools.corefresolvers import SpanBERTResolver

resolver = SpanBERTResolver()
example_query = "John and Jane went to the park. They had a picnic and played frisbee. When they were done, they walked home together."
resolved_query = resolver.resolve_coref(example_query)
print(resolved_query)

# Output
# John and Jane went to the park. John and Jane had a picnic and played frisbee. When John and Jane were done, John and Jane walked home together.

Example 2: Using the GPTResolver

The following example demonstrates how to use the GPTResolver class to resolve coreferences using the GPT-3 model. Note that we use "text-davinci-003" as our default model due to performance reasons. You can also pass other models, such as "text-davinci-002" or "GPT3.5" with engine parameter to resolve_coref method of the GPTResolver class. This would resemble gpt.resolve_coref(query_to_resolve, engine=your_choice_of_engine)

from coreftools.corefresolvers import GPTResolver

resolver = GPTResolver()
example_query = "My dog is very cute. She loves to play fetch."
resolved_query = resolver.resolve_coref(example_query)
print(resolved_query)

# Output
# My dog is very cute. My dog loves to play fetch

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coreftools-0.2.5-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file coreftools-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: coreftools-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.0

File hashes

Hashes for coreftools-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3bbfbccd539f419176c4d21629fd7e61449305b40afbc9129e991dff15415465
MD5 627980bb148f547c44d452568dab849f
BLAKE2b-256 ec9b784a03468e5c50ebd243227315392b804fdf5e088fb578cdeb3d209b4326

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page