Abstract
Large Language Models (LLMs) are increasingly vulnerable to jailbreak attacks—adversarial prompts designed to bypass safety guardrails. This paper presents DETAM (Defending LLMs via Targeted Attention Modification), a training-free defense mechanism that mitigates these attacks by dynamically redistributing internal attention. By identifying "sensitive" attention heads and amplifying the focus on the user's core intent while suppressing adversarial "noise," DETAM significantly reduces attack success rates (ASR) across multiple benchmarks while preserving model utility.
1. Introduction
Despite extensive safety alignment through Reinforcement Learning from Human Feedback (RLHF), LLMs remain susceptible to jailbreak prompts. These prompts often use complex wrappers—such as roleplay scenarios or hypothetical constraints—to distract the model from its safety training.
This paper identifies a phenomenon termed "Focus Loss." Focus loss occurs when an LLM's drive for utility forces it to attend equally to all parts of a prompt, including the adversarial template. This dispersion of attention prevents the model's internal safety mechanisms from recognizing the harmful nature of the underlying request. DETAM addresses this by surgically modifying the attention mechanism during inference to ensure the model remains focused on the core intent of the query.
2. Methodology
DETAM is a finetuning-free defense that operates in three distinct stages: identification, parsing, and modification.
2.1 Sensitive Head Identification
The researchers observed that not all attention heads contribute equally to the success of a jailbreak. By analyzing the variance in attention scores between successful and blocked attacks, they identified a subset of "sensitive heads." These heads are particularly prone to being distracted by adversarial tokens. DETAM calculates a sensitivity score for each head, allowing for a targeted defense that only affects a small fraction of the model's architecture.
2.2 Intent-Aware Attention Redistribution
To differentiate between the adversarial wrapper and the actual request, DETAM employs a prompt-based "span parser." This parser identifies the core intent (e.g., "how to build a dangerous device") within the larger jailbreak prompt.
2.3 Targeted Modification
During the forward pass, DETAM modifies the attention mask within the pre-identified sensitive heads. It applies a scaling factor ($\beta$) to the tokens associated with the core intent. This effectively "amplifies" the signal of the potentially harmful request. By forcing the sensitive heads to prioritize the intent over the adversarial context, the model’s existing safety alignment is more likely to trigger, leading to a refusal of the harmful prompt.
3. Experimental Evaluation
3.1 Datasets and Attack Vectors
The efficacy of DETAM was tested against a variety of benchmarks and attack methodologies:
- JBB-Behaviors: 100 distinct misuse behaviors across 10 safety categories.
- WildJailbreak: 200 real-world jailbreak prompts sourced from user interactions.
- Utility Benchmarks: XSTest and ORBench-Hard were used to monitor "over-refusal" and ensure the model remains helpful for benign queries.
- Attacks: The defense was tested against diverse methods including GCG, DeepInception, DSN, RS, and ReNeLLM.
3.2 Key Results
DETAM demonstrated superior performance compared to existing baselines like SmoothLLM and Self-Reminder:
- LLaMA-2-7b-chat: The average Attack Success Rate (ASR) dropped from 31.8% to 0.8%.
- Vicuna-13b-v1.5: The ASR was reduced from 61.6% to 2.2%.
- Robustness: Unlike "Goal Priority" methods, DETAM maintained high defensive performance on "in-the-wild" datasets, suggesting it generalizes well to unseen attack patterns.
- Utility Preservation: DETAM maintained high instruction-following accuracy and low false-refusal rates (FRR), ensuring that the defense does not compromise the model's general capabilities.
4. Discussion and Insights
4.1 Structural Consistency
A significant finding of the study is the transferability of sensitive heads. Heads identified as sensitive in one model (e.g., LLaMA-2) often correspond to sensitive heads in other models within the same family. This suggests that the processing of adversarial prompts is structurally consistent across different scales of the same architecture.
4.2 Surgical Precision
Unlike input-level defenses that rewrite or denoise the entire prompt—potentially losing nuance—DETAM only modifies internal attention. This surgical approach allows the model to process complex instructions while remaining shielded from the adversarial influence of the jailbreak template.
5. Limitations and Future Work
While effective, DETAM has limitations. Its performance on models that have received no safety alignment (e.g., base Vicuna) is limited, as there is no "safety signal" to amplify. Additionally, the defense relies on the accuracy of the intent-span parser; if an attacker can successfully hide the core intent from the parser, the defense may be bypassed. Future research will focus on automating the selection of hyperparameters (such as the number of modified heads and the scaling factor $\beta$) and investigating adaptive attacks designed to circumvent attention-based defenses.
6. Conclusion
DETAM provides a computationally efficient, finetuning-free solution to the problem of LLM jailbreaking. By addressing the "Focus Loss" through targeted attention modification, it enables models to recognize and refuse harmful requests even when they are embedded in sophisticated adversarial wrappers.
Summary updated