pub struct SecurityAnalysisConfig {Show 20 fields
pub ml_enabled: bool,
pub ml_model: String,
pub ml_threshold: f64,
pub ml_cache_dir: String,
pub ml_preload: bool,
pub ml_download_timeout_seconds: u64,
pub ner_enabled: bool,
pub ner_model: String,
pub fusion_enabled: bool,
pub fusion_model_path: Option<String>,
pub jailbreak_enabled: bool,
pub jailbreak_threshold: f32,
pub injecguard_enabled: bool,
pub injecguard_model: String,
pub injecguard_threshold: f64,
pub piguard_enabled: bool,
pub piguard_model: String,
pub piguard_threshold: f64,
pub operating_point: OperatingPoint,
pub over_defence: bool,
}Expand description
Security analysis configuration for ML-based prompt injection detection.
Controls whether ML-based detection is enabled alongside regex-based analysis, which HuggingFace model to use, the confidence threshold, and the local model cache directory.
§Memory requirements
Each DeBERTa model requires ~400-600 MB of RAM. When ml_enabled,
injecguard_enabled, and piguard_enabled are all true, expect
~1.2-1.8 GB total for three model instances. Plan host memory accordingly.
§Example (YAML)
security_analysis:
ml_enabled: true
ml_model: "protectai/deberta-v3-base-prompt-injection-v2"
ml_threshold: 0.8
ml_cache_dir: "~/.cache/llmtrace/models"
ml_preload: true
ml_download_timeout_seconds: 300
ner_enabled: true
ner_model: "dslim/bert-base-NER"
jailbreak_enabled: true
jailbreak_threshold: 0.7Fields§
§ml_enabled: boolEnable ML-based security analysis (requires ml feature in llmtrace-security).
Enabled by default – the Ensemble analyzer (regex + ML fusion) is the recommended path.
ml_model: StringHuggingFace model ID for ML-based prompt injection detection.
ml_threshold: f64Confidence threshold for ML detection (0.0–1.0).
ml_cache_dir: StringLocal cache directory for downloaded ML models.
ml_preload: boolPre-load ML models at proxy startup rather than on first request.
ml_download_timeout_seconds: u64Timeout in seconds for downloading ML models at startup.
ner_enabled: boolEnable ML-based NER for PII detection (person names, orgs, locations).
ner_model: StringHuggingFace model ID for NER-based PII detection.
fusion_enabled: boolEnable feature-level fusion classifier (ADR-013).
When true, the ensemble concatenates DeBERTa embeddings with heuristic
feature vectors and feeds them through a learned fusion classifier instead
of combining scores after independent classification.
fusion_model_path: Option<String>Optional file path for trained fusion classifier weights.
When None, the fusion classifier is initialised with random weights
(suitable for architecture validation; not for production inference).
jailbreak_enabled: boolEnable dedicated jailbreak detection (runs alongside prompt injection).
When true (the default when security analysis is enabled), a separate
jailbreak detector with heuristic patterns and encoding evasion checks
is run on every request.
jailbreak_threshold: f32Confidence threshold for jailbreak detection (0.0–1.0).
injecguard_enabled: boolEnable InjecGuard as a third injection detector in the Ensemble.
When true, the ensemble uses majority voting (regex + ML + InjecGuard)
to suppress false positives from individual detectors.
Adds ~400-600 MB memory for the InjecGuard DeBERTa-v3 model.
injecguard_model: StringHuggingFace model ID for the InjecGuard model.
injecguard_threshold: f64Confidence threshold for InjecGuard detection (0.0-1.0).
piguard_enabled: boolEnable PIGuard as an additional injection detector in the Ensemble.
PIGuard uses DeBERTa + MOF (Mitigating Over-defense for Free) training to reduce trigger-word false positives. Adds ~400-600 MB memory.
piguard_model: StringHuggingFace model ID for the PIGuard model.
piguard_threshold: f64Confidence threshold for PIGuard detection (0.0-1.0).
operating_point: OperatingPointOperating point for ensemble thresholds.
over_defence: boolEnable over-defence suppression to reduce false positives on benign content.
Trait Implementations§
Source§impl Clone for SecurityAnalysisConfig
impl Clone for SecurityAnalysisConfig
Source§fn clone(&self) -> SecurityAnalysisConfig
fn clone(&self) -> SecurityAnalysisConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more