ICML 2026 · LLM Safety · Mechanistic Interpretability

Harmfulness
Propagates
Through Layers

We discover that harmful intent in LLMs is not a static property—it rises monotonically across transformer layers. HERALD reads this trajectory to detect adversarial prompts with 262 KB of memory and zero extra forward passes.

Noor Islam S. Mohammad*1, Uluğ Bayazıt2· Istanbul Technical University
0 AVG F1 · OLMO2-7B
262KB TOTAL MEMORY OVERHEAD
8 BENCHMARKS EVALUATED
98.4 JAILBREAK F1 · WILDJAILBREAK

The Shape of Harm

A new lens for understanding how large language models process dangerous requests.

We study how harmful intent emerges across transformer layers as a structured internal signal and identify Harmfulness Propagation Dynamics (HPD): for harmful prompts, the projection of the last-token hidden state onto a learned harm direction increases with depth and becomes strongly positive in late layers, whereas benign prompts remain flat or oscillatory. Building on this, we introduce HERALD (Harmful Encoding Recognition via Activation Layer Dynamics), an input moderator that classifies the shape of the cross-layer trajectory rather than a single-layer snapshot. HERALD stores one d-dimensional direction per layer, requiring only 262 KB for a 32-layer model, and needs no gradient computation during training. Across eight prompt-harmfulness benchmarks and four backbone families, HERALD attains an average F1 of 89.3 on OLMo2-7B, outperforms all tested guard models on adversarial jailbreak detection, and surpasses prior latent-based methods while providing a visualisable, structured per-instance harmfulness trajectory.

Harmful Intent Rises With Depth

Projecting each layer's last-token hidden state onto a learned harm direction reveals a systematic difference. Harmful prompts produce a rising, monotonic trajectory. Benign prompts stay flat.

Harmful Prompt Jailbreak · WildJailbreak
Benign Prompt General QA · MMLU
Simulated trajectory on Llama-3.1-8B-Instruct · 32 transformer layers · cosine projection onto LDA harm direction

Four Steps. No Gradients. 262 KB.

HERALD operates entirely within the forward pass of the host model. No additional model weights are loaded. No backpropagation required.

STEP 01
⟨ v ⟩
Per-Layer LDA Directions

For each of the L transformer layers, compute a harm direction via Linear Discriminant Analysis on the last-token hidden states. Ledoit–Wolf shrinkage ensures stability even at 100 training samples.

STEP 02
⟨ p_l ⟩
Cosine Projection

At inference, project each layer's unit-normalised last-token hidden state onto its learned harm direction to produce scalar pl. The sequence {pl} is the harm trajectory.

STEP 03
⟨ φ ⟩
7-Dim Feature Record

Extract slope, curvature, monotonicity, onset layer, onset value, mean, and final value from the trajectory. A compact tabular representation capturing the geometry of how harmfulness emerges.

STEP 04
⟨ g ⟩
288-Parameter MLP

A two-layer MLP with hidden dimension 32 classifies the feature record. Trains on CPU in seconds. Logistic regression nearly matches it—the hard work is in the trajectory geometry.

TRAJECTORY FEATURE VECTOR φ(p) ∈ ℝ⁷

pL
final value
mean
Δp
total rise
κ
curvature
m
monotonicity
pl*
onset value
l*
onset layer ★

★ Onset layer provides the largest single gain, especially on adversarial jailbreak detection (+1.3 F1).

State-of-the-Art Across Eight Benchmarks

HERALD outperforms all latent-based baselines on every backbone and surpasses all guard models on adversarial jailbreak detection (WJB), while using 53,000× less memory than a 7B guard model.

Method Backbone Aegis HarmB OAI SimpST TChat WGMix WJB ⚡ XSTest Avg F1
Latent-based methods
Embed. Clf.Llama-8B 79.393.163.796.452.877.979.489.679.0
Act. DeltaLlama-8B 81.692.465.297.157.383.590.887.982.0
HERALDLlama-8B 84.197.669.598.464.986.395.893.786.3
Embed. Clf.Mistral-7B77.488.572.696.861.080.684.791.881.7
Act. DeltaMistral-7B81.994.762.396.355.482.988.491.381.6
HERALDMistral-7B 85.797.968.498.963.686.794.394.986.3
Embed. Clf.OLMo2-7B85.693.865.498.663.185.794.291.584.7
Act. DeltaOLMo2-7B81.490.772.997.470.883.691.092.285.0
HERALDOLMo2-7B 88.797.473.199.574.687.998.495.889.3
Guard models (standalone classifiers; no backbone required)
Guard A70.297.677.498.352.974.866.186.978.0
Guard B75.867.375.989.766.457.158.380.671.4
Guard C86.278.476.198.571.882.996.984.184.4
Guard D88.498.181.598.378.986.896.493.987.8

⚡ WJB = WildJailbreak · HERALD surpasses all guard models on this benchmark

OLMo2-7B Performance vs. Best Baseline

HERALD (cyan) vs. best competing method per benchmark (gray). The gap is largest on adversarial jailbreak prompts.

Order-of-Magnitude Smaller

HERALD stores only L direction vectors. No scatter matrices. No extra model weights. Deployable alongside the host model on a single GPU.

14 GB GUARD MODEL (7B PARAMS) Requires a dedicated inference process. ≈53,000× larger than HERALD.
1.07 GB FULL COVARIANCE APPROACH O(Ld²) storage. Infeasible at d=4096 without approximation. ≈4,100× larger.
262 KB HERALD — O(Ld) STORAGE 32 × 4096 × 2 bytes (fp16). One direction vector per layer. Scatter matrices discarded after training.
INFERENCE OVERHEAD
2.6 × 10⁻⁶
of prefill FLOPs for a 100-token prompt on a 32-layer model
DIRECTION STABILITY
> 0.97
pairwise cosine similarity of LDA directions across 5 independent splits at every layer

Harm Categories Have Distinct Signatures

The onset layer reveals when the model resolves harmful intent. Jailbreaks are resolved early and consistently. Social stereotypes emerge late and diffusely. This structure is invisible to any single-layer approach.

HARM CATEGORY
ONSET LAYER (L=32)
ONSET L*
MONO.
● = onset marker position on the 32-layer axis  |  Mono = fraction of consecutive layers with rising projection  |  Data: Llama-3.1-8B-Instruct

BibTeX

If you find HERALD or HPD useful in your research, please cite:

@inproceedings{mohammad2026harmfulness,
  title = {Harmfulness Propagation Dynamics: Layer-wise Trajectories of Adversarial Intent in Large Language Models},
  author = {Noor Islam S. Mohammad and Ulug Bayazit},
  booktitle = {Mechanistic Interpretability Workshop at ICML 2026},
  year = {2026},
  url = {https://openreview.net/forum?id=SGnAkwZ3VV}
}