Text evals with HuggingFace
How to use models available on HuggingFace as text Descriptors.
Last updated
How to use models available on HuggingFace as text Descriptors.
Last updated
Pre-requisites:
You know how to generate Reports or Test Suites for text data using Descriptors.
You know how to pass custom parameters for Reports or Test Suites.
You know to specify text data in column mapping.
You can use an external machine learning model to score text data. This method lets you evaluate texts based on any criteria from the source model, e.g. classify it into a set number of labels.
The model you use must return a numerical score or a category for each text in a column. You will then be able to view scores, analyze their distribution or run conditional tests through the usual Descriptor interface.
Evidently supports using HuggingFace models: use the general HuggingFaceModel()
descriptor to select models on your own or simplified interfaces like HuggingFaceToxicityModel()
.
You can refer to an end-to-end example with different Descriptors:
To import the Descriptor:
To get a Report with a Toxicity score for the response
column:
To get a Report with with several different scores using the general HuggingFaceModel()
descriptor:
You can do the same for Test Suites.
Which descriptors are there? See the list of available built-in descriptors in the All Metrics page.
Here are some example models you can call using the HuggingFaceModel()
descriptor.
Model | Parameters |
---|---|
Emotion classification
Example use:
| Required:
Available labels:
Optional:
|
Toxicity detection
Example use:
| Optional:
|
Zero-shot classification
Example use:
| Required:
Optional:
|
GPT-2 text detection
Example use:
| Optional:
|
This list is not exhaustive, and the Descriptor may support other models published on Hugging Face. The implemented interface generally works for models that:
Output a single number (e.g., predicted score for a label) or a label, not an array of values.
Can process raw text input directly.
Name labels using label
or labels
fields.
Use methods named predict
or predict_proba
for scoring.
However, since each model is implemented differently, we cannot provide a complete list of models with a compatible interface. We suggest testing the implementation on your own using trial and error. If you discover useful models, feel free to share them with the community in Discord. You can also open an issue on GitHub to request support for a specific model.