Skip to main content

A library for basic NLP metric score implementations

Project description

AI Metrics

AI Metrics is a Python library for basic Natural Language Processing (NLP) metric score implementations. This library provides various metrics commonly used in evaluating NLP models, such as accuracy, BERT score, BLEU score, and ROUGE score.

Table of Contents

Installation

You can install the library using pip. First, clone the repository:

git clone https://github.com/hari-hud/ai-metrics.git
cd ai-metrics

Then, install the dependencies:

pip install -r requirements.txt

Finally, install the library in editable mode:

pip install -e .

Usage

Here are some examples of how to use the different metrics provided by the library:

Metrics

Accuracy Score

from metrics.nlp.accuracy_score import AccuracyScore

ground_truths = ["label1", "label2", "label3"]
predictions = ["label1", "label2", "label3"]

accuracy = AccuracyScore()
score = accuracy.get_score(ground_truths, predictions)
print(score)  # Output: {'accuracy': 1.0}

BERT Score

from metrics.nlp.bert_score import BertScore

ground_truths = ["The cat is on the mat."]
predictions = ["The cat is sitting on the mat."]

bert_score = BertScore()
score = bert_score.get_score(ground_truths, predictions)
print(score)  # Output: {'bert_f1': <float_value>}

BLEU Score

from metrics.nlp.bleu_score import BLEUScore

ground_truths = ["The cat is on the mat."]
predictions = ["The cat is on the mat."]

bleu = BLEUScore()
score = bleu.get_score(ground_truths, predictions)
print(score)  # Output: {'bleu_score': <float_value>}

ROUGE Score

from metrics.nlp.rouge_score import ROUGEScores

ground_truths = ["The cat sat on the mat."]
predictions = ["The cat sat on the mat."]

rouge = ROUGEScores()
score = rouge.get_score(ground_truths, predictions)
print(score)  # Output: {'rouge_1_score': <float_value>, 'rouge_2_score': <float_value>, ...}

Running Tests

You can run the tests using pytest. To run all tests, execute:

pytest tests/

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue.

  1. Fork the repository
  2. Create your feature branch (e.g., git checkout -b feature/YourFeature)
  3. Commit your changes (e.g., git commit -m 'Add some feature')
  4. Push to the branch (e.g., git push origin feature/YourFeature)
  5. Open a pull request

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Contact

For any questions or suggestions, please contact:

Hari Hud
Email: hudharibhau@nvidia.com
GitHub: hari-hud

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

ai_metrics-0.0.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

ai_metrics-0.0.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file ai_metrics-0.0.1.tar.gz.

File metadata

  • Download URL: ai_metrics-0.0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for ai_metrics-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5ede574a7f03bc28eb8a6f061cb2c480b1d8dcd2b1aec8223e41ba249c3cf88a
MD5 305773c6fa744823a98afa474e3b6394
BLAKE2b-256 0a0656b38087a4a68590b7e1537deda7f9e5736fe070c08c12ae97a500cc255a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ai_metrics-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for ai_metrics-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 804777a73021f871464647fa4657182647a9ceafe28c51bf84b11a5fa1e87c7e
MD5 3122fd035a0fb2da33fdef2d71744467
BLAKE2b-256 9a0c3d56cc1092cb36563b7f531b0663350b4744240a95f53c033b3ace2e9eb1

See more details on using hashes here.

Supported by

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