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 seq-eval

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.1.tar.gz (5.4 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.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sequence-evaluate-0.0.1.tar.gz
  • Upload date:
  • Size: 5.4 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.1.tar.gz
Algorithm Hash digest
SHA256 37ae8905a93abd42243fc7a131282601385f1d7d222cae7e046b062aebbf6ce4
MD5 99c54ee24efafa55a31b786dc8c2581d
BLAKE2b-256 58e8221c8248ec29620eef9dc48f43f6d2550adec988f6fecf6b4708fc08ffd5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sequence_evaluate-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6edb5b67dbcac77375e8b6bf9bba40604d12500d4617e633654d54b2033222d8
MD5 fde1d9c230e097aa8d495b7c55e628ad
BLAKE2b-256 6ab49d54806a8dd7f293c483760b4a7c7c4700af91f81fc81b0056453d0ccd04

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