ISafetyFilter<T>
Interfaces · AiDotNet.Interfaces
Defines the contract for safety filters that detect and prevent harmful or inappropriate model inputs and outputs.
Implements: IModelSerializer
Known implementations: SafetyFilter<T>
How It Works
Safety filters act as gatekeepers that monitor model inputs and outputs to prevent harmful, inappropriate, or malicious content from passing through the system.
For Beginners: Think of safety filters as “security guards” for your AI system. They check everything going in and coming out to make sure nothing dangerous or inappropriate gets through.
Common safety filter functions include:
- Input Validation: Check that inputs are safe and properly formatted
- Output Filtering: Ensure outputs don’t contain harmful content
- Jailbreak Detection: Identify attempts to bypass safety measures
- Harmful Content Detection: Flag potentially dangerous or inappropriate content
Why safety filters matter:
- They prevent misuse of AI systems
- They protect users from harmful content
- They help maintain ethical AI deployments
- They catch edge cases and adversarial inputs
Methods
| Method | Summary |
|---|---|
HarmfulContentResult<T> IdentifyHarmfulContent(Vector<T> content) |
Identifies harmful or inappropriate content in text or data. |
JailbreakDetectionResult<T> DetectJailbreak(Vector<T> input) |
Detects jailbreak attempts that try to bypass safety measures. |
SafetyFilterOptions<T> GetOptions() |
Gets the configuration options for the safety filter. |
SafetyFilterResult<T> FilterOutput(Vector<T> output) |
Filters model outputs to remove or flag harmful content. |
SafetyValidationResult<T> ValidateInput(Vector<T> input) |
Validates that an input is safe and appropriate for processing. |
T ComputeSafetyScore(Vector<T> content) |
Computes a safety score for model inputs or outputs. |
void Reset() |
Resets the safety filter state. |