Skip to main content

SecurityAnalysisConfig

Struct SecurityAnalysisConfig 

Source
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.7

Fields§

§ml_enabled: bool

Enable 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: String

HuggingFace model ID for ML-based prompt injection detection.

§ml_threshold: f64

Confidence threshold for ML detection (0.0–1.0).

§ml_cache_dir: String

Local cache directory for downloaded ML models.

§ml_preload: bool

Pre-load ML models at proxy startup rather than on first request.

§ml_download_timeout_seconds: u64

Timeout in seconds for downloading ML models at startup.

§ner_enabled: bool

Enable ML-based NER for PII detection (person names, orgs, locations).

§ner_model: String

HuggingFace model ID for NER-based PII detection.

§fusion_enabled: bool

Enable 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: bool

Enable 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: f32

Confidence threshold for jailbreak detection (0.0–1.0).

§injecguard_enabled: bool

Enable 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: String

HuggingFace model ID for the InjecGuard model.

§injecguard_threshold: f64

Confidence threshold for InjecGuard detection (0.0-1.0).

§piguard_enabled: bool

Enable 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: String

HuggingFace model ID for the PIGuard model.

§piguard_threshold: f64

Confidence threshold for PIGuard detection (0.0-1.0).

§operating_point: OperatingPoint

Operating point for ensemble thresholds.

§over_defence: bool

Enable over-defence suppression to reduce false positives on benign content.

Trait Implementations§

Source§

impl Clone for SecurityAnalysisConfig

Source§

fn clone(&self) -> SecurityAnalysisConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SecurityAnalysisConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SecurityAnalysisConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SecurityAnalysisConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SecurityAnalysisConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,