Beijing Institute of Technology Pinpoints the Attention Heads Behind Every Jailbreak
Researchers pinpoint the exact attention heads that make LLMs cave to jailbreaks — and show you can dial safety up or down at inference time without retraining
ProTakeaways
- Moving a completion suffix like
Sure, here is a step-by-step guide:outside the user prompt boundary drives jailbreak ASR from 0 to as high as 0.58 on LLaMA-2-7B-Chat. - Researchers used path patching to causally identify which attention heads enable this -- heads in layers 15-17 and 25-27 are most critical.
- Two head types were found: Safety Heads (suppress harmful output) and Continuation Heads (drive harmful generation), confirmed via ablation and activation scaling.
- Amplifying safety heads at inference time cuts ASR dramatically with no retraining; amplifying continuation heads does the opposite.
- Safety heads work differently across architectures: LLaMA-2 heads detect harmfulness, while Qwen2.5 heads control refusal execution.
- No code released; experiments use open benchmarks AdvBench, JailbreakBench, and MaliciousInstruct with deterministic decoding.
Safety alignment in large language models has always felt like a game of whack-a-mole. You patch one attack vector, another pops up. A new paper from researchers at the Beijing Institute of Technology takes a different approach: instead of patching, they crack open the model and watch the fight happen in real time. The result is one of the clearest mechanistic explanations yet for why jailbreaks work at all.
The paper, "The Struggle Between Continuation and Refusal", focuses on a deceptively simple attack. Move a completion-style suffix like Sure, here is a step-by-step guide: First, from inside the user prompt to just after the prompt delimiter, and the model stops refusing and starts complying. No semantic change, no elaborate social engineering. Just a structural shift in where the text sits.
A one-line prompt change that breaks safety
The core observation is striking. Simply relocating a continuation-triggered instruction suffix can substantially increase jailbreak success rates. The researchers tested this on two open-source models: LLaMA-2-7B-Chat and Qwen2.5-7B-Instruct. Under the clean prompt setting, LLaMA-2-7B-Chat's Attack Success Rate (ASR) remains zero across AdvBench, JailbreakBench, and MaliciousInstruct, whereas under the jailbreak prompt, the ASR rises sharply to 0.16, 0.26, and 0.58, respectively.
The intuition behind why this works is rooted in pretraining. Given that most current LLMs are trained on next-token prediction, they possess an inherent tendency to generate coherent continuations that align with the semantics of the input. Alignment training tries to override this tendency when safety is at stake, but it turns out that override is fragile. When the suffix lands outside the user turn and looks like the beginning of an assistant response, the model's pretraining instinct kicks in and wins.
Opening the black box with path patching
The researchers did not stop at observing the behavior. They used a technique called path patching to find exactly which attention heads are responsible. Path patching is a causal interpretability method: you run the model twice (once on a safe prompt, once on the jailbreak prompt), then swap the internal activations of one attention head at a time and measure how much the output distribution shifts. If swapping a head's activation changes the output significantly, that head is causally involved in the behavior.
The path patching results reveal a sparse yet functionally significant distribution of influential attention heads. Notably, heads in layers 15-17 and 25-27 show particularly strong effects, implying that these layers contain key pathways that substantially influence the model's predictions.

From this analysis, the team identified two functionally distinct classes of attention heads:
- Safety Heads: Zeroing these heads increases ASR. They are actively suppressing harmful generation. Head (27,7) in LLaMA-2-7B-Chat is a clear example.
- Continuation Heads: Zeroing these heads decreases ASR. They are the engine driving the model to keep generating. Head (13,17) is a key example.
As a sanity check, zeroing randomly selected heads produced negligible changes in ASR, confirming the causal specificity of the identified heads.
Turning the dial at inference time
Once the heads were identified, the team applied activation scaling -- a lightweight technique that multiplies the output of a specific attention head by a scalar w during inference, without changing any model weights. Setting w > 1 amplifies the head's contribution; w = 0 silences it entirely.
The results validate the causal story cleanly. Varying the scaling coefficient for safety heads from w=0 to moderate values sharply decreases ASR across all datasets, demonstrating that strengthening safety head activations significantly enhances the model's resistance to jailbreak attacks. Flip the other direction: scaling continuation heads produces the opposite effect -- increasing the scaling coefficient leads to a monotonic and substantial rise in ASR on all benchmarks.

Scaling multiple heads compounds the effect. Amplifying three safety heads simultaneously drove ASR on MaliciousInstruct from 0.58 down to 0.16 on LLaMA-2-7B-Chat. Amplifying three continuation heads pushed it up to 0.92.
Safety heads do different things in different models
One of the more nuanced findings is that safety heads are not all doing the same job. The researchers probed this with a reply inversion task: they asked the model to output "Yes" for harmful inputs and "No" for harmless ones, inverting the normal logic. This decouples two distinct safety behaviors:
- Harmfulness Recognition: Does the model know the input is dangerous?
- Refusal Execution: Does the model decide to withhold a response?
The safety heads in LLaMA-2-7B-Chat are primarily responsible for recognizing harmful instructions. Scaling these safety heads enhances the model's ability to detect harmful instructions; however, excessive scaling can make the model overly cautious, leading to the misclassification of a small number of harmless instructions as harmful.
In contrast, the safety heads in Qwen2.5-7B-Instruct are primarily responsible for refusal behavior. Amplifying them over-triggers the refusal mechanism, causing the model to say "No" even when it correctly identified the input as harmful. The two models have the same safety outcome but achieve it through different internal wiring.
What this means in practice
This work sits at the intersection of mechanistic interpretability and LLM security, a space that is growing fast. Despite significant efforts in safety alignment, current LLMs remain vulnerable to jailbreaking attacks, and the root causes of such vulnerabilities are still poorly understood. Most defenses today are data-driven: collect more refusal examples, retrain, repeat. This paper suggests a complementary path: identify the specific heads responsible for safety and continuation, then modulate them directly at inference time.
The practical implications are concrete:
- Safety can be boosted at inference time by amplifying safety head activations, with no retraining required.
- Continuation heads are a measurable attack surface. Monitoring their activation patterns could flag jailbreak attempts in real time.
- The architecture-specific differences in safety head behavior mean that defenses need to be tailored per model family, not applied universally.
- The "locate-then-intervene" paradigm demonstrated here could extend to other alignment failures beyond jailbreaks.
No code or model weights have been released alongside the paper. The experiments were conducted on LLaMA-2-7B-Chat and Qwen2.5-7B-Instruct using three standard benchmarks: AdvBench, JailbreakBench, and MaliciousInstruct. The evaluation is rule-based and deterministic (greedy decoding, max 32 new tokens), which makes the results reproducible but also means ASR numbers may differ under sampling-based generation.
The deeper takeaway is not just about this one attack. This jailbreak behavior primarily arises from an inherent competition between the model's intrinsic continuation drive and the safety defenses acquired through alignment training, and these findings provide a novel mechanistic perspective for understanding and interpreting jailbreak behaviors in LLMs. As long as models are pretrained to complete text and then patched for safety, that tension will exist. Understanding exactly where it lives in the network is the first step toward resolving it.