You can score your text by downloading and using ML models from HuggingFace. This lets you apply any criteria from the source model, e.g. classify texts by emotion. There are:
Ready-to-use descriptors that wrap a specific model,
A general interface to call other suitable models you select.
Pre-requisites:
You know how to use descriptors to evaluate text data.
from evidently.descriptors import HuggingFace, HuggingFaceToxicity
To generate toy data and create a Dataset object:
Copy
import pandas as pdfrom evidently import Datasetfrom evidently import DataDefinitiondata = [ ["Why is the sky blue?", "The sky is blue because molecules in the air scatter blue light from the sun more than they scatter red light.", "because air scatters blue light more"], ["How do airplanes stay in the air?", "Airplanes stay in the air because their wings create lift by forcing air to move faster over the top of the wing than underneath, which creates lower pressure on top.", "because wings create lift"], ["Why do we have seasons?", "We have seasons because the Earth is tilted on its axis, which causes different parts of the Earth to receive more or less sunlight throughout the year.", "because Earth is tilted"], ["How do magnets work?", "Magnets work because they have a magnetic field that can attract or repel certain metals, like iron, due to the alignment of their atomic particles.", "because of magnetic fields"], ["Why does the moon change shape?", "The moon changes shape, or goes through phases, because we see different portions of its illuminated half as it orbits the Earth.", "because it rotates"], ["What movie should I watch tonight?", "A movie is a motion picture created to entertain, educate, or inform viewers through a combination of storytelling, visuals, and sound.", "watch a movie that suits your mood"]]columns = ["question", "context", "response"]df = pd.DataFrame(data, columns=columns)eval_df = Dataset.from_pandas( pd.DataFrame(df), data_definition=DataDefinition())
Alternatively, use the general HuggingFace() descriptor to call a specific named model. The model you use must return a numerical score or a category for each text in a column.
For example, to evaluate “curiousity” expressed in a text:
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.