Efficient and Adaptable Detection of Malicious LLM Prompts via Bootstrap Aggregation
Listen
Radio episode about this paper
Transcript
Introduction to the show: ident: AI Radio. Generated commentary on the latest Artificial Intelligence papers.
Tom: We're looking at the paper: "Efficient and Adaptable Detection of Malicious LLM Prompts via Bootstrap Aggregation".
Jane: Here's the gist of the paper. The gist: BAGEL, a modular, lightweight, and incrementally updatable framework for malicious prompt detection, achieves an F1 score of 0.92 by employing a bootstrap aggregation and mixture of experts inspired ensemble of fine-tuned models that outperforms larger baselines while maintaining computational efficiency Large Language Models (LLMs) are susceptible to malicious prompts that induce unsafe or policy-violating behavior through harmful requests, jailbreak techniques, and prompt injection attacks.
Tom: Existing defenses face fundamental limitations where black-box moderation APIs offer limited transparency and adapt poorly to evolving threats, while whitebox approaches using large LLM judges impose prohibitive computational costs and require expensive retraining for new attacks Current systems force designers to choose between performance, efficiency, and adaptability.
Jane: BAGEL Framework BAGEL is a modular, lightweight, and incrementally updatable framework for malicious prompt detection that employs a bootstrap aggregation and mixture of experts inspired ensemble of fine-tuned models.
Tom: At inference, it uses a random forest router to identify the most suitable ensemble member, then applies stochastic selection to sample additional members for prediction aggregation.
Title and authors: Tom: Let's look at the title itself: "Efficient and Adaptable Detection of Malicious LLM Prompts via Bootstrap Aggregation." It sounds like a very structured approach to solving this detection problem.
Jane: It suggests that instead of one giant system, we should be thinking about modularity and incremental updates as the way forward for prompt detection.
Lu: The authors are Shayan Ali Hassan, Tao Ni, Zafar Ayyub Qazi from LUMS and KAUST, plus Marco Canini from KAUST. They are researchers in AI and machine learning who have deep expertise in model representation learning.
Meng: So we're listening to people who understand the math behind how these ensemble methods work versus just throwing a massive parameter count at it.
Lalam: The paper is proposing BAGEL, which stands for Bootstrap Aggregated Ensemble Layer, as this modular and incrementally updatable framework for prompt detection.
The paper's summary: Tom: Basically, the summary says they use a bootstrap aggregation technique but they train those ensemble models on entirely different datasets instead of just splitting one big dataset.
Jane: And they modify the mixture of experts technique by routing an incoming prompt to a subset of more than one ensemble member by first predicting an ideal member and then using a random selection process for the final prediction.
Lu: The key finding they highlight is that training each model on different datasets provides robustness to the system across all types of prompt attacks, which is something they found when comparing it to just training them on subsets of the same data.
Meng: That sounds like a clever way to ensure that if an attack type slips through one set, another specialized member in the ensemble can catch it because they learned about different stuff.
Lalam: They also talk about how this setup allows for updating the system as new attack datasets become available without having to retrain the entire system from scratch.
The paper's improvements: Tom: The authors point out several improvements in their approach, focusing on computational efficiency and interpretability over just raw detection accuracy.
Jane: They suggest that the main improvement is moving away from monolithic guardrails toward something modular and incrementally updatable, which they argue is the practical way to handle this issue.
Lu: They emphasize that by using a small base prompt-safety classifier, like the 86M parameter Prompt Guard two mentioned in their setup, each member stays relatively lightweight during inference.
Meng: That's good for deployment because it keeps the computational cost low per request, which is what matters when you're handling massive traffic spikes.
Lalam: They also mention using a random forest router trained on structural features derived from prompt samples to predict the ideal member, which gives us some insight into why the system is making a certain decision.
Conclusion: Tom: So to wrap up, this paper about "Efficient and Adaptable Detection of Malicious LLM Prompts via Bootstrap Aggregation" shows how you can build a robust detection system using smaller, specialized models instead of one massive model.
Jane: The implication is that we can get high performance, like an F1 score of zero point nine two two when they use their specific subset size of 430M parameters, while maintaining computational efficiency for real-world deployment.
Lu: The robustness is also interesting because the final F1 scores never drop below zero point nine two even after nine incremental updates by adding new datasets to the ensemble <ref:2602.08062#pg1>.
Meng: That incremental update feature is huge for us because it means we don't have to redo a massive retraining cycle every time a new threat emerges, just fine-tune and add one more piece.
Lalam: It shows that modular architectures with intelligent routing can deliver protection while remaining practical for deployment in production LLM systems.
Tom: That’s the core idea of BAGEL, which is this bootstrap aggregation and mixture of experts inspired ensemble layer for prompt detection.
Jane: It really sets a blueprint for building these kinds of security systems that prioritize modularity and efficiency over just chasing the biggest number possible.
Shayan Ali Hassan, Tao Ni, Zafar Ayyub Qazi, Marco Canini
KAUST · LUMS
cs.LG, cs.CR
Submitted: 2026-02-08
Updated: 2026-10-20
Code: https://github.com/sands-lab/bagel
License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/
Importance score: 90/100
The gist: The gist: BAGEL, a modular, lightweight, and incrementally updatable framework for malicious prompt detection, achieves an F1 score of 0.92 by employing a bootstrap aggregation and mixture of experts
Key concepts
- Bootstrap Aggregation (Bagging)
- This technique involves training multiple models on different subsets of the same data and then averaging their predictions. BAGEL uses this by creating specialized prompt detectors from various datasets, enhancing the overall robustness and accuracy of the final detection system.
- Mixture of Experts (MoE) Inspired Ensemble
- Instead of using one large model, BAGEL combines several smaller, specialized models. A random forest router decides which specific expert model is best suited for a new prompt, and then samples a few others to make the final decision, improving detection capability.
- Incremental Updates
- This allows the system to learn from new threats without retraining everything. When new attack data arrives, BAGEL fine-tunes a small classifier on that data and adds it to the existing ensemble, enabling continuous improvement efficiently.
Terminology
Summary
The gist: BAGEL, a modular, lightweight, and incrementally updatable framework for malicious prompt detection, achieves an F1 score of 0.92 by employing a bootstrap aggregation and mixture of experts inspired ensemble of fine-tuned models that outperforms larger baselines while maintaining computational efficiency
Motivation and Problem
Large Language Models (LLMs) are susceptible to malicious prompts that induce unsafe or policy-violating behavior through harmful requests, jailbreak techniques, and prompt injection attacks. Existing defenses face fundamental limitations where black-box moderation APIs offer limited transparency and adapt poorly to evolving threats, while whitebox approaches using large LLM judges impose prohibitive computational costs and require expensive retraining for new attacks Current systems force designers to choose between performance, efficiency, and adaptability.
BAGEL Framework
BAGEL is a modular, lightweight, and incrementally updatable framework for malicious prompt detection that employs a bootstrap aggregation and mixture of experts inspired ensemble of fine-tuned models. At inference, it uses a random forest router to identify the most suitable ensemble member, then applies stochastic selection to sample additional members for prediction aggregation. When new attacks emerge, BAGEL updates incrementally by fine-tuning a small prompt-safety classifier (86M parameters) and adding the resulting model to the ensemble.
Key Advantages of BAGEL
BAGEL offers three key advantages over prior approaches.
-
Computational Efficiency: Each member is a finetune of an 86M-parameter base promptsafety classifier, which keeps inference lightweight (for example, setting the selection size to 5 yields an effective footprint of 430M parameters).
-
Incremental Updates: When new attack datasets become available, LLM providers can finetune the same base model and add the resulting classifier to the ensemble, avoiding expensive end-to-end retraining of the full system while preserving performance on previously observed attacks.
-
Interpretability: The random forest router relies on transparent structural features allowing clear insight into which structural patterns of prompt attacks are most indicative of malicious intent.
Methodology
The framework modifies the classic bootstrap aggregating technique by training the ensemble models on entirely different datasets rather than subsets of the same dataset. It modifies the classic mixture of experts technique by routing the incoming prompt to a subset of more than one ensemble member by predicting an ideal member combined with a stochastic selection.
The process involves several steps:
-
Base Model: BAGEL utilizes a small base prompt-safety classifier as the backbone for each promptcop, such as Prompt Guard 2 (86M parameters).
-
Creation of Specialized PromptCops: Each dataset Di is partitioned into three disjoint subsets: Finetuning Set (70%), Calibration Set (10%), and Test Set (20%).
-
Dynamic Routing via Random Forest: A Random Forest classifier, R, is trained on structural features derived from prompt samples to serve as a router, predicting the index of the ideal promptcop i∗.
-
Selection and Aggregation: A subset Sx of size n is constructed as Sx = Mi∗ ∪ Mrand1, …, Mrandn-1, where Mrand are models drawn uniformly at random from P excluding Mi∗. The final maliciousness score yˆ(x) is computed via simple averaging: yˆ(x) = 1/n ∑Mj∈Sx pj(x).
-
Threshold Calibration: The optimal threshold τ∗ is updated by evaluating the F1 score across the cumulative calibration data to maximize it using a heuristic two-stage search strategy.
Results and Evaluation
BAGEL was evaluated on a diverse collection of nine largescale, real-world datasets covering multiple categories of malicious prompts. The results show that BAGEL outperforms popular black-box moderation APIs and competitive white-box baselines, achieving 0.095 Attack Success Rate (ASR) and 0.066 False Positive Rate (FPR), resulting in an F1 score of 0.922 when utilizing the previously mentioned 430M parameters subset which is 45% smaller than the entire ensemble. Performance remains robust after nine incremental updates, since the final F1 scores never drop below 0.92 even after introducing new datasets nine times. The performance curves show that increasing the selection size n further from n = 5 to n = 9 yields only marginal gains, confirming that it is unnecessary to select and request inference from every promptcop in the ensemble. BAGEL achieves comparable or superior results while being significantly more lightweight and transparent compared to methods like Perspective API and ToxicDetector.
Conclusion
BAGEL establishes a blueprint for sustainable LLM security systems that prioritize modularity, efficiency, and adaptability. It demonstrates that small, specialized models can match or exceed the performance of billion-parameter alternatives while significantly reducing computational overhead and enabling efficient incremental updates through simple fine-tuning and ensemble addition. This work shows that modular architectures with intelligent routing can deliver robust protection while remaining practical for real-world deployment.
--- Page 1 ---
The gist: BAGEL, a modular, lightweight, and incrementally updatable framework for malicious prompt detection, achieves an F1 score of 0.92 by employing a bootstrap aggregation and mixture of experts inspired ensemble of fine-tuned models that outperforms larger baselines while maintaining computational efficiency
Motivation and Problem
Large Language Models (LLMs) are susceptible to malicious prompts that induce unsafe or policy-violating behavior through harmful requests, jailbreak techniques, and prompt injection attacks. Existing defenses face fundamental limitations where black-box moderation APIs offer limited transparency and adapt poorly to evolving threats, while whitebox approaches using large LLM judges impose prohibitive computational costs and require expensive retraining for new attacks. Current systems force designers to choose between performance, efficiency, and adaptability.
Results and Evaluation
BAGEL was evaluated on a diverse collection of nine largescale, real-world datasets covering multiple categories of malicious prompts. The results show that BAGEL outperforms popular black-box moderation APIs and competitive white-box baselines, achieving 0.
Improvements for AI systems
-
Adaptive Ensemble Detection: Implement BAGEL to detect malicious prompts using an ensemble of smaller fine-tuned models, achieving high performance (F1 score of 0.92) while using significantly fewer parameters (430M effective) than billion-parameter baselines.
-
Incremental Defense Evolution: Allow the system to update incrementally by fine-tuning a small classifier on new attack data and adding it to the ensemble,
avoiding expensive end-to-end retraining of the full system while preserving performance on previously observed attacks.
-
Interpretable Routing: Utilize a random forest router trained on structural features derived from prompt samples to identify the most suitable promptcop, providing
clear insight into which structural patterns of prompt attacks are most indicative of malicious intent.
-
Computational Efficiency and Sustainability: Reduce computational overhead by employing a subset selection strategy where
setting the selection size to 5 yields an effective footprint of 430M parameters,
making it feasible for low-latency deployments. -
Robustness Against Evolving Threats: Maintain robust performance across incremental updates, as the framework demonstrates that
the final F1 scores never drop below 0.92 even after introducing new datasets nine times.
Sources
- gpt-oss-120b & gpt-oss-20b Model Card
- Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attacks
- Carbontracker: Tracking and Predicting the Carbon Footprint of Training Deep Learning Models
- An Analysis of Deep Neural Network Models for Practical Applications
- LLM Jailbreak Detection for (Almost) Free!
- Baseline Defenses for Adversarial Attacks Against Aligned Language Models
- PromptLocate: Localizing Prompt Injection Attacks
- Weight Poisoning Attacks on Pre-trained Models
- AutoDAN: Generating Stealthy Jailbreak Prompts on Aligned Large Language Models
- Safety Instincts: LLMs Learn to Trust Their Internal Compass for Self-Defense
- The Computational Limits of Deep Learning
- Defending against Indirect Prompt Injection by Instruction Detection
- Jailbreak Attacks and Defenses Against Large Language Models: A Survey
- GPTFUZZER: Red Teaming Large Language Models with Auto-Generated Jailbreak Prompts
- ShieldGemma: Generative AI Content Moderation Based on Gemma
- Universal and Transferable Adversarial Attacks on Aligned Language Models
Related papers
- Polynomial-Augmented Neural Networks (PANNs) with Weak Orthogonality Constraints for Enhanced Function and PDE Approximation
- AIRL-S: Unifying Reinforcement Learning and Search-Based Test-Time Scaling via Adversarial Inverse Reinforcement Learning
- Transformers as Bayesian In-Context Experimenters: Smoothness-Adaptive Efficient ATE Estimation
- Convergence issues in Relational Concept Analysis based on AOC-posets
- Beliefs Beyond Posteriors: The Predictive Cost of ELBO Binding
- Understanding Diffusion Models via Ratio-Based Function Approximation with SignReLU Networks