SafetyModuleBase<T>

Base Classes ยท AiDotNet.Safety

Abstract base class for all safety modules, providing common infrastructure.

Inheritance: ModelBase<T, Vector<T>, Vector<T>> โ†’ SafetyModuleBase<T>

Implements: ISafetyModule<T>

Known derived types: AudioSafetyModuleBase<T>, ImageSafetyModuleBase<T>, MultimodalSafetyModuleBase<T>, TextSafetyModuleBase<T>, VideoSafetyModuleBase<T>, VoiceProtectorBase<T>

For Beginners

This is the common ancestor of all safety modules. It handles boilerplate like module naming and readiness checks so each module can focus on its specific detection logic.

How It Works

Provides shared functionality for all safety modules including the module name, readiness state, and default numeric operations. Concrete safety modules should typically inherit from a more specific base class (TextSafetyModuleBase, ImageSafetyModuleBase, etc.) rather than this one directly.

Properties

Property Summary
ILossFunction<T> DefaultLossFunction { get; }
bool IsReady { get; }
string ModuleName { get; }

Methods

Method Summary
IFullModel<T, Vector<T>, Vector<T>> DeepCopy()
IFullModel<T, Vector<T>, Vector<T>> WithParameters(Vector<T> parameters)
IReadOnlyList<SafetyFinding> Evaluate(Vector<T> content)
Vector<T> Predict(Vector<T> input) Predicts safety scores from content by delegating to Evaluate and converting findings to a score vector.
void Train(Vector<T> input, Vector<T> expectedOutput) Training is not typically used for safety modules.