Package dev.braintrust.eval
Interface Classifier<INPUT,OUTPUT>
- Type Parameters:
INPUT- type of the input dataOUTPUT- type of the output data
- All Known Subinterfaces:
TracedClassifier<INPUT,OUTPUT>
public interface Classifier<INPUT,OUTPUT>
A classifier categorizes and labels eval outputs, producing zero or more structured
Classification items.
Classifiers run independently from Scorers. Each Classifier exposes a name (used as
the span name and as the default grouping key for classifications whose own name is
blank).
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionclassify(TaskResult<INPUT, OUTPUT> taskResult) Classifies the result of a successful task execution.getName()static <INPUT,OUTPUT>
Classifier<INPUT,OUTPUT> of(String classifierName, Function<TaskResult<INPUT, OUTPUT>, List<Classification>> classifierFn) Creates a classifier from a function that returns a (possibly empty or null) list of classifications.static <INPUT,OUTPUT>
Classifier<INPUT,OUTPUT> single(String classifierName, Function<TaskResult<INPUT, OUTPUT>, Classification> classifierFn) Creates a classifier from a function that returns a single classification.
-
Field Details
-
INVALID_CLASSIFICATION_MESSAGE
- See Also:
-
-
Method Details
-
getName
String getName() -
classify
Classifies the result of a successful task execution.- Parameters:
taskResult- the task output and originating dataset case- Returns:
- zero or more classifications. An empty list means "no classifications for this case".
-
of
static <INPUT,OUTPUT> Classifier<INPUT,OUTPUT> of(String classifierName, Function<TaskResult<INPUT, OUTPUT>, List<Classification>> classifierFn) Creates a classifier from a function that returns a (possibly empty or null) list of classifications.A
nullreturn value is treated as no classifications. Each returnedClassificationmust have a non-blankid; otherwise the classifier throws an exception (which the eval runner records but does not abort on). -
single
static <INPUT,OUTPUT> Classifier<INPUT,OUTPUT> single(String classifierName, Function<TaskResult<INPUT, OUTPUT>, Classification> classifierFn) Creates a classifier from a function that returns a single classification.A
nullreturn value is treated as no classifications.
-