cs.AINov 5, 2026

AttentionSwitch: Jailbreak Defense for LLMs via Joint Learning of Sparse Attention-Head Selection and Scaling

Authors: Doniyorkhon Obidov, Honggang Yu, Xiaolong Guo, Kaichen Yang

Organizations: Michigan Technological University · Miami University · Lehigh University

Abstract

Large language models have achieved remarkable performance across a wide range of tasks, yet they remain susceptible to jailbreak attacks that circumvent safety mechanisms and elicit harmful or unintended outputs. Although safety can be improved through model fine-tuning, such approaches can be computationally expensive and may degrade previously acquired capabilities through catastrophic forgetting. Recent jailbreak defenses have therefore explored targeted interventions on specific model components associated with unsafe behavior. However, existing approaches typically decouple two inherently related decisions: where to intervene and how to modify the selected components. Such sequential optimization may be suboptimal because the optimal intervention location can depend on the intervention applied there, and vice versa. In this work, we introduce AttentionSwitch, the first jailbreak defense to jointly optimize intervention sites and strengths within a frozen LLM. Specifically, AttentionSwitch learns a sparse set of attention heads together with query-conditioned multiplicative scaling factors, allowing the outputs of the selected heads to be either attenuated or amplified without altering the directions of their representations. Across popular language models and jailbreak attacks, AttentionSwitch outperforms existing defenses, with particularly strong results when training data is scarce.

Figures & tables

Appendix figures & tables8 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Depth Charge: Jailbreak Large Language Models from Deep Safety Attention Heads

    Mar 6, 2026Jinman Wu, Yi Xie, Shiqian Zhao +1Adversarial Attacks on LLMsLLM Jailbreak Attacks

  2. POEM: Output-Relative Block-Sparse Attention for Long-Context Prefilling

    Nov 10, 2026Haoyi Wu, Yunkai Dang, Wanyu Zhang +2LLM SafetyJailbreak Defense

  3. TERM: Target-Free Jailbreak Defense via Entropy-Guided Residual Modulation

    Nov 10, 2026Yunkai Dang, Wanyu Zhang, Meiyi Zhu +3LLM SafetyJailbreak Defense