Skip to main content

A python package to evaluate sequence-to-sequence models

Project description

SeqEval: A python package for evaluating Seq2Seq models

Sequence Evaluator (SeqEval) is a python package that computes metrics useful for evaluating Seq2Seq models for many tasks such as: machine translation, dialogue response generation, and text summarization. There already exists many packages to compute those metrics, but Seq2Eval puts them all in one place!

Installation

pip install sequence-evaluate

Usage

You can easily compute all metrics in just a few lines of code.
You first import the class SeqEval and create an instance of it:

from seq_eval import SeqEval
evaluator = SeqEval()

The evaluator expects two python lists containing candidates (outputs generated by the model) and references (ground-truth data).
For example:

candidates = ["he began by starting a five person war cabinet and included chamberlain as lord president of the council",
             "the siege lasted from 250 to 241 bc, the romans laid siege to lilybaeum",
             "the original ocean water was found in aquaculture"]

references = ["he began his premiership by forming a five-man war cabinet which included chamberlain as lord president of the council",
             "the siege of lilybaeum lasted from 250 to 241 bc, as the roman army laid siege to the carthaginian-held sicilian city of lilybaeum",
             "the original mission was for research into the uses of deep ocean water in ocean thermal energy conversion (otec) renewable energy production and in aquaculture"]

You can now compute all metrics by using the evaluate function: (Setting verbose=True prints out the results)

scores = evaluator.evaluate(candidates, references, verbose=True)

The function returns a dictionary containing all computed metric values:

{'bleu_1': 0.4428272792647754,
 'bleu_2': 0.35920252706356015,
 'bleu_3': 0.29702864345243746,
 'bleu_4': 0.2527668976020239,
 'inter_dist1': 0.1294642799346348,
 'inter_dist2': 0.5837103808275891,
 'intra_dist1': 0.31033264382268116,
 'intra_dist2': 0.7908440001400115,
 'rouge_1_f1': 0.6512670259900423,
 'rouge_1_precision': 0.8539562289562289,
 'rouge_1_recall': 0.5528035775713794,
 'rouge_2_f1': 0.3928074411537155,
 'rouge_2_precision': 0.5244559362206421,
 'rouge_2_recall': 0.3353174603174603,
 'rouge_l_f1': 0.6282785202429159,
 'rouge_l_precision': 0.8122895622895623,
 'rouge_l_recall': 0.5369305616983636,
 'semantic_textual_similarity': 0.8229544957478842}

Dependencies

Make sure that you have the following libraries installed:

transformers 4.16.2
sentence-transformers 2.2.0
ntlk 3.2.5
torch 1.10.0+cu111
rouge 1.0.1
numpy 1.21.5

Contact

Tarek Naous: Scholar | Github | Linkedin | Research Gate | Personal Wesbite | tareknaous@gmail.com



Project details


Download files

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

Source Distribution

sequence-evaluate-0.0.3.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

sequence_evaluate-0.0.3-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file sequence-evaluate-0.0.3.tar.gz.

File metadata

  • Download URL: sequence-evaluate-0.0.3.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.3

File hashes

Hashes for sequence-evaluate-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8704ca971c0a2685c9c29464cf576fd07230dcb85598ed52492dbc0ebd3f34a7
MD5 a433f3e560228555e08f8c7a39e9b469
BLAKE2b-256 0e361a48282c1250d929d3085c0a7b8683a4357ea5304cf7ea3351a381a492b8

See more details on using hashes here.

File details

Details for the file sequence_evaluate-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: sequence_evaluate-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.3

File hashes

Hashes for sequence_evaluate-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c330d543f8c95b9f1e92c20410a126be9e8cd54be6c3cc99a571e68009780955
MD5 fde118d005f0386d0e8503a61c7c83fc
BLAKE2b-256 6b798621f44612dddf602e600d8c8b1cd47f3fd4fb7a7f19873c62d56e034991

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