GUARD-SLM: Token Activation-Based Defense Against Jailbreak Attacks for Small Language Models
Authors: Md Jueal Mia, Joaquin Molto, Yanzhao Wu, M. Hadi Amini
Organizations: Knight Foundation School of Computing and Information Sciences Florida International University Miami, FL, USA · Security, Optimization, and Learning for InterDependent networks laboratory (solid lab) Florida International University Miami, FL, USA
Small Language Models (SLMs) are emerging as efficient and economically viable alternatives to Large Language Models (LLMs), offering competitive performance with significantly lower computational costs and latency. These advantages make SLMs suitable for resource-constrained and efficient deployment on edge devices. However, existing jailbreak defenses show limited robustness against heterogeneous attacks, largely due to an incomplete understanding of the internal representations across different layers of language models that facilitate jailbreak behaviors. In this paper, we conduct a comprehensive empirical study on 9 jailbreak attacks across 7 SLMs and 3 LLMs. Our analysis shows that SLMs remain highly vulnerable to malicious prompts that bypass safety alignment. We analyze hidden-layer activations across different layers and model architectures, revealing that different input types form distinguishable patterns in the internal representation space. Based on this observation, we propose GUARD-SLM, a lightweight token activation-based method that operates in the representation space to filter malicious prompts during inference while preserving benign ones. Our findings highlight robustness limitations across layers of language models and provide a practical direction for secure small language model deployment.
Figures & tables
Figure 1: Jailbreak attack on aligned vs non-aligned SLMs.
Figure 2: Overview of proposed GUARD-SLM framework.
Table 1: Attack Success Rate (ASR) across jailbreak attacks on SLMs. Models: LLaMA-2 (meta-llama/Llama-2-7b-chat-hf), Vicuna (lmsys/vicuna-7b-v1.5), Mistral (mistralai/Mistral-7B-Instruct-v0.2), Yi (01-ai/Yi-6B-Chat), Qwen (Qwen/Qwen1.5-7B-Chat), Gemma (google/gemma-7b-it), OpenChat (openchat/openchat-3.5-0106). Dataset:AdvBench Evaluator: GPT-4o-mini
Table 2: Attack Success Rate (ASR) across jailbreak attacks on LLMs. Models: LLaMA-2-13B, Vicuna-13B, Qwen-1.5-14B. Dataset: AdvBench. Evaluator: GPT-4o-mini
Figure 3: t-SNE visualization of LLaMA-7B activations showing early, middle, and late layer representations.
Figure 4: Attack detection accuracy in the representation space using GUARD-SLM across early layers (0–10), Dataset: HarmBench, model: meta- llama/Llama-2-7b-chat-hf
Table 3: ASR(%) comparison of different defense methods against different jailbreak attacks, model: meta-llama/Llama-2-7b-chat-hf, dataset: HarmBench, judge model: gpt-4o
Defense
Additional Tokens (In/Out)
Avg. Inf. Time
SelfEval
+51
8.24s
SelfReminder
+44
1.12s
RobustAlign
(n−1)q
12.45s
SmoothLLM
(n−1)q
38.07s
ICD
+805
1.13s
Aligner
+42
4.90s
Table 4: Efficiency comparison of different defense methods. n denotes the number of queries for single forward pass and q denotes the number of tokens per query.
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
GPU Model
No. of GPUs
GPU Memory
NVIDIA H100
Multiple Nodes
80 GB HBM3
NVIDIA RTX A6000
2
48 GB
NVIDIA A100 PCIe
4
80 GB
NVIDIA A100 PCIe
8
40 GB
Appendix
Table 5: Hardware configuration used in the experiments
Category
Count
Benign
52,000
Direct Malicious
32,490
AutoDAN
1,370
Cipher
2,080
CodeChameleon
520
DeepInception
520
Appendix
Table 6: Data distribution of benign, malicious, and optimized jailbreak samples used for activation analysis.
Phase
Hyperparameter
Value
Activation extraction
Maximum input tokens
512
Hidden representation used
Last-token activation from all transformer layers
Layer grouping
Early: first 40% layers, Middle: 40%–70%, Late: remaining layers
Figure 5: t-SNE visualization of last-token activations across all layers (Layer 0 to Layer 31) of LLaMA-7B.
Figure 6: t-SNE visualization across layers 0–31 of Vicuna-7B
Figure 7: t-SNE visualization across layers 0–31 of Mistral-7B
Figure 8: Attack detection accuracy in the representation space using GUARD-SLM across early layers (0–10), Dataset: HarmBench , model: meta- llama/Llama-2-7b-chat-hf
Figure 9: Attack detection accuracy in the representation space using GUARD-SLM across middle layers (11–21), Dataset: HarmBench, model: meta- llama/Llama-2-7b-chat-hf
Figure 10: Attack detection accuracy in the representation space using GUARD-SLM across late layers (22–31), Dataset: HarmBench, model: meta- llama/Llama-2-7b-chat-hf
Acc(%) on HarmBench
Acc(%) on AutoDAN
Layers
LLaMA-7B
Vicuna-7B
Mistral-7B
LLaMA-7B
Vicuna-7B
Mistral-7B
0
53.00%
50.00%
52.52%
100.0%
100.0%
100.0%
1
52.50%
53.50%
58.50%
100.0%
100.0%
100.0%
2
62.00%
62.50%
68.50%
100.0%
100.0%
100.0%
3
66.50%
69.50%
71.50%
100.0%
100.0%
100.0%
4
75.50%
76.00%
77.50%
100.0%
100.0%
100.0%
Appendix
Table 9: Layer-wise jailbreak detection accuracy using GUARD-SLM across LLaMA-7B, Vicuna-7B, and Mistral-7B models.
Acc(%) on PAIR
Acc(%) on TAP
Layers
LLaMA-7B
Vicuna-7B
Mistral-7B
LLaMA-7B
Vicuna-7B
Mistral-7B
0
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
1
100.0%
99.50%
100.0%
100.0%
100.0%
100.0%
2
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
3
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
4
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
Appendix
Table 10: Layer-wise jailbreak detection accuracy using GUARD-SLM across LLaMA-7B, Vicuna-7B, and Mistral-7B models.
Acc(%) on GCG
Acc(%) on Cipher
Layers
LLaMA-7B
Vicuna-7B
Mistral-7B
LLaMA-7B
Vicuna-7B
Mistral-7B
0
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
1
100.0%
100.0%
99.50%
100.0%
100.0%
100.0%
2
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
3
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
4
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
Appendix
Table 11: Layer-wise jailbreak detection accuracy using GUARD-SLM across LLaMA-7B, Vicuna-7B, and Mistral-7B models.
Acc(%) on DeepInception
Acc(%) on CodeChameleon
Layers
LLaMA-7B
Vicuna-7B
Mistral-7B
LLaMA-7B
Vicuna-7B
Mistral-7B
0
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
1
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
2
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
3
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
4
100.0%
100.0%
100.0%
100.0%
100.0%
100.0%
Appendix
Table 12: Layer-wise jailbreak detection accuracy using GUARD-SLM on DeepInception and CodeChameleon attacks across LLaMA-7B, Vicuna-7B, and Mistral-7B models.
Acc(%) on ICA
Acc(%) on Jailbroken
Layers
LLaMA-7B
Vicuna-7B
Mistral-7B
LLaMA-7B
Vicuna-7B
Mistral-7B
0
100.0%
100.0%
100.0%
86.36%
87.64%
86.50%
1
100.0%
100.0%
100.0%
88.57%
85.33%
88.02%
2
100.0%
100.0%
100.0%
86.97%
86.03%
80.60%
3
100.0%
100.0%
100.0%
84.78%
85.50%
86.66%
4
100.0%
100.0%
100.0%
86.14%
87.03%
93.21%
Appendix
Table 13: Layer-wise jailbreak detection accuracy using GUARD-SLM on ICA and Jailbroken attacks across LLaMA-7B, Vicuna-7B, and Mistral-7B models.
Large Language Model (LLM) alignment remains vulnerable to jailbreak attacks that elicit unsafe responses, motivating pre-model and post-model guards. Pre-model guards audit the safety of prompts before invoking target models. However, relying solely on the prompt often leads to high false-negative rates (i.e., jailbreak attacks go undetected). Post-model guards address this issue by auditing both the user prompt and the target model's response. However, they incur a high computational cost, including increased token usage and processing time, because they operate after target model inference. In this paper, we introduce a safeguard design that leverages the transferability of jailbreak attacks to enforce prompt safety before target model inference. We first conduct a systematic study of jailbreak transferability, particularly from LLMs to small language models (SLMs). Through these experiments, we identify key factors influencing transferability. Building on these insights, we observe that responses from smaller draft models reflect the safety implications of those from large target models; \ie given a jailbreak prompt constructed for an LLM, an SLM is likely to be triggered to generate an unaligned response. Based on this observation, our safeguard design leverages speculative inference with SLMs to generate a set of draft responses. It then feeds the original prompt and these drafts into existing guards to predict their safety. We demonstrate that this design reduces the false-negative rate of pre-model guards and offers a low \Efficiency alternative to post-model guards. \textcolor{red}{\bf Notice: This paper contains examples of harmful language.}
Hongyu Cai, Arjun Arunasalam, Yiming Liang +2
Purdue University West Lafayette, Indiana, USA · Florida International University Miami, Florida, USA
This paper proposes a guaranteed defense method for large language models (LLMs) to safeguard against jailbreaking attacks. Drawing inspiration from the denoised-smoothing approach in the adversarial defense domain, we propose a novel smoothing-based defense method, termed Disrupt-and-Rectify Smoothing (DR-Smoothing). Specifically, we integrate a two-stage prompt processing scheme-first disrupting the input prompt, then rectifying it-into the conventional smoothing defense framework. This disrupt-and-rectify approach improves upon previous disrupt-only approaches by restoring out-of-distribution disrupted prompts to an in-distribution form, thereby reducing the risk of unpredictable LLM behavior. In addition, this two-stage scheme offers a distinct advantage in striking a balance between harmlessness and helpfulness in jailbreaking defense. Notably, we present a theoretical analysis for generic smoothing framework, offering a tight bound for the defense success probability and the requirements on the disruption strength. Our approach can defend against both token-level and prompt-level jailbreaking attacks, under both established and adaptive attacking scenarios. Extensive experiments demonstrate that our approach surpasses current state-of-the-art defense methods in terms of both harmlessness and helpfulness.
Currently, open-sourced large language models (OSLLMs) have demonstrated remarkable generative performance. However, as their structure and weights are made public, they are exposed to jailbreak attacks even after alignment. Existing attacks operate primarily at shallow levels, such as the prompt or embedding level, and often fail to expose vulnerabilities rooted in deeper model components, which creates a false sense of security for successful defense. In this paper, we propose Safety Attention Head Attack (SAHA), an attention-head-level jailbreak framework that explores the vulnerability in deeper but insufficiently aligned attention heads. SAHA contains two novel designs. Firstly, we reveal that deeper attention layers introduce more vulnerability against jailbreak attacks. Based on this finding, SAHA introduces Ablation-Impact Ranking head selection strategy to effectively locate the most vital layer for unsafe output. Secondly, we introduce a boundary-aware perturbation method, i.e. Layer-Wise Perturbation, to probe the generation of unsafe content with minimal perturbation to the attention. This constrained perturbation guarantees higher semantic relevance with the target intent while ensuring evasion. Extensive experiments show the superiority of our method: SAHA improves ASR by 14% over SOTA baselines, revealing the vulnerability of the attack surface on the attention head. Our code is available at https://anonymous.4open.science/r/SAHA.
Jinman Wu, Yi Xie, Shiqian Zhao +1
Xidian University, Xi’an, China · Tsinghua University, Shenzhen, China · Nanyang Technological University, Singapore