Safeguarding large language models: a survey

Yi Dong, Ronghui Mu, Yanghao Zhang, Siqi Sun, Tianle Zhang, Changshun Wu, Gaojie Jin, Yi Qi, Jinwei Hu, Jie Meng, Saddek Bensalem, Xiaowei Huang

Introduction

As Large Language Models (LLMs) transition from research environments to production-ready applications, the implementation of "guardrails"—external safety layers designed to monitor and filter model inputs and outputs—has emerged as an industry standard. While internal alignment techniques like Reinforcement Learning from Human Feedback (RLHF) provide a foundation for safety, they often fall short against sophisticated adversarial attacks, social biases, and privacy concerns. This survey by Dong et al. provides a comprehensive mapping of the current safeguarding landscape, exploring technical methodologies, vulnerabilities, and the evolving socio-technical requirements of AI safety.

The Need for Post-Hoc Safeguards

The primary challenge addressed in this survey is the inherent limitation of training-time alignment. Models remain susceptible to hallucinations and malicious exploitation even after extensive fine-tuning. Furthermore, the prevalence of closed-source models prevents end-users from making "white-box" internal modifications. Consequently, robust post-hoc safeguards—algorithms that act as real-time intermediaries between users and LLMs—are essential for identifying and mitigating risks during deployment.

Taxonomy of Safeguarding Methods

The authors categorize current safeguarding frameworks into several distinct technical approaches:

  • Classifier-based Guardrails: Systems like Llama Guard utilize fine-tuned LLMs to serve as safety judges. These models classify both user prompts and model responses into predefined risk categories (e.g., violence, hate speech).
  • Similarity-based Retrieval: Frameworks such as Nvidia NeMo employ K-Nearest Neighbors (KNN) to compare incoming prompts against a database of "canonical forms" representing safe or unsafe interactions, ensuring the model adheres to prescribed conversational "rails."
  • Constraint-based Programming: Tools like LMQL and Guidance AI allow for the embedding of hard constraints directly into the token decoding process. By utilizing logit masking, these systems can physically prevent the generation of forbidden tokens or ensure outputs follow specific structural formats.
  • Neuro-Symbolic Integration: A significant trend identified is the move toward "Type-2" neuro-symbolic systems. These combine a symbolic backbone (logic-based rules) with neural learning (classifiers) to provide a robust defense against both high-volume standard data and rare corner cases.
The Llama Guard framework for classifying safety in LLM inputs and outputs.

Evaluation and Benchmarking

The survey references a diverse array of benchmarks used to measure the efficacy of these systems across multiple dimensions:

  • Safety & Toxicity: Evaluated using RealToxicityPrompts, AdvBench, and Do-Not-Answer.
  • Fairness: Measured via the PANDA and FairBERTa datasets.
  • Robustness: Tested against jailbreaking frameworks like DecodingTrust and EasyJailbreak, the latter of which unifies 12 different attack types.
  • Multimodal Safety: Audited using SafeWatch-Bench for video-based interactions.

Key Insights: The Safety-Intelligence Trade-off

A critical observation in the survey is the fragility of current safety alignment. The authors note that fine-tuning a model with as few as 10-15 malicious examples can effectively strip away the safeguards of advanced models like GPT-4. This highlights a "Gray-Box" vulnerability where even limited access can lead to significant safety degradation.

Overview of guardrail development and deployment against various jailbreak vulnerabilities.

Furthermore, there is an inherent tension between safety and model utility. Strict guardrails can lead to a "conservative shift," where models become less creative, provide overly brief responses, or exhibit high false-positive rates by refusing benign queries. The evolution of attacks has also shifted from manual prompt engineering to automated red-teaming (e.g., PAIR), which can be orders of magnitude more efficient than manual methods.

Comparative Framework Analysis

The survey provides a high-level comparison of leading guardrail frameworks:

  • Guardrails AI and TruLens are recognized for their broad coverage, including out-of-distribution (OOD) detection and uncertainty quantification.
  • Llama Guard is noted for its high efficiency in text-level safety checks, though it currently lacks multimodal capabilities.
  • Quantitative Performance: While external guardrails significantly reduce the success rate of jailbreak attempts, the survey emphasizes that they often do so only marginally, indicating that AI safety remains an open research problem.

Future Directions

The authors identify several frontiers for future research:

  1. Standardized Benchmarking: There is a pressing need for a unified, standardized benchmark for LLM safety similar to ImageNet in Computer Vision.
  2. Multimodal Expansion: Current guardrails are predominantly text-centric and are ill-equipped to handle the exponential growth of the attack surface in vision and audio-capable models (MLLMs).
  3. Agentic Safeguards: As LLMs evolve into autonomous agents, the focus must shift from filtering "bad words" to preventing "bad actions" through behavioral safeguards.
  4. Formal Verification: The field must move toward a rigorous Systems Development Life Cycle (SDLC) for AI, incorporating formal verification and statistical guarantees rather than relying solely on intuitive engineering.

Summary updated

BibTeX
@article{dong2025safeguarding,
  author = {Yi Dong and Ronghui Mu and Yanghao Zhang and Siqi Sun and Tianle Zhang and Changshun Wu and Gaojie Jin and Yi Qi and Jinwei Hu and Jie Meng and Saddek Bensalem and Xiaowei Huang},
  title = {{Safeguarding large language models: a survey}},
  journal = {Artif. Intell. Rev.},
  year = {2025},
  doi = {10.1007/s10462-025-11389-2},
}
Figure