Skip to main content

Enhanced evaluation metrics for NLP tasks

Project description

evalNLP

evalNLP is a Python library offering advanced metrics for evaluating Automatic Speech Recognition (ASR) and translation models. This library is designed to meet the needs of researchers and developers working on Natural Language Processing tasks.

Features

  • UWER: Universal Word Error Rate, an enhanced metric for fair transcription evaluation, adapted to morphologically rich and low-resource languages. It uses a revised version of the Levenshtein algorithm with weighted substitutions through a cost_func and segmentation operations with a u_cost. For more details, see the paper: Universal-WER: Enhancing WER with Segmentation and Weighted Substitution for Varied Linguistic Contexts.

  • UTER: (Coming Soon) Universal Translation Error Rate, a robust metric for translation evaluation. It provides scores that closely align with human Direct Assessment (DA) evaluations, even for low-resource languages.

Installation

Install evalNLP using pip:

pip install evalnlp

Usage

The uwer function is defined as:

def uwer(ref: str, hyp: str, cost_func=None, u_cost=None):

By default:

  • The substitution cost function (cost_func) uses the Sorensen-Dice similarity measure.
  • You can also use an average-based function that combines CER, similarity_rate_lcs, jaccard_coefficient_lcs, fuzzy_ratio, and Sorensen-Dice by passing "moyenne" as the cost_func parameter.
  • The union cost (u_cost) is defined as described in the paper.

The uwer function works with both single strings and lists of strings.

Example with single strings:

from evalnlp import uwer

reference = "This is a reference"
hypothesis = "This is a hypothesis"
score = uwer(reference, hypothesis)
print(f"UWER Score: {score}")

Example with lists:

from evalnlp import uwer

references = ["This is a reference", "Another reference"]
hypotheses = ["This is a hypothesis", "Another hypothesis"]
scores = uwer(references, hypotheses)
print(f"UWER Scores: {scores}")

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

evalnlp-0.1.2.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

evalnlp-0.1.2-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file evalnlp-0.1.2.tar.gz.

File metadata

  • Download URL: evalnlp-0.1.2.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for evalnlp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9771fd638d11de2a89b5dd3b7fc853ddd95024515ba610c99bd4d182607a5284
MD5 ee621bf07d6c691dc05aabaaac831a95
BLAKE2b-256 a60071408aa43c5a6d9ad263ccf506c8896b4fa6e2fd3ab08b2be962e51576fd

See more details on using hashes here.

File details

Details for the file evalnlp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: evalnlp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for evalnlp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1dbdb0445053f9b0b928252d2a4cabc2618927946d56d23da07dc656b9bc212e
MD5 d0097b491a6f421280b08cd63c9d5580
BLAKE2b-256 35eba07170ca2fecf321c889380c0278d4a1f72752cb67cad20084da0e20fc13

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