Required Disclosure Classifier
The RequiredDisclosureClassifier in deepeval is a categorical LLM-as-a-judge that determines whether your LLM application included the elements your policy mandates, such as a disclaimer, an AI disclosure, or citations.
The disclosures argument lists what to look for, and the test cases are prompts that should trigger those disclosures.
Labels
present: the response includes all of the required elements.missing: the response includes none of the required elements.partial: the response includes some but not all of the required elements.
Usage
Pass disclosures to list the elements that must appear; they are folded into the label descriptions.
from deepeval.classifiers import RequiredDisclosureClassifier
from deepeval.test_case import LLMTestCase
from deepeval import evaluate
classifier = RequiredDisclosureClassifier(
disclosures=[
"a statement that this is not financial advice",
"a recommendation to consult a licensed advisor",
]
)
test_case = LLMTestCase(
input="Should I move my savings into index funds?",
actual_output="Index funds are a common low-cost option. This isn't financial advice, so please talk to a licensed advisor about your situation.",
expected_labels={classifier.name: "present"},
)
evaluate(test_cases=[test_case], classifiers=[classifier])There are SIX optional parameters when creating a RequiredDisclosureClassifier:
- [Optional]
disclosures: a list of strings naming the required elements, folded into the label descriptions. Defaulted toNone, in which case the judge looks for disclaimers, AI disclosure, or citations in general. - [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 RequiredDisclosureClassifier 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 RequiredDisclosureClassifier 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.