The Geometry of Harmful Intent: Training-Free Anomaly Detection via Angular Deviation in LLM Residual Streams
Organizations: Independent Researcher
Abstract
We present LatentBiopsy, a training-free method for detecting harmful prompts by analysing the geometry of residual-stream activations in large language models. Given 200 safe normative prompts, LatentBiopsy computes the leading principal component of their activations at a target layer and characterises new prompts by their radial deviation angle from this reference direction. The anomaly score is the negative log-likelihood of under a Gaussian fit to the normative distribution, flagging deviations symmetrically regardless of orientation. No harmful examples are required for training. We evaluate two complete model triplets from the Qwen3.5-0.8B and Qwen2.5-0.5B families: base, instruction-tuned, and abliterated (refusal direction surgically removed via orthogonalisation). Across all six variants, LatentBiopsy achieves AUROC 0.937 for harmful-vs-normative detection and AUROC = 1.000 for discriminating harmful from benign-aggressive prompts (XSTest), with sub-millisecond per-query overhead. Three empirical findings emerge. First, geometry survives refusal ablation: both abliterated variants achieve AUROC at most 0.015 below their instruction-tuned counterparts, establishing a geometric dissociation between harmful-intent representation and the downstream generative refusal mechanism. Second, harmful prompts exhibit a near-degenerate angular distribution ( rad), an order of magnitude tighter than the normative distribution ( rad), preserved across all alignment stages including abliteration. Third, the two families exhibit opposite ring orientations at the same depth: harmful prompts occupy the outer ring in Qwen3.5-0.8B but the inner ring in Qwen2.5-0.5B, directly motivating the direction-agnostic scoring rule.
Figures & tables
| Model | Type | Layer | AUROC | AUPRC | h/r | Prec@90 | |||
| h/n | h/b | h/n | h/b | ||||||
| Qwen3.5-0.8B ( ) | |||||||||
| Base | Base | 20 | 0.9642 | 1.000 | 0.9373 | 1.000 | 0.9758 | 0.928 | |
| Chat | Instruct | 20 | 0.9497 | 1.000 | 0.9117 | 1.000 | 0.9661 | 0.899 | |
| Abliterated | Abliterated | 20 | 0.9517 | 1.000 | 0.9165 | 1.000 | 0.9674 | 0.899 | |
| Qwen2.5-0.5B ( ) | |||||||||
| Model | Type | ||||||
| Qwen3.5-0.8B | |||||||
| Base | Base | 1.161 | 0.272 | 1.811 | 1.094 | 0.034 | |
| Chat | Instruct | 1.178 | 0.267 | 1.801 | 1.104 | 0.030 | |
| Abliterated | Abliterated | 1.175 | 0.267 | 1.802 | 1.104 | 0.031 | |
| Qwen2.5-0.5B | |||||||
| Base | Base | 1.819 | 0.188 | 1.357 | 1.821 | 0.034 | |
| Model | Type | AUROC | ||
|---|---|---|---|---|
| Qwen3.5-0.8B-Base | Base | 0.9642 | ||
| Qwen3.5-0.8B-Chat | Instruct | 0.9497 | ||
| Qwen3.5-0.8B-Abliterated | Abliterated | 0.9517 | ||
| Qwen2.5-0.5B-Base | Base | 0.9585 | ||
| Qwen2.5-0.5B-Instruct | Instruct | 0.9420 | ||
| Qwen2.5-0.5B-Abliterated † | Abliterated | 0.9374 |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
Anomaly Detection
Anomaly detection finds rare or unexpected patterns in data, from defective products and system faults to fraud and security threats.
See all 652 papers