HPD and HERALD: detecting jailbreak prompts using cross-layer harmful propagation trajectoriesHarmfulness Propagation Dynamics: Layer-wise Trajectories of Adversarial Intent in Large Language Models
Translation in progress — untranslated text is omitted.
The paper proposes Harmfulness Propagation Dynamics (HPD): for harmful prompts, the projection of the last token hidden state onto a learned harm direction increases monotonically with Transformer depth, while benign prompts remain flat or oscillate, indicating that trajectory shape is more informative than single-layer snapshots. Based on this, the authors propose HERALD, which extracts seven-dimensional features such as slope, curvature, monotonicity, and starting layer from cross-layer projection sequences, and classifies with a 288-parameter MLP; each layer stores a d-dimensional direction (about 262 KB for a 32-layer, d=4096 model), training requires no gradient computation, and inference adds only 2.6×10⁻⁶ of prefill FLOPs.
- Aligned models remain vulnerable to adversarial and indirect prompting; input review is a supplementary defense before generation. Guard models are accurate but require running a large model separately; existing latent methods are lightweight but only look at single-layer hidden states, missing cross-layer trajectories.
- HERALD applies gradient-free LDA to the last-token hidden state at each layer, obtains a harmful direction, and computes a sequence of cosine projections. It then extracts seven trajectory features (terminal value, mean, total increase, curvature, monotonicity, starting layer and its projection) and classifies them with a 288-parameter MLP.
- Across four instruction-tuned models and eight harmfulness benchmarks, trained on WildGuardMix and evaluated zero-shot on the rest. OLMo2-7B achieves an average F1 of 89.3; on WildJailbreak it reaches 98.4, above the highest guard's 96.9. On ToxicChat and OpenAI Moderation it trails the strongest guard.
- The authors note that WildGuardMix is English-centric and may miss culture-specific, multilingual, or diffuse harm; spurious correlations in training may inflate false positives. Adaptive white-box adversaries remain an open problem. Experiments cover four 7B–8B backbone models, eight benchmarks, and three types of random seeds.
Related papers
- Safeguards Based on Copyable Context Cannot Provide Reliable Safety for LLMsAnalysis / interpretabilityarXiv