Clarification Classifier
The ClarificationClassifier in deepeval is a categorical LLM-as-a-judge that determines whether your LLM application asked a clarifying question on an ambiguous input, answered because the input was clear, or guessed.
Underspecified prompts, where the right move is to ask a question before acting, make the best test cases here. They show whether the assistant pauses or simply barrels ahead.
Labels
asked_clarification: the input is ambiguous or underspecified and the response asks a clarifying question before proceeding.answered_directly: the input is clear enough and the response answers or acts on it without needing clarification.guessed: the input is ambiguous or underspecified but the response proceeds on an assumption instead of asking.
Usage
from deepeval.classifiers import ClarificationClassifier
from deepeval.test_case import LLMTestCase
from deepeval import evaluate
classifier = ClarificationClassifier()
test_case = LLMTestCase(
input="Book me a flight to Portland next week.",
actual_output="Portland, Oregon or Portland, Maine? And which day next week works best?",
expected_labels={classifier.name: "asked_clarification"},
)
evaluate(test_cases=[test_case], classifiers=[classifier])There are FIVE optional parameters when creating a ClarificationClassifier:
- [Optional]
model: a string specifying which of OpenAI's GPT models to use, OR any custom LLM model of typeDeepEvalBaseLLM. Defaulted togpt-5.4. - [Optional]
include_reason: a boolean which when set toTrue, includes a reason for the chosen label. Defaulted toTrue. - [Optional]
allow_none: a boolean which when set toTrue, lets the classifier return no label when none of them fit (surfaced aslabel=None, with a reason). WhenFalse, the closest label is always chosen. Defaulted toFalse. - [Optional]
async_mode: a boolean which when set toTrue, enables concurrent execution within theclassify()method. Defaulted toTrue. - [Optional]
classification_template: a subclass ofClassifierTemplateused to override the default prompts. Defaulted toClassifierTemplate.
As a standalone
You can also run the ClarificationClassifier on a single test case as a standalone, one-off execution. classify() returns the label and stores the result on the instance:
...
label = classifier.classify(test_case)
print(classifier.label, classifier.reason)How Is It Calculated?
The ClarificationClassifier is a one-shot LLM-as-a-judge: a single call to your evaluation model with the test case content and the labels above, returning the chosen label and a reason. The result is compared against the test case's expected_labels entry, if any, to decide pass or fail.