Custom Text Descriptor
How to add a custom row-level text evaluator.
To run a check not available in Evidently, you can implement it as a custom function. Use this for building your own programmatic evaluators.
You can also customize existing evals with parameters, such as defining custom LLM judges or using regex-based metrics like Contains
for word lists. See available descriptors.
Pre-requisites:
- You know how to use built-in descriptors.
Imports
Single column check
You can define a CustomColumnDescriptor
that will:
-
take any column from your dataset to evaluate each value inside it
-
return a single column with numerical (
num
) scores or categorical (cat
) labels.
Implement it as a Python function that takes a Pandas Series as input and return a transformed Series. For example, to check if the column is empty:
To use this descriptor on your data:
Publish to a dataframe:
Multi-column check
You can alternatively define a CustomDescriptor
that:
-
Takes one or many named columns from your dataset,
-
Returns one or many transformed columns.
Pairwise evaluation. For example, to check exact match between target_answer
and answer
columns, and return a label:
To use this descriptor on your data:
Multiple scores. You can also use CustomDescriptor
to run evals for multiple columns and return multiple scores.
As a fun example, let’s reverse all words in the question
and answer
columns:
To use this descriptor on your data: