Safety evaluation refers to the ability to evaluate and validate text output from LLM models based on various safety criteria. This includes checking for sensitive topics, profanity, personally identifiable information, and other safety concerns.

Evaluation TypeDescriptionRequired Keys
SafeForWorkTextCheck if text is safe for workresponse
NotGibberishTextCheck if text is not gibberishresponse
ContentModerationUse OpenAI’s content moderationtext
PiiDetectionCheck for personally identifiable informationtext
PromptInjectionCheck for prompt injection attemptstext
ToxicityCheck for toxic/harmful languageinput
DataPrivacyComplianceCheck compliance with privacy regulationsinput
CulturalSensitivityCheck for cultural appropriateness and inclusive languageinput
BiasDetectionCheck for various forms of biasinput

These evaluations do not require any additional configuration.

Example

from fi.evals import PiiDetection, EvalClient
from fi.testcases import TestCase

evaluator = EvalClient(fi_api_key="your_api_key", fi_secret_key="your_secret_key")

# Create a test case to check for personally identifiable information
pii_test_case = TestCase(
    text="My email is john.doe@email.com and my phone number is 123-456-7890"
)
pii_template = PiiDetection()

result = evaluator.evaluate(pii_template, pii_test_case)
print(result)  # Will return Fail due to presence of PII (email and phone number)