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.2.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.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sequence-evaluate-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 e605e8bcd54800f273523933814b80a2330782733e16dc8fe8ba059888f72699
MD5 0dceeceb446cd5d18f954028e7e66c8c
BLAKE2b-256 e1ad8b3a0af6cb54277adf16ede9ae2a0081e2eb6b6462c2cbe080c3c5ec2b6b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sequence_evaluate-0.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9904f4fec7dfae6301acfa2e0f0fd3185ad1ff96db24ae62bbdb4183d071a245
MD5 5750b9b648461d73942a359a6da5aa82
BLAKE2b-256 d19d079c5093dcba2f6dc4961ecb2773197edca2921cbd4a782b0c8e0dccf9a9

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