AdversarialRobustnessOptions<T>

Options & Configuration ยท AiDotNet.Models.Options

Unified configuration options for adversarial robustness and AI safety.

Inheritance: ModelOptions โ†’ AdversarialRobustnessOptions<T>

For Beginners

This is your one-stop shop for all AI safety and robustness settings. You can configure how strictly inputs are validated, how the model is protected against attacks, and what guarantees you want about model predictions.

How It Works

This comprehensive options class consolidates all adversarial robustness settings including:

  • Safety filtering (input validation, output filtering, harmful content detection)
  • Adversarial attacks (for robustness testing and evaluation)
  • Adversarial defenses (training and preprocessing)
  • Certified robustness (provable guarantees)
  • Content moderation (for LLM applications)

Where each group takes effect when passed to AiModelBuilder.ConfigureAdversarialRobustness:

copied into the SafetyFilterOptions of the SafetyFilter that validates every Predict input and filters every output. EnableSafetyFiltering false removes the filter.

TrainingAttackMethod): build runs AdversarialTraining on the trained model with these settings and BatchSize, and the result predicts through the defended model.

CertificationNormType): build creates the CertificationMethod engine with these settings, reports certified accuracy, and AiModelResult.PredictCertified certifies single predictions.

HallucinationThreshold): fills the text section of the ConfigureSafety pipeline; settings the caller passed to ConfigureSafety explicitly win.

runs RedTeamingPromptCount prompts from the safety benchmarks of the chosen categories through that pipeline and attaches the report as AiModelResult.RedTeamingReport.

Constructors

Constructor Summary
AdversarialRobustnessOptions()

Properties

Property Summary
AdversarialAttackMethod TrainingAttackMethod { get; set; } Gets or sets the attack method to use during adversarial training.
AdversarialAttackMethod[] AttackMethods { get; set; } Gets or sets which attack methods to use for testing.
AdversarialNormType AttackNormType { get; set; } Gets or sets the norm type for perturbation constraints.
AdversarialNormType CertificationNormType { get; set; } Gets or sets the norm type for certification.
AdversarialPreprocessingMethod PreprocessingMethod { get; set; } Gets or sets the preprocessing method to use.
CertifiedDefenseMethod CertificationMethod { get; set; } Gets or sets the certification method to use.
PiiType[] PIITypes { get; set; } Gets or sets the types of PII to filter.
RedTeamingCategory[] RedTeamingCategories { get; set; } Gets or sets the red teaming categories to test.
bool BlockPromptInjections { get; set; } Gets or sets whether to detect and block prompt injection attacks.
bool EnableAdversarialTraining { get; set; } Gets or sets whether to enable adversarial training.
bool EnableCertifiedRobustness { get; set; } Gets or sets whether to enable certified robustness.
bool EnableContentModeration { get; set; } Gets or sets whether to enable content moderation for LLM outputs.
bool EnableFactualityChecking { get; set; } Gets or sets whether to enable factuality checking.
bool EnableInputValidation { get; set; } Gets or sets whether to enable input validation.
bool EnableOutputFiltering { get; set; } Gets or sets whether to enable output filtering.
bool EnableRedTeaming { get; set; } Gets or sets whether to enable red teaming during evaluation.
bool EnableRobustnessTesting { get; set; } Gets or sets whether to enable adversarial robustness testing.
bool EnableSafetyFiltering { get; set; } Gets or sets whether safety filtering is enabled.
bool FilterPII { get; set; } Gets or sets whether to filter PII (personally identifiable information).
bool LogFilteredContent { get; set; } Gets or sets whether to log filtered content for review.
bool UseContentClassifier { get; set; } Gets or sets whether to use a classifier for harmful content detection.
bool UseEnsembleDefense { get; set; } Gets or sets whether to use ensemble defenses.
bool UseInputPreprocessing { get; set; } Gets or sets whether to use input preprocessing for defense.
bool UseRandomStartForAttacks { get; set; } Gets or sets whether to use random initialization for attacks.
bool UseTargetedAttacks { get; set; } Gets or sets whether to use targeted attacks.
bool UseTightCertificationBounds { get; set; } Gets or sets whether to use tight bounds computation.
bool VerboseLogging { get; set; } Gets or sets whether to enable verbose logging.
double AdversarialTrainingRatio { get; set; } Gets or sets the ratio of adversarial examples to include in training.
double AttackEpsilon { get; set; } Gets or sets the maximum perturbation budget (epsilon) for attacks.
double AttackStepSize { get; set; } Gets or sets the step size for iterative attacks.
double CertificationConfidence { get; set; } Gets or sets the confidence level for certification.
double CertificationNoiseSigma { get; set; } Gets or sets the noise standard deviation for randomized smoothing.
double DefenseEpsilon { get; set; } Gets or sets the perturbation budget for adversarial training.
double HallucinationThreshold { get; set; } Gets or sets the hallucination detection threshold.
double JailbreakSensitivity { get; set; } Gets or sets the jailbreak detection sensitivity.
double PromptInjectionSensitivity { get; set; } Gets or sets the prompt injection detection sensitivity.
double SafetyThreshold { get; set; } Gets or sets the safety threshold for content filtering.
int AdversarialTrainingEpochs { get; set; } Gets or sets the number of adversarial training epochs run on the trained model at build.
int AttackIterations { get; set; } Gets or sets the number of iterations for iterative attacks.
int BatchSize { get; set; } Gets or sets the batch size for robustness operations.
int CertificationSamples { get; set; } Gets or sets the number of samples for randomized smoothing.
int EnsembleSize { get; set; } Gets or sets the number of models in the ensemble.
int MaxInputLength { get; set; } Gets or sets the maximum input length to process.
int RedTeamingPromptCount { get; set; } Gets or sets the number of red teaming prompts to generate.
int TargetClass { get; set; } Gets or sets the target class for targeted attacks.
string SafetyLogFilePath { get; set; } Gets or sets the file path for filtered content logging.
string[] HarmfulContentCategories { get; set; } Gets or sets the harmful content categories to check for.

Methods

Method Summary
AdversarialRobustnessOptions<T> AdversarialTrainingFocus() Creates options for adversarial training focus.
AdversarialRobustnessOptions<T> BasicSafety() Creates options for basic safety filtering only.
AdversarialRobustnessOptions<T> ComprehensiveRobustness() Creates options for comprehensive robustness with certified guarantees.
AdversarialRobustnessOptions<T> LLMSafety() Creates options for LLM safety with content moderation.