TL;DR
Even after safety alignment, Large Language Models (LLMs) often retain latent unsafe behaviors within sparse subnetworks inherited during pre-training. This paper introduces a resource-efficient, gradient-free pruning framework that surgically identifies and removes these "unsafe tickets" while preserving general model utility. The resulting models achieve massive safety improvements and heightened jailbreak robustness across both text and vision-language models with zero inference overhead.
What Problem Does This Paper Address?
Standard alignment techniques like Supervised Fine-Tuning (SFT) and Reinforcement Learning from Human Feedback (RLHF) teach LLMs how to behave safely by shifting output probabilities toward preferred responses. However, they do not explicitly eliminate the underlying capabilities or subnetworks that generate harmful content. As a result, these unsafe behaviors often resurface when the model faces adversarial jailbreak attacks or distribution shifts.
Existing post-hoc alternatives, such as internal model interventions or heavy safety prompting, either introduce severe inference latency or require significant manual engineering and GPU resources. The authors tackle this gap by proposing a method to permanently and efficiently excise unsafe subnetworks directly from model weights without requiring full fine-tuning.
Methods
Inspired by the Lottery Ticket Hypothesis (LTH), the authors hypothesize that unsafe behaviors are localized within sparse subnetworks ("unsafe tickets"). To remove them, they develop a four-stage, gradient-free pruning pipeline:
- Behavior Profiling: The framework generates model-specific safe and unsafe prompt-response pairs. This ensures that the pruning dataset targets the specific model's actual failure modes rather than relying on generic public datasets.
- Attribution Analysis: The authors extend Wanda (a popular activation-based pruning method) to act as a gradient-free parameter attribution tool. Crucially, they modify the Wanda score to isolate activations exclusively during the response generation phase, completely ignoring prompt tokens.
- Component Scoring: A contrastive importance score is computed for each parameter by dividing its unsafe activation score by its safe activation score ($I = S'_u / (S'_s + \epsilon)$). This isolates weights that are uniquely active during harmful outputs but quiet during benign ones.
- Iterative Pruning: Instead of pruning all components at once, the framework progressively removes parameters using either a fast Greedy Pruning heuristic or a more thorough Beam Search Pruning strategy guided by a contrastive validation loss.
Datasets
The framework utilizes several datasets for profiling and evaluation:
- Profiling: An unsafe prompt dataset from prior work on circuit breakers is filtered using Llama-Guard to build the model-specific behavioral dataset.
- Safety Evaluation: HarmBench (which aggregates AdvBench and the TDC 2023 dataset) and CatHarmfulQA are used to measure unsafe generation rates.
- Over-Refusal Evaluation: JailbreakBench (JBB) evaluates whether the model over-refuses benign prompts.
- Utility Evaluation: MT-Bench (for text LLMs), LLaVA-Bench (In-the-Wild) (for vision-language models), and UltraChat_200k ensure general capabilities are preserved.
Key Insights and Ideas
- The "Unsafe Ticket" Hypothesis Holds Up: The paper provides strong empirical backing for the idea that safety risks are localized within sparse subnetworks rather than being uniformly distributed across the entire model.
- Anatomy of Harm: Across all model scales, the pruning process consistently targets only two component types: the self-attention output projections (
Self-Attn.O) and the second linear layer in the MLP blocks (MLP.2). This implies that these specific layers are the primary drivers of unsafe generations. - Modality-Agnostic Safety: The framework transfers seamlessly to Vision-Language Models (VLMs) like LLaVA without modifying the visual encoder. Pruning just the language component successfully suppresses unsafe multimodal outputs, demonstrating that safety mechanisms are heavily rooted in text generation layers.
Key Results
- Surgical Safety Gains: On Mistral-7B, Beam pruning slashed the Unsafe Rate from 22.8% to just 1.17%, outperforming DPO while maintaining a strong utility score (7.13 vs 8.07 base).
- Zero Inference Overhead: Unlike prompting defenses (such as Goal Prioritization) which inflate prompt lengths and more than double inference latency, the pruned models maintain the exact same inference speed and memory footprint as the base model.
- Extreme Efficiency: The Greedy variant pruned Mistral-7B in just 455 seconds using a mere 18 GB of peak GPU memory, making it highly accessible for resource-constrained environments.
- Jailbreak Robustness: Beam pruning significantly lowered the Attack Success Rate (ASR) of adversarial jailbreaks on Mistral-7B; for instance, the success rate of the AutoDAN attack dropped from 45.7% to 0.67%.
Limitations and Future Work
- Beam Search Compute Costs: While the Greedy approach is incredibly fast, the higher-performing Beam Search algorithm incurs significantly more computational cost during the initial building phase (taking up to ~4.6 hours for Mistral-Small).
- Static Attribution: The parameter attribution mechanism relies on static, token-level activations, which might fail to capture broader semantic or contextual nuances that influence unsafe generations.
- Future Directions: The authors suggest exploring parallelization to accelerate the beam search process and extending the framework to handle more dynamic, context-aware attribution.
Summary updated