Attributing and Exploiting Safety Vectors in Large Language Models via Global OptimizationAttributing and Exploiting Safety Vectors through Global Optimization in Large Language Models
GOSV globally optimizes to locate safety heads and performs white-box re-patching; on AdvBench, Mistral-7B's ASR is 100.00% (Table 2).
White-box jailbreak at inference: without changing the prompt or parameters, only at the last token the activations of safety-critical attention heads are replaced with the mean of Harmful Patching or 0 from Zero Ablation, to make aligned open-source LLMs output harmful content. Success is determined by HarmBench-Llama-2-13b-cls.
- Aligned LLMs are still easily jailbroken; the authors believe that understanding of the components that control safety is insufficient. Existing attribution methods are mostly local and greedy, ignoring collaboration among attention heads.
- GOSV uses policy gradient to select all attention heads simultaneously. Harmful Patching writes the average activation of harmful generation, and Zero Ablation sets the selected heads to 0, yielding two types of vectors. At inference, the prompt and parameters are not changed; only these heads are re-patched at the last token.
- On four open-source models, Ours (taking the higher ASR of the two strategies) in Table 2 outperforms GCG, AutoDAN, AdvPrefix, DSN, and ORTHO on both AdvBench and StrongREJECT. The authors state that safety collapses when about 30% of heads are patched, and the overlap between the two head types is low.
- The authors note that no defense has been developed, and white-box access is required; evaluation is limited to a set of open-source models and English instructions. ASR is averaged over three runs; Table 2 does not separate the two strategies; the evaluation sets for Figures 4 to 7 are not specified in the paper.
- Evaluated models
- Llama-2-7b-chatLlama-3.1-8B-InstructQwen2.5-7B-InstructMistral-7B-Instruct-v0.2
- Benchmarks
- AdvBenchStrongREJECTAlpaca
- Metrics
- ASR
The paper proposes the GOSV framework, which simultaneously identifies safety-related attention heads in large language models through global optimization and constructs a white-box jailbreak method based on them. The framework employs two activation re-patching strategies, Harmful Patching and Zero Ablation, identifying two groups of spatially separated safety vectors with low overlap, termed Malicious Injection Vectors and Safety Suppression Vectors, from which the authors argue that aligned models maintain independent functional pathways for safety. The analysis shows that when approximately 30% of attention heads are re-patched, all tested models exhibit complete failure of safety mechanisms. The white-box jailbreak method based on these safety vectors substantially outperforms existing white-box attacks across all tested models.
Paper analysis
What problem does this paper attempt to solve?
The authors argue that local greedy attribution ignores attention head cooperation, so they use global optimization to extract safety vectors and perform white-box jailbreaks.
Safety guardrails in aligned LLMs remain fragile, and local greedy attribution cannot see how attention heads work together to maintain safety.
- Scenario: The authors state that models aligned with RLHF and DPO are still broken by jailbreaks and model editing; this corresponds to limited understanding of the architectural components governing safety.
- Existing shortcomings: Existing causal interventions attribute safety to layers, neurons, or individual attention heads, but typically assume component contributions are independent, ignoring that component functions are interdependent in information flow.
- Hypothesis: Inspired by Function Vectors, the authors hypothesize that safety behavior can be encoded as safety vectors transmitted by several attention heads, i.e., an implicit safety representation captured by a set of activations.
- Approach: Propose GOSV, optimizing over all attention heads simultaneously; use two activation patching methods to obtain Malicious Injection Vectors and Safety Suppression Vectors, and patch these vectors at inference to jailbreak.
- Threat model:
- Goal: Bypass safety alignment to make the model produce harmful outputs. The paper records results as whether the attack succeeds.
- Knowledge: The paper describes an inference-time white-box jailbreak; Limitations state that activation patching requires white-box access.
- Capability: No prompt engineering or query modification, and no parameter changes; only replaces activations of identified heads at the last token.
- Victim system: Experiments target four open-source aligned chat models. Success is judged yes/no by HarmBench-Llama-2-13b-cls. The paper does not specify a query budget.
What related research exists?
Related work is divided into jailbreak attacks and safety attribution on attention heads; the authors criticize the latter's local greedy assumption.
Jailbreak attacks
- Optimization-based suffixes and objectives: GCG (Zou et al., 2023) searches for adversarial suffixes; AdvPrefix (Zhu et al., 2024) adjusts jailbreak objectives; DSN (Zhou et al., 2025) suppresses refusals. The paper treats them as white-box baselines in experiments, without criticizing each in Related Work.
- Readable prompts and context: AutoDAN (Liu et al., 2023) uses genetic algorithms to generate readable prompts; the same paragraph also mentions iterative refinement (Chao et al., 2025; Mehrotra et al., 2024), nested scenarios (Li et al., 2023), multi-turn escalation (Russinovich et al., 2025), and disguised intent (Zheng et al., 2025). The paper only describes these approaches.
- Representation-level refusal suppression: ORTHO (Arditi et al., 2024) orthogonalizes the refusal direction. The paper lists it as a white-box baseline.
Safety attribution on attention heads
- Scoring and monitoring: Zhou et al. (2024b) propose the Safety Head Importance Score, which the paper states identifies safety concentrated in sparse safety heads. Hung et al. (2025) Attention Tracker monitors attention flow to detect prompt injection.
- Modifying attention: DeTAM (Li et al., 2025) modifies attention at inference for defense; AGD (Pan et al., 2025a) adjusts weights of jailbreak-sensitive heads using variational games; Banerjee et al. (2025) manipulate specific heads by language for multilingual safety alignment.
- Authors' criticism of this group: The authors state that these methods use local, greedy attribution to identify safety-critical heads, treating heads as independent units and ignoring interdependencies. The criticism applies to the group as a whole, not to other flaws of individual papers.
Mechanistic interpretation and alignment training
- Representations and causal interventions: The introduction lists works mapping internal representations to concepts (Zhou et al., 2024a; Pan et al., 2025b; Wollschläger et al., 2025; Zhao et al., 2025a), as well as attributions to safety layers (Li et al., 2024), safety neurons (Chen et al., 2024; Zhao et al., 2025b), or interventions on attention heads. The authors state that such approaches typically rely on local greedy attribution.
- Function Vectors: Todd et al. (2023) write tasks as compact representations transmissible by specific attention heads. The authors state GOSV is inspired by this. Evidence for interdependence cites Elhage et al. (2022), Fakhar and Hilgetag (2022), and Giallanza et al. (2024).
- Alignment: The introduction mentions RLHF (Ouyang et al., 2022) and DPO (Rafailov et al., 2023). Neither is an experimental baseline.
Baselines and benchmarks
- Baseline methods: §4.1 white-box comparisons are GCG, AutoDAN, AdvPrefix, DSN, ORTHO. §5 also compares with Ships (Zhou et al., 2024b) and fine-tuning FT on the same training data.
- Benchmarks: AdvBench and StrongREJECT. Benign patching in Appendix E.2 uses the first 100 Alpaca entries.
The authors position this work against local attribution: using global optimization to simultaneously attribute safety across all attention heads, capturing distributed, interdependent safety mechanisms.
How does the paper address this problem?
GOSV uses policy gradient to select heads simultaneously across all attention heads, and uses two activation patching methods to extract safety vectors.
GOSV does not fine-tune parameters. It patches attention head activations at inference and uses global optimization to find a set of heads whose patching pushes outputs toward harmful target responses; the attack then reuses these positions and patching values.
Intervention target
- Multi-head attention is computed per equations (1)(2). The intervention targets the output z at layer l, head position h at the last token, with dimension equal to head dimension. The authors state the last token is critical for autoregressive generation, citing Todd et al. (2023).
- Patching is defined as zl,h ← μl,h, i.e., replacing that activation with the patching value and letting it flow into subsequent layers.
Two patching methods
- Harmful Patching: For each head, take the mean activation at the last token over malicious instructions as μ. Experiments use N=1000, which the authors state is 10 times the 100 training samples (§4.1). The resulting position-value pairs are called Malicious Injection Vectors.
- Zero Ablation: Set μ to 0 for selected heads to cut off information flow from these heads. The corresponding set is called Safety Suppression Vectors.
- Appendix E.2 also defines control methods Benign Patching (mean of first 100 Alpaca entries) and Random Patching (Gaussian sampling with the same mean and standard deviation as harmful activations). They are not part of the main attack.
Global head selection
- Each head has a parameter θ, and whether to patch is decided by Bernoulli(σ(θ)). Unlike per-head greedy, sampling covers combinations of all heads.
- Each round samples K=32 configurations, trains for E=500 epochs, Adam, learning rate 0.1. Loss is L=1−CosSim(ŷ, R), i.e., semantic distance between generated response and target harmful response; embeddings from all-MiniLM-L6-v2 (384 dimensions).
- Target responses are generated by unaligned base models on harmful queries; the paper does not name these models. Training set is 100 query-target response pairs from AdvBench. During training, both sides are kept at 256 tokens (Appendix E.1).
- Updates use REINFORCE-style policy gradient (Williams, 1992; Hojel et al., 2024). After training, a final sample from the Bernoulli gives I_safety. Algorithm 1 is in Appendix D. Model parameters are never updated.
Inference-time attack and judgment
- For test queries, at the last token, replace each head in I_safety with its corresponding μ (Equation 7). Each strategy is used independently, without modifying prompts or parameters.
- The progressive analysis in §4.3 is a different usage: patch top-k heads by σ(θ) in descending order, not a new Bernoulli sample.
- ASR is the number of successes divided by total attacks. The judge HarmBench-Llama-2-13b-cls reads the behavior and generation, outputting yes or no. Appendix B gives the full judgment template.
What experiments did the paper conduct?
On four open-source models, the ASR of Ours (taking the higher of the two strategies) in Table 2 is higher than all listed white-box baselines.
Experimental Setup
- Models: Llama-2-7b-chat, Llama-3.1-8B-Instruct, Qwen2.5-7B-Instruct, Mistral-7B-Instruct-v0.2. Table headers abbreviated as Llama2-7B, Llama3.1-8B, Qwen2.5-7B, Mistral-7B. Table 4: parameter sizes 7B/8B/7B/7B, layers 32/32/28/32, heads per layer 32/32/28/32, head dimensions all 128.
- Data: Safety head identification uses only 100 AdvBench behaviors and harmful target responses. Attack evaluation uses the full AdvBench (520 behaviors) and StrongREJECT (313 malicious instructions).
- Baselines: GCG, AutoDAN, AdvPrefix, DSN, ORTHO; §5 also compares Ships and FT. Appendix E.3, Table 5: GCG uses 500 steps, search width 512, top-k 64; AutoDAN's attack model is gpt-3.5-turbo; FT uses LoRA rank 16, alpha 32, 3 epochs, learning rate 2×10^{-4}.
- Metrics: ASR is judged yes/no by HarmBench-Llama-2-13b-cls. Appendix B states that the mean over three different random seeds is reported. The paper does not perform statistical significance tests.
- Optimization: Harmful Patching uses N=1000; GOSV uses K=32, 500 epochs, learning rate 0.1. Appendix E states that experiments were completed on a single 80GB NVIDIA A100.
- Table 2 reporting: §5 states that for each model only the higher ASR of the two strategies is reported, without separately listing Harmful Patching and Zero Ablation.
Main Results
Model AdvBench ASR StrongREJECT ASR Llama-2-7b-chat 92.50% 91.05% Llama-3.1-8B-Instruct 96.35% 92.01% Qwen2.5-7B-Instruct 86.35% 90.42% Mistral-7B-Instruct-v0.2 100.00% 99.36% According to Table 2, the above table is Ours, and is the higher value of the two strategies.
- Comparison with baselines in the same table: All 8 cells are higher than GCG, AutoDAN, AdvPrefix, DSN, ORTHO in the same table. The authors state that it is close to the best on almost all model-dataset combinations, and claim to outperform all baselines on Mistral and Llama-3.1.
- Baseline endpoints: The lowest baseline cell in Table 2 is GCG on Llama3.1-8B for StrongREJECT at 18.27%, and the lowest for AdvBench is AutoDAN on Llama2-7B at 24.04%. The closest to Ours include ORTHO on Qwen for AdvBench at 84.81%, AdvPrefix on Mistral at 95.77%, and ORTHO on Qwen for StrongREJECT at 88.50%, AdvPrefix on Mistral at 90.10%.
- Authors' interpretation: The authors state that this supports that the safety vectors found by GOSV are effective, and that the attack generalizes across architectures and harmful scenarios. The paper does not report the number of queries.
Two Pathways and Re-patching Scale
- Head positions: Figure 2 uses color to show the optimized selection probability σ(θ). In the figure, n for Zero Ablation is 326 for Llama2-7B, 333 for Llama3.1-8B, 240 for Qwen2.5-7B, 379 for Mistral-7B; for Harmful Patching it is 339, 339, 263, 322. Figure 8 overlap rates are 24.8% (overlap 132), 21.3% (118), 21.2% (88), 22.3% (128). The authors state that overlap remains consistently low, and both pathways can independently break safety. Appendix F states that scatter points are mostly along the axes rather than the diagonal. Figure 3 only textually states that top-k overlap remains consistently low, without giving readable numbers.
- About 30%: Figure 4 plots ASR and PPL against the number of re-patched heads; the paper does not specify the evaluation set. The authors state that about 1% of heads can raise ASR from near 0 to 50% or higher for most models; at about 30% ASR reaches a plateau, and they state that safety vectors account for about one-third of all heads. The authors state that Qwen2.5 rises more slowly. Beyond that point, some models' ASR slightly decreases; the authors believe this is not safety recovery but generation breakdown, and state that PPL rises after about 30%.
- Transition for a single request: Table 1 uses Zero Ablation on Llama-3.1-8B, with head counts 0, 160, 320, 640, 1024 corresponding to Complete Refusal, Refusal with Harmful Content, Full Harmful Compliance, Degraded & Incoherent, Complete Dysfunction. The authors state that at about 30% (320 in the table) it transitions to full harmful compliance, and further increases lead to incoherence. Harmful original text is not quoted.
Re-patching Values, Ships, and Fine-tuning
- Which activations are effective: Figure 5 compares Harmful Patching, Zero Ablation, Benign Patching, Random Patching, and vanilla; the paper does not specify the benchmark. The authors state that only the first two exceed 90% ASR; the latter two show only small increases relative to no intervention, which the authors attribute to disrupting general functionality rather than removing specific safety vectors. Exact readings for each bar in the figure are not given in the paper.
- Ships: The row without the method in Table 3, AdvBench / StrongREJECT, is Llama2-7B 0.38% / 0.32%, Llama3.1-8B 0.96% / 1.60%, Qwen2.5-7B 1.73% / 7.67%, Mistral-7B 35.58% / 29.71%. Ships is 33.08% / 33.87%, 15.19% / 16.61%, 0.00% / 0.64%, 0.38% / 8.31%. The authors state that the improvement over Ships exceeds 50%, and that Ships is near 0 on Qwen2.5-7B and Mistral-7B, and harms normal functionality. For the latter two models, Ships is lower than the no-intervention row in the same table.
- FT and cross-table inconsistency: FT with the same training data, AdvBench / StrongREJECT, is 91.92% / 71.88%, 94.81% / 84.66%, 90.58% / 82.43%, 95.00% / 80.83%. Ours in Table 3 is 92.50% / 91.05%, 96.35% / 97.44%, 86.35% / 90.42%, 100.00% / 99.36%. The authors state that on the training distribution the two are comparable, and on StrongREJECT this paper is better, and claim improvements ranging from 8% to 19%. An exception is Qwen2.5-7B on AdvBench: FT 90.58% is higher than Ours 86.35%. For Llama3.1-8B on StrongREJECT, Ours is 92.01% in Table 2 and 97.44% in Table 3; the paper does not explain this.
Other Ablations and Analyses
- Epochs: In Figure 6, ASR for the four models rises quickly in the first 300–500 epochs, then slows; the authors fix 500 epochs based on this. The paper does not specify the evaluation set.
- Sample count: Figure 7 only plots Llama-2-7B and Llama-3.1-8B. The authors state that ASR rises quickly between 20 and 50 samples, and enters a plateau after about 100. The paper does not give specific ASR values in the figure, nor does it specify the evaluation set.
- Negatives and exceptions: Qwen2.5's ASR rises more slowly; after excessive re-patching, some models' ASR decreases and outputs become incoherent; Benign/Random cannot reach the authors' claimed 90%+; Ships is lower than the no-intervention row on Qwen and Mistral; FT is higher than Ours on Qwen's AdvBench.
What are some points that can be further explored?
The authors note that defenses have not been addressed, white-box access is required, and state that the evaluation focuses on open-source models and English instructions.
Limitations and future directions noted by the authors
- No defense developed: Limitations state that no defense has been developed based on these findings; future work should develop more robust protections.
- White-box requirement: The method relies on white-box access for activation patching, limiting applicability in black-box scenarios (Limitations).
- Models, languages, and behaviors: Evaluation is limited to a set of open-source models and English instructions; generalizability to larger proprietary models, multilingual contexts, and other safety-critical behaviors requires further study (Limitations).
Experimental coverage
- Tested models are Llama-2-7b-chat, Llama-3.1-8B-Instruct, Qwen2.5-7B-Instruct, Mistral-7B-Instruct-v0.2, with architecture in Table 4 (§4.1).
- Attack ASR is reported on the full AdvBench (520 behaviors) and StrongREJECT (313 malicious instructions); safety head identification uses 100 AdvBench entries (§4.1).
- Comparisons include GCG, AutoDAN, AdvPrefix, DSN, ORTHO, as well as Ships and FT (Table 2, Table 3). There are also Benign Patching and Random Patching (Figure 5, Appendix E.2).
- ASR is judged by HarmBench-Llama-2-13b-cls; Appendix B states the mean of three runs. The paper does not report agreement with human judgment or query counts for each attack.
- Table 2 reports only the higher ASR of the two strategies (§5). The unaligned base models generating target responses are not named (Appendix E.1). The evaluation sets for Figures 4, 5, 6, and 7 are not specified in the paper.
Summarize the main content of the paper
GOSV globally selects two types of safety vectors; after re-patching at inference, the ASR in Table 2 is higher than the listed white-box baselines.
GOSV writes the safety of aligned models as vectors transmissible by attention heads, uses global optimization to find these heads, then modifies activations at inference to jailbreak.
- Problem: Local attribution assumes head contributions are independent. The authors argue this misses how heads work together to maintain safety, so why guardrails are vulnerable to jailbreaks remains unclear.
- Method: All heads are selected simultaneously using Bernoulli policy gradient. Harmful Patching writes the average activation of harmful generations, Zero Ablation sets selected heads to 0. Figure 8 shows overlap rates of 21.2%, 21.3%, 22.3%, 24.8% across four models. The attack does not modify prompts or parameters, only patches at the last token.
- Main results: Table 2 reports the higher ASR of the two strategies. On AdvBench, the four models achieve 92.50%, 96.35%, 86.35%, 100.00%; on StrongREJECT, 91.05%, 92.01%, 90.42%, 99.36%, all higher than GCG, AutoDAN, AdvPrefix, DSN, ORTHO in the same table.
- Other results: The authors state that safety collapses when about 30% of heads are patched (Figure 4); further increases degrade output. Ships achieves 0.00% on AdvBench for Qwen2.5-7B (Table 3). FT on Qwen's AdvBench is 90.58%, higher than Ours' 86.35%.
- Authors' conclusion: The authors argue that aligned models maintain separate safety pathways rather than a single mechanism; and state that robust defenses must consider mechanisms that span multiple pathways and are interdependent. Limitations state that no defense is provided, and the method requires white-box access.
Related papers
Show 3 more papers
- Where Is Rank-1 DiM Refusal Intervenable in Multimodal LM Derivatives?Analysis / interpretabilityarXiv