LLM Safety From Within: Detecting Harmful Content with Internal Representations

Difan Jiao, Yilun Liu, Ye Yuan, Zhenwei Tang, Linfeng Du +2 more
4/20/2026
cs.AI

No confident code implementation found for this paper. 2 possible matches can be shown below.

Abstract

Guard models are widely used to detect harmful content in user prompts and LLM responses. However, state-of-the-art guard models rely solely on terminal-layer representations and overlook the rich safety-relevant features distributed across internal layers. We present SIREN, a lightweight guard model that harnesses these internal features. By identifying safety neurons via linear probing and combining them through an adaptive layer-weighted strategy, SIREN builds a harmfulness detector from LLM internals without modifying the underlying model. Our comprehensive evaluation shows that SIREN substantially outperforms state-of-the-art open-source guard models across multiple benchmarks while using 250 times fewer trainable parameters. Moreover, SIREN exhibits superior generalization to unseen benchmarks, naturally enables real-time streaming detection, and significantly improves inference efficiency compared to generative guard models. Overall, our results highlight LLM internal states as a promising foundation for practical, high-performance harmfulness detection.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 2 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{jiao2026safety,
  title  = {LLM Safety From Within: Detecting Harmful Content with Internal Representations},
  author = {Difan Jiao and Yilun Liu and Ye Yuan and Zhenwei Tang and Linfeng Du and Haolun Wu and Ashton Anderson},
  year   = {2026},
  eprint = {2604.18519},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2604.18519v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2604.18519.svg)](https://codeofpaper.com/paper/2604.18519)

Discussion