SURE: data-efficient safety guardrailing via internal representations and uncertainty-weighted pseudo-labels
Large language models (LLMs) can produce harmful content when prompted with unsafe inputs, yet inference-time safety interventions often degrade general-purpose performance through over-refusal. We propose SURE (Semi-supervised Uncertainty-weighted Representation-based External detection), a framework that trains a lightweight classifier on the LLM’s hidden state representations to detect harmful inputs entirely outside the inference pipeline, preserving the model’s original capabilities. To overcome annotation scarcity, SURE queries the target LLM to assess unlabeled inputs and weights each pseudo-label by the classifier’s confidence, the LLM’s uncertainty, measured as the perplexity of its single-token safety self-assessment, and their agreement. Experiments across three open-source LLMs (8B–70B parameters) show that SURE achieves average harmonic mean scores of 88–90% with only 80 labeled samples, surpassing both inference-time and representation-based baselines. Performance plateaus at 40 labeled examples, and cross-category generalization confirms over 90% accuracy on held-out categories, indicating that the learned representations capture general safety features.
Authors
- Sandeep Madireddy (ORCID: https://orcid.org/0000-0002-0437-8655)
- Hanwen Li (ORCID: https://orcid.org/0000-0001-9160-2821)
- Bhavya Kailkhura (ORCID: https://orcid.org/0000-0002-2819-2919)
- Chenxi Yuan (ORCID: https://orcid.org/0000-0002-4927-709X)
- James Diffenderfer
- Kaidi Xu
- Jinhao Duan
Institutions
- University of North Carolina at Chapel Hill (US)
- New Jersey Institute of Technology (US)
- Argonne National Laboratory (US)
- Lawrence Livermore National Laboratory (US)
- City University of Hong Kong (HK)
Publication Details
- Journal
- npj Artificial Intelligence
- Published
- 2026-07-25
- DOI
- https://doi.org/10.1038/s44387-026-00141-y
- Primary Topic
- Adversarial Robustness in Machine Learning
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- U.S. Department of Energy
- Office of Science
- Laboratory Directed Research and Development
- Lawrence Livermore National Laboratory