Registry / ai-ml / evaluate

evaluate

JSON →
library0.4.6pypypi✓ verified 26d ago

Evaluate is a Hugging Face community-driven open-source library providing a standardized interface for accessing and comparing over 80+ evaluation metrics, datasets, and models. It simplifies the process of evaluating machine learning models, offering a consistent API for various tasks. The library is actively maintained with frequent patch releases, currently at version 0.4.6.

pip install evaluate
INSTALL
IMPORT
SIG · EVALUATE
E
evaluate
ai-mlpythonv0.4.6
Install
16.1s avg
Import
3831ms
Disk
385MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 4.012s · 397.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 16.1s · import 3.649s · 361MB
385MB installed
● package 385MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

evaluate
import evaluate
import evaluate
load
from evaluate import load
import evaluate; metric = evaluate.load("accuracy")

This quickstart demonstrates how to load a metric (e.g., 'accuracy') using `evaluate.load()` and then compute its results with sample predictions and references. While 'accuracy' doesn't require authentication, the commented section illustrates how an `HF_TOKEN` environment variable would be used with the `token` parameter for metrics or evaluators requiring access to private resources on the Hugging Face Hub. Remember that many metrics require specific input formats (e.g., text for BERTScore) and may need additional `pip install` commands for their dependencies.

import evaluate # Load an evaluation metric accuracy_metric = evaluate.load("accuracy") # Prepare dummy predictions and references predictions = [0, 1, 0, 1, 0] references = [0, 1, 1, 0, 0] # Compute the metric results = accuracy_metric.compute(predictions=predictions, references=references) print(f"Accuracy results: {results}") # Load a metric from the Hub that requires a token (e.g., for private models/datasets) # TOKEN = os.environ.get('HF_TOKEN', '') # if TOKEN: # # Example for a metric that might need a token, like an 'evaluator' # # Note: 'accuracy' itself doesn't require a token for basic use. # # Let's simulate loading an evaluator that might need one. # # For actual evaluators or private resources, `token=TOKEN` would be passed. # # For this example, we'll just demonstrate the token parameter concept. # # evaluator = evaluate.load("text_classification", model_or_pipeline="username/my-private-model", token=TOKEN) # # print("Evaluator loaded with token (concept shown).") # pass # Placeholder, as 'accuracy' doesn't use token for compute # Example with specific configuration (e.g., for BERTScore) # bertscore_metric = evaluate.load("bertscore") # predictions_text = ["The cat sat on the mat.", "The dog ate the bone."] # references_text = [["A cat was on the mat."], ["A dog consumed the bone."]] # bertscore_results = bertscore_metric.compute(predictions=predictions_text, references=references_text, lang="en") # print(f"BERTScore results (first example): {bertscore_results['f1'][0]}")
Debug
Known issues
breakingThe `use_auth_token` parameter has been deprecated across the Hugging Face ecosystem, including `evaluate`. It has been replaced by `token` for authentication.
fix
Update your code to use `token='your_huggingface_token'` instead of `use_auth_token=True` or `use_auth_token='your_token'` when loading metrics or interacting with the Hub.
affects: <0.4.3
breakingAs of v0.4.6, `evaluate` removed support for the deprecated `HfFolder` class from `huggingface_hub`. This change adds support for `huggingface_hub>=1.0`.
fix
Ensure `huggingface_hub` is updated to version `1.0.0` or higher to maintain compatibility and access the latest authentication mechanisms. Older `huggingface_hub` versions might cause issues with token loading.
affects: <0.4.6
gotchaMany evaluation metrics and evaluators within the `evaluate` library have external dependencies that are not installed by default. These include `nltk`, `scikit-learn`, `transformers`, `datasets`, `jiwer`, etc.
fix
When `evaluate.load()` reports a `ModuleNotFoundError`, check the metric's documentation on the Hugging Face Hub to identify and install the required extra packages (e.g., `pip install transformers` for 'perplexity' or `pip install evaluate[full]` for a broad set of common dependencies).
affects: All versions
gotchaThe `evaluate` library uses caching mechanisms for loaded metrics and sometimes for computation results. While beneficial for performance, this can lead to unexpected behavior if you modify metric parameters or source data without properly clearing or understanding the cache.
fix
If you encounter unexpected results, try restarting your environment or manually managing the cache (`evaluate.config.set_caching_path()`, `evaluate.config.HF_EVALUATE_OFFLINE`, `evaluate.config.set_verbosity()`). Refer to the official documentation for advanced cache management options if needed.
affects: All versions
Upgrade
Version history
0.4.6latest on PyPI · released Sep 18, 2025
Audit
Dependencies
huggingface_hubrequiredRequired for authentication, loading metrics from the Hugging Face Hub, and interacting with Hub features.
datasetsoptionalRequired for loading evaluation datasets and often used in conjunction with evaluate for data handling.
transformersoptionalRequired for certain metrics like 'perplexity' or 'bertscore' which depend on transformer models.
nltkoptionalRequired for certain NLP-focused metrics like 'sacrebleu' or 'rouge'.
Agent activity
38 hits · last 30 days
node
36
OpenAI (training)
1
Resources