Harmfulness Propagation Dynamics: Layer-wise Trajectories of Adversarial Intent in Large Language Models
Organizations: Department of Computer Science, İTÜ, İstanbul, Türkiye · Faculty of Computer Engineering, İTÜ, İstanbul, Türkiye.
Abstract
We identify Harmfulness Propagation Dynamics (HPD): for harmful prompts, the projection of the last-token hidden state onto a learned harm direction rises monotonically with transformer depth, whereas benign prompts remain flat or oscillatory. This cross-layer signature reflects harmful intent as a progressively resolved semantic property: surface form appears early, while pragmatic intent consolidates later, making the trajectory shape more informative than any single-layer snapshot. Moreover, LDA-based harm directions, learned per layer, remain stable across random splits (pairwise cosine similarity ), supporting the projection sequence as a reproducible structured signal. Building on HPD, we introduce \herald{} (Harmful Encoding Recognition via Activation Layer Dynamics). This lightweight input moderator extracts a seven-dimensional feature record, slope, curvature, monotonicity, onset layer, and related statistics from the cross-layer projection sequence and classifies it with a 288-parameter MLP. \herald{} stores one -dimensional direction per layer (,KB for a 32-layer, model), requires no gradient computation during training, and adds only prefill FLOPs at inference. Across eight prompt-harmfulness benchmarks and four model families, \herald{} achieves an average F1 of on OLMo2-7B, surpassing all tested guard models on adversarial jailbreak detection ( vs.\ F1) and outperforming prior latent-based methods by - F1 points on every backbone. Per-instance trajectories provide machine-readable audit records that reveal when and how harmfulness emerges, offering an interpretability advantage over single-layer approaches.
Figures & tables
| Method | Backbone | Aegis | HarmB | OAI | SimpST | TChat | WGMix | WJB | XSTest | Avg F1 |
|---|---|---|---|---|---|---|---|---|---|---|
| Latent-based methods (lightweight; use backbone activations) | ||||||||||
| Embed. Clf. | Llama-8B | 79.3 | 93.1 | 63.7 | 96.4 | 52.8 | 77.9 | 79.4 | 89.6 | 79.0 |
| Act. Delta | Llama-8B | 81.6 | 92.4 | 65.2 | 97.1 | 57.3 | 83.5 | 90.8 | 87.9 | 82.0 |
| Herald (ours) | Llama-8B | 84.1 | 97.6 | 69.5 | 98.4 | 64.9 | 86.3 | 95.8 | 93.7 | 86.3 |
| Embed. Clf. | Mistral-7B | 77.4 | 88.5 | 72.6 | 96.8 | 61.0 | 80.6 | 84.7 | 91.8 | 81.7 |
| Act. Delta | Mistral-7B | 81.9 | 94.7 | 62.3 | 96.3 | 55.4 | 82.9 | 88.4 | 91.3 | 81.6 |
| Backbone | Method | F1@100 | F1@1k | F1@10k | F1@Full |
|---|---|---|---|---|---|
| Llama-8B | Embed. Clf. | 79.3 | 81.6 | 82.9 | 83.6 |
| Act. Delta | 77.8 | 80.4 | 82.1 | 82.7 | |
| Herald | 79.6 | 84.1 | 85.9 | 86.3 | |
| Mistral-7B | Embed. Clf. | 74.7 | 79.3 | 82.0 | 83.1 |
| Act. Delta | 71.2 | 77.1 | 80.6 | 81.4 | |
| Herald | 77.3 | 83.5 | 85.8 | 86.7 |
| Feature configuration | Llama-8B | Mistral-7B | OLMo2-7B | WJB (OLMo2) |
|---|---|---|---|---|
| only | 84.7 | 84.4 | 87.8 | 96.3 |
| mean | 85.0 | 84.7 | 88.1 | 96.6 |
| total rise | 85.5 | 85.2 | 88.5 | 97.1 |
| monotonicity | 85.9 | 85.8 | 88.9 | 97.6 |
| curvature | 86.1 | 86.1 | 89.1 | 97.9 |
| onset (full) | 86.3 | 86.3 | 89.3 | 98.4 |
| Direction method | Llama-8B | Mistral-7B | OLMo2-7B |
|---|---|---|---|
| Random (control) | 77.2 | 76.9 | 79.9 |
| Class-mean diff. | 85.8 | 85.5 | 88.5 |
| PCA on harm-class residuals | 85.4 | 85.1 | 88.1 |
| LDA (used in Herald ) | 86.3 | 86.3 | 89.3 |
| Layer selection | Llama-8B | Mistral-7B | OLMo2-7B |
|---|---|---|---|
| Single best layer (oracle) | 85.5 | 85.0 | 88.5 |
| Early third ( ) | 80.4 | 79.9 | 83.2 |
| Middle third ( ) | 84.2 | 84.7 | 87.1 |
| Late third ( ) | 84.9 | 83.8 | 88.0 |
| Top-8 by validation F1 | 85.9 | 85.8 | 89.0 |
| All layers (used in Herald ) | 86.3 | 86.3 | 89.3 |
| Token position | Llama-8B | Mistral-7B | OLMo2-7B |
|---|---|---|---|
| First token | 80.6 | 79.3 | 82.4 |
| Mean over all tokens | 84.1 | 83.7 | 87.2 |
| Last token (used in Herald ) | 86.3 | 86.3 | 89.3 |
| Variant | |||||
|---|---|---|---|---|---|
| Last token (default) | 86.3 | 85.8 | 85.0 | 83.7 | 81.5 |
| Max projection over layers | 85.9 | 85.7 | 85.4 | 85.0 | 83.8 |
| Normalization | Llama-8B | Mistral-7B | OLMo2-7B |
|---|---|---|---|
| No normalization | 84.5 | 84.0 | 87.5 |
| Normalize only | 85.1 | 84.8 | 88.0 |
| Normalize and | 86.3 | 86.3 | 89.3 |
| Architecture | Params | Llama-8B | Mistral-7B | OLMo2-7B |
|---|---|---|---|---|
| Logistic regression (0 hidden) | 8 | 85.3 | 85.3 | 88.4 |
| MLP, hidden | 128 | 85.9 | 85.8 | 88.9 |
| MLP, hidden (used) | 288 | 86.3 | 86.3 | 89.3 |
| MLP, hidden | 512 | 86.3 | 86.2 | 89.3 |
| MLP, hidden | 1024 | 86.3 | 86.2 | 89.2 |
| MLP, 2 hidden layers ( ) | 1344 | 86.4 | 86.3 | 89.4 |
| Inversion strategy | Llama-8B | Mistral-7B | OLMo2-7B | F1@100 |
|---|---|---|---|---|
| No regularization (raw inverse) | 61.3 | 59.8 | 63.7 | 52.1 |
| Diagonal covariance approx. | 85.2 | 84.9 | 88.2 | 78.3 |
| Fixed ridge ( ) | 86.0 | 85.9 | 89.0 | 81.7 |
| Ledoit–Wolf (used in Herald ) | 86.3 | 86.3 | 89.3 | 79.6 |
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
| Feature | Symbol | What it captures |
|---|---|---|
| Final value | Terminal harm alignment | |
| Mean | Global bias across all layers | |
| Total rise | Net directional movement with depth | |
| Curvature | Trajectory smoothness / oscillation | |
| Monotonicity | Consistency of directional increase | |
| Onset value | Projection at first salient layer |
| Model | L4 | L8 | L16 | L24 | L32 |
|---|---|---|---|---|---|
| Llama-8B-Inst | 0.984 | 0.991 | 0.994 | 0.992 | 0.989 |
| Mistral-7B-Inst | 0.979 | 0.987 | 0.993 | 0.990 | 0.983 |
| OLMo2-7B-Inst | 0.975 | 0.988 | 0.991 | 0.993 | 0.991 |
| Qwen3-8B-Inst | 0.972 | 0.984 | 0.991 | 0.988 | 0.986 |
| Llama-8B | OLMo2-7B | |||
|---|---|---|---|---|
| Harm category | Mono. | Mono. | ||
| Jailbreak | 7.4 | 0.83 | 5.9 | 0.86 |
| Direct harmful request | 14.2 | 0.79 | 13.1 | 0.82 |
| Hate speech | 10.8 | 0.75 | 9.4 | 0.77 |
| Violence and physical harm | 9.1 | 0.81 | 8.7 | 0.83 |
| Cyberattack | 11.3 | 0.77 | 10.2 | 0.79 |
| Backbone | Alpaca | BBH | Codex | GSM8k | MMLU | MTBench | TruthQA | Avg |
|---|---|---|---|---|---|---|---|---|
| Llama-8B-Inst | 94.7 | 99.4 | 100.0 | 100.0 | 99.6 | 100.0 | 97.8 | 98.8 |
| Mistral-7B-Inst | 93.9 | 99.5 | 100.0 | 100.0 | 99.4 | 100.0 | 97.3 | 98.6 |
| OLMo2-7B-Inst | 97.1 | 99.6 | 100.0 | 100.0 | 99.7 | 98.8 | 97.1 | 98.9 |
| Qwen3-8B-Inst | 95.4 | 99.5 | 100.0 | 100.0 | 99.6 | 100.0 | 97.9 | 98.9 |
| Classifier | Llama-8B | Mistral-7B | OLMo2-7B | Qwen3-8B |
|---|---|---|---|---|
| LDA direction (used in Herald ) | 84.7 | 84.4 | 87.8 | 83.4 |
| Logistic Regression | 83.1 | 83.6 | 85.9 | 83.2 |
| MLP (1 hidden layer) | 84.2 | 82.7 | 86.4 | 83.0 |
| Linear SVM | 83.6 | 83.9 | 86.6 | 82.8 |
| Random Forest | 82.9 | 81.4 | 86.7 | 81.9 |
| Method | Llama-8B | Mistral-7B | OLMo2-7B | WJB (OLMo2) | Params |
|---|---|---|---|---|---|
| All-layers MLP ( raw input) | 85.2 | 85.0 | 88.4 | 97.1 | 288 |
| 1D-CNN over | 85.6 | 85.4 | 88.8 | 97.6 | 600 |
| GRU over | 85.7 | 85.3 | 88.9 | 97.8 | 900 |
| Herald ( , MLP) | 86.3 | 86.3 | 89.3 | 98.4 | 288 |
| Condition | Llama-8B (% refuse) | OLMo2-7B (% refuse) |
|---|---|---|
| No intervention (baseline) | 94.5 | 93.0 |
| Ablate (peak layer) | 61.0 | 58.5 |
| Ablate (early, ) | 89.0 | 90.5 |
| Ablate (late, ) | 88.0 | 86.5 |
| Train Test | Method | Llama-8B | Mistral-7B | OLMo2-7B |
|---|---|---|---|---|
| Aegis HarmBench | Embed. Clf. | 79.1 (93.1) | 77.3 (88.5) | 82.4 (93.8) |
| Act. Delta | 78.4 (92.4) | 79.0 (94.7) | 79.8 (90.7) | |
| Herald | 84.9 (97.6) | 85.2 (97.9) | 88.6 (97.4) | |
| Aegis XSTest | Embed. Clf. | 77.6 | 76.9 | 80.3 |
| Act. Delta | 76.2 | 77.4 | 80.0 | |
| Herald | 83.8 | 84.1 | 87.3 |
| Method | Backbone | WJB (full) | HD-WJB ( ) |
|---|---|---|---|
| Embed. Clf. | OLMo2-7B | 94.2 | 90.1 |
| Act. Delta | OLMo2-7B | 91.0 | 87.3 |
| Herald | OLMo2-7B | 98.4 | 95.7 |
| Guard C (ShieldGemma-2) | NE | 96.9 | 94.2 |
| Guard D (Llama-Guard-3) | NE | 96.4 | 94.8 |
| Embed. Clf. | Llama-8B | 79.4 | 75.9 |
| Threshold | Llama-8B | Mistral-7B | OLMo2-7B | WJB (OLMo2) |
|---|---|---|---|---|
| 85.5 | 85.4 | 88.6 | 97.5 | |
| 86.1 | 86.0 | 89.1 | 98.1 | |
| 86.2 | 86.2 | 89.2 | 98.2 | |
| (default) | 86.3 | 86.3 | 89.3 | 98.4 |
| 86.0 | 86.0 | 89.0 | 98.1 | |
| (max min) | 0.8 | 0.9 | 0.7 | 0.9 |
| Method | Backbone | WGMix | WJB | Aegis | HarmB | Avg F1 |
|---|---|---|---|---|---|---|
| Embed. Clf. | Qwen3-8B-Instruct | 78.2 | 79.6 | 77.8 | 88.3 | 80.5 |
| Embed. Clf. | Qwen3-8B-Thinking | 77.4 | 78.1 | 76.9 | 87.1 | 79.9 |
| Herald | Qwen3-8B-Instruct | 84.9 | 92.1 | 82.4 | 98.6 | 84.7 |
| Herald | Qwen3-8B-Thinking | 83.8 | 90.4 | 81.0 | 97.2 | 83.4 |
| (Thinking Instruct) | 1.1 | 1.7 | 1.4 | 1.4 | 1.3 |
| Method (OLMo2-7B) | Aegis | HarmB | OAI | SimpST | TChat | WGMix | WJB | Avg |
|---|---|---|---|---|---|---|---|---|
| Oracle single layer | 87.3 | 96.4 | 72.4 | 99.3 | 73.6 | 87.1 | 96.5 | 87.5 |
| Herald (all layers) | 88.7 | 97.4 | 73.1 | 99.5 | 74.6 | 87.9 | 98.4 | 89.3 |
| +1.4 | +1.0 | +0.7 | +0.2 | +1.0 | +0.8 | +1.9 | +1.8 |
| Method | Llama-8B | Mistral-7B | OLMo2-7B |
|---|---|---|---|
| Embed. clf., last layer | 79.3 | 77.4 | 85.6 |
| Embed. clf., oracle layer | 82.7 | 82.6 | 85.8 |
| Herald (all layers) | 86.3 | 86.3 | 89.3 |
| ( Herald oracle embed.) | +3.6 | +3.7 | +3.5 |
LLM Security
Large language model (LLM) security studies attacks, privacy risks, and defenses across model training, inference, and deployment.
See all 322 papers