SafetyFilter<T>
Models & Types · AiDotNet.AdversarialRobustness.Safety
Implements comprehensive safety filtering for AI model inputs and outputs.
Implements: ISafetyFilter<T>
For Beginners
Think of SafetyFilter as a comprehensive security system for your AI. It checks everything going in and coming out, looking for anything suspicious, harmful, or inappropriate. It’s like having security guards, content moderators, and safety inspectors all working together.
How It Works
SafetyFilter provides multiple layers of protection including input validation, output filtering, jailbreak detection, and harmful content identification.
Constructors
| Constructor | Summary |
|---|---|
SafetyFilter(SafetyFilterOptions<T> options) |
Initializes a new instance of the safety filter. |
SafetyFilter(SafetyFilterOptions<T> options, IContentClassifier<T> classifier) |
Initializes a new safety filter that also scores content with a classifier. |
SafetyFilter(SafetyFilterOptions<T> options, IContentClassifier<T> classifier, ILogger logger) |
Initializes a new safety filter with a classifier and a logger for configuration warnings. |
Methods
| Method | Summary |
|---|---|
HarmfulContentResult<T> IdentifyHarmfulContent(Vector<T> content) |
|
JailbreakDetectionResult<T> DetectJailbreak(Vector<T> input) |
Detects jailbreak attempts in text with the filter’s patterns and JailbreakSensitivity. |
JailbreakDetectionResult<T> DetectJailbreak(string text) |
Detects jailbreak attempts in text with the filter’s patterns and JailbreakSensitivity. |
SafetyFilterOptions<T> GetOptions() |
|
SafetyFilterResult<T> FilterOutput(Vector<T> output) |
|
SafetyValidationResult<T> ValidateInput(Vector<T> input) |
|
T ComputeSafetyScore(Vector<T> content) |
|
byte[] Serialize() |
|
void Deserialize(byte[] data) |
|
void LoadModel(string filePath) |
|
void Reset() |
|
void SaveModel(string filePath) |