Attention Slipping: A Mechanistic Understanding of Jailbreak Attacks and Defenses on Large Language ModelsAttention Slipping: A Mechanistic Understanding of Jailbreak Attacks and Defenses in LLMs
The paper reveals a prevalent phenomenon in jailbreak attacks, Attention Slipping: during an attack, the model gradually reduces its attention to the unsafe request in the query, ultimately leading to a jailbreak. This phenomenon appears consistently across multiple categories of jailbreak methods, including gradient-based token replacement, prompt-level template rewriting and in-context learning. The paper evaluates two query-perturbation-based defenses, Token Highlighter and SmoothLLM, and finds that both indirectly mitigate Attention Slipping, with effectiveness positively correlated with the degree of mitigation. Based on this, it proposes the Attention Sharpening defense, which directly counters this phenomenon by sharpening the attention score distribution via temperature scaling; experiments on four models, Gemma2-9B-It, Llama3.1-8B-It, Qwen2.5-7B-It and Mistral-7B-It v0.2, show that this method can resist multiple jailbreak attacks while maintaining benign task performance on AlpacaEval, and introduces no additional computation or memory overhead.