Swift Hydra: Self-Reinforcing Generative Framework for Anomaly Detection with Multiple Mamba Models

Nguyen Hoang Khoi Do, Truc Nguyen, Malik Hassanaly, raed alharbi, Jung Taek Seo, My T. Thai

Anomaly detection is often described as a "cat-and-mouse" game. In real-world applications, anomalies are rare, and their patterns constantly evolve to evade detection. Traditional supervised models tend to overfit to the few known examples they have seen, failing to generalize to novel threats. Conversely, unsupervised models, such as those based on Variational Autoencoders (VAEs), often suffer from "memorization"—they become so adept at reconstructing data that they reconstruct anomalies just as well as normal data, making the two indistinguishable.

Furthermore, as data complexity grows, detectors require more parameters, leading to a computational tax that slows down inference. To address this triple challenge of data scarcity, poor generalization, and the trade-off between model complexity and speed, researchers have introduced Swift Hydra. This self-reinforcing framework uses Reinforcement Learning (RL) to "red-team" its own anomaly detection system, achieving state-of-the-art accuracy while maintaining high-speed inference.

The Swift Hydra Architecture

Swift Hydra operates through a continuous feedback loop between two primary modules: a generative "red team" and an inference "blue team."

Overview of the Swift Hydra framework, detailing the Self-Reinforcing Generative Module and the Inference Module.

1. Self-Reinforcing Generative Module

This module is responsible for synthesizing increasingly sophisticated synthetic anomalies to challenge the detector.

  • The Generator: A Conditional VAE (C-VAE) is used to synthesize new anomalous samples.
  • The RL Agent: Instead of relying on random generation, an RL policy (trained via Proximal Policy Optimization, or PPO) operates directly on the C-VAE's latent variables. Its primary goal is to discover "blind spots" in the current detection model.
  • The Reward Function: The agent is rewarded for creating samples that are both diverse (exhibiting high entropy) and capable of "deceiving" the detector (resulting in low detection confidence).
  • Cold-Start Mitigation: To solve the initial exploration problem common in RL, the framework utilizes a deterministic gradient descent search in the latent space, helping the agent find effective adversarial actions early in training.

2. Inference Module (The "Hydra")

The detection side of the framework is built for both accuracy and speed, utilizing a Mixture of Mamba Experts (MoE) architecture.

  • Mamba Backbone: The framework uses Mamba models, which are renowned for their linear-time complexity, making them highly suitable for high-throughput environments where traditional Transformers might bottleneck.
  • Scalable Specialization: Different "experts" within the MoE specialize in different regions of the feature space. Because only the top-$k$ experts are activated for any given input, the model scales its capacity to handle complex data without a linear increase in inference time.
  • Balanced Utilization: To prevent a single expert from dominating the training process (a common "winner-take-all" issue in MoE), a probabilistic cluster assignment strategy ensures all experts are utilized effectively.

Experimental Setup and Key Results

The authors evaluated Swift Hydra on ADBench, a comprehensive benchmark comprising 57 datasets spanning diverse domains, including image analysis (e.g., MNIST, CIFAR10), healthcare (e.g., Thyroid, Breast Cancer), and cybersecurity (e.g., Backdoor, SMTP).

Superior Accuracy and Efficiency

Swift Hydra's adversarial augmentation—using RL to strategically explore the latent space and hunt for samples that bypass the detector—forces the model to learn highly robust decision boundaries.

Performance comparison of Swift Hydra against baseline methods across different train/test split ratios.

As shown in the results, the Swift Hydra (MoME) configuration consistently outperformed state-of-the-art baselines like DTE, Rejex, and ADGym. Even in highly constrained scenarios with only 10% training data, it achieved an average AUC-ROC of 0.87, significantly higher than its competitors.

Crucially, the Mixture of Experts approach proved vital for inference efficiency. While a single, large Mamba detector was relatively slow (18.52s Time in Framework, or TIF), the MoE version reduced this to 5.84s—a roughly 3x speedup—while simultaneously improving detection accuracy. This mathematically overcomes the theoretical limitations of a single detector struggling with overlapping data distributions.

Better Distribution Coverage

Visualizations of the latent space (via T-SNE) demonstrated that Swift Hydra generates anomalies that cluster near the decision boundary and extend well beyond the original training set. This is a significant improvement over traditional oversampling methods like SMOTE, which typically only interpolate between existing, known data points.

Limitations and Future Directions

While highly effective, Swift Hydra does come with training complexity. The pipeline involves coordinating a C-VAE, an RL agent, and an MoE gating network, requiring careful hyperparameter tuning (such as balancing the KL-divergence weight). Additionally, as a semi-supervised/supervised framework, it requires at least a small initial set of anomalies to condition the C-VAE.

Looking forward, the authors suggest this self-reinforcing generative paradigm could be extended far beyond anomaly detection. It holds significant promise for any field where data is expensive or scarce, such as synthesizing rare medical conditions for diagnostic training or generating edge-case scenarios for autonomous driving systems.

Summary updated

BibTeX
@inproceedings{do2025swift,
  author = {Nguyen Hoang Khoi Do and Truc Nguyen and Malik Hassanaly and raed alharbi and Jung Taek Seo and My T. Thai},
  title = {{Swift Hydra: Self-Reinforcing Generative Framework for Anomaly Detection with Multiple Mamba Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=P7t2niLbvw},
}
Figure