SafeRoute: Adaptive Model Selection for Efficient and Accurate Safety Guardrails in Large Language Models

Seanie Lee, Dong Bok Lee, Dominik Wagner, Minki Kang, Haebin Seong, Tobias Bocklet, Juho Lee, Sung Ju Hwang

Abstract

Deploying large language models (LLMs) in real-world applications requires robust safety guard models to detect and block harmful user prompts. While large safety guard models achieve strong performance, their computational cost is substantial. To mitigate this, smaller distilled models are used, but they often underperform on “hard” examples where the larger model provides accurate predictions. We observe that many inputs can be reliably handled by the smaller model, while only a small fraction require the larger model’s capacity. Motivated by this, we propose SafeRoute, a binary router that distinguishes hard examples from easy ones. Our method selectively applies the larger safety guard model to the data that the router considers hard, improving efficiency while maintaining accuracy compared to solely using the larger safety guard model. Experimental results on multiple benchmark datasets demonstrate that our adaptive model selection significantly enhances the trade-off between computational cost and safety performance, outperforming relevant baselines.

Introduction

To prevent LLMs from generating toxic, harmful, or jailbroken content, developers typically deploy secondary "safety guard" models to screen user prompts and AI responses. However, large guard models (e.g., 8B+ parameters) introduce massive computational overhead and latency to the user experience. Conversely, smaller distilled models (e.g., 1B parameters) are faster but frequently fail on complex, adversarial, or "hard" prompts.

Conceptual overview of SafeRoute routing easy prompts to a smaller model and hard prompts to a larger model.

The authors identify a Pareto inefficiency: small models handle the vast majority of "easy" queries perfectly well. The core challenge lies in identifying which specific queries require the capacity of the large model without incurring the cost of running it for every input.

Methods

SafeRoute is an adaptive model selection mechanism that utilizes a lightweight binary router to predict when a small model is likely to fail.

Labeling and Architecture

The router is trained on a dataset where prompts are labeled as "hard" (1) if the small model fails while the large model succeeds, and "easy" (0) otherwise. To minimize overhead, the router is a tiny 3-layer Bayesian neural network. It "piggybacks" on the small model by taking the hidden representation of the final token from the small model's last layer as its input.

Data Augmentation and Inference

Because "hard" examples are sparse in standard datasets, the authors use Llama-3.1-8B-Instruct to generate paraphrased versions of training data, enriching the router's exposure to edge cases. During inference, the small model runs first. The router analyzes its final hidden state; if the predicted "hardness" score exceeds a threshold, the large model is triggered for the final decision. Otherwise, the small model's output is used.

Experimental Setup

The router was trained on the WildGuardMix training split and evaluated across six public benchmarks:

  • WildGuardMix & WildGuardMix-p (prompt only)
  • OpenAI Moderation (OAI)
  • ToxicChat
  • XSTest (focusing on exaggerated safety/over-refusals)
  • HarmBench (red teaming and jailbreaks)

Results and Discussion

SafeRoute demonstrates a superior trade-off between safety performance and computational efficiency.

Safety F1 Score vs. Latency across multiple benchmarks, showing SafeRoute (X) outperforming baselines.

Key Insights

  • Confidence vs. Competence: Traditional routing based on entropy (uncertainty) often fails because small models can be "confidently wrong" on clever jailbreaks. SafeRoute explicitly learns the capability gap between models.
  • Internal State Utility: Using the small model's own hidden states is more effective than external encoders like ModernBERT, which tend to overfit and fail to capture the small model's specific failure modes.
  • Efficiency Gains: When pairing Llama-Guard-3-1B with Llama-Guard-3-8B, SafeRoute achieves F1 scores comparable to the 8B model while significantly reducing latency. On HarmBench, it successfully identifies complex semantic attacks as "hard" while saving compute on simpler attacks.

Conclusion

SafeRoute provides an efficient path for deploying robust safety guardrails. While currently limited by the router's reliance on small model representations and training data quality, future work aims to incorporate large model features and synthesize higher-quality training data. This adaptive routing framework holds potential for broader LLM tasks like reasoning and coding.

Summary updated

BibTeX
@inproceedings{lee2025saferoute,
  author = {Seanie Lee and Dong Bok Lee and Dominik Wagner and Minki Kang and Haebin Seong and Tobias Bocklet and Juho Lee and Sung Ju Hwang},
  title = {{SafeRoute: Adaptive Model Selection for Efficient and Accurate Safety Guardrails in Large Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=eB8U7cMFLx},
}
Figure