const correctness = createClassificationEvaluator({
name: "correctness",
model: openai("gpt-6-luna"),
promptTemplate: "Is this answer correct?\n{{input}}\n{{output}}",
choices: { correct: 1, incorrect: 0 },
});
const quality = createClassificationEvaluator({
name: "response-quality",
model: openai("gpt-6-luna"),
promptTemplate: "Assess the response.\n{{input}}\n{{output}}",
choices: [
{
name: "helpfulness",
instruction: "Does the response resolve the request?",
labels: { helpful: null, not_helpful: null },
scoreMap: { helpful: 1, not_helpful: 0 },
},
{
name: "toxicity",
instruction: "Is the response toxic?",
labels: { toxic: "insulting or hateful", non_toxic: null },
scoreMap: { toxic: 1, non_toxic: 0 },
optimizationDirection: "MINIMIZE",
},
],
});
Create a classification evaluator.
With choices as a label-to-score map, the evaluator classifies each
example into one label and evaluate returns one result.
With choices as a list of criteria, the evaluator answers every criterion
in one backend request and evaluate returns one result per criterion.
const correctness = createClassificationEvaluator({
name: "correctness",
model: openai("gpt-6-luna"),
promptTemplate: "Is this answer correct?\n{{input}}\n{{output}}",
choices: { correct: 1, incorrect: 0 },
});
const quality = createClassificationEvaluator({
name: "response-quality",
model: openai("gpt-6-luna"),
promptTemplate: "Assess the response.\n{{input}}\n{{output}}",
choices: [
{
name: "helpfulness",
instruction: "Does the response resolve the request?",
labels: { helpful: null, not_helpful: null },
scoreMap: { helpful: 1, not_helpful: 0 },
},
{
name: "toxicity",
instruction: "Is the response toxic?",
labels: { toxic: "insulting or hateful", non_toxic: null },
scoreMap: { toxic: 1, non_toxic: 0 },
optimizationDirection: "MINIMIZE",
},
],
});
Create a classification evaluator.
With
choicesas a label-to-score map, the evaluator classifies each example into one label andevaluatereturns one result.With
choicesas a list of criteria, the evaluator answers every criterion in one backend request andevaluatereturns one result per criterion.