Recent studies have started to investigate internal safety-relevant components, such as safety-critical parameters and neurons, in large language models (LLMs) by gradient-based importance attribution to guide safety interventions. However, existing gradient-based methods have four limitations. First, they rely on gradients of generic training objectives, which measure discrepancies between model outputs and specific response patterns rather than directly measuring output safety. Second, they overlook parameter variations across layers and modules. Third, safety-critical parameters in multimodal large language models (MLLMs) remain underexplored. Furthermore, a single gradient is insufficient to reflect local parameter geometry. To address the first three limitations, we propose Multimodal Safety Index (MSI), which quantifies output safety using the expected safety value and develops estimators for its gradient and parameter variation magnitudes for importance attribution. To address the fourth limitation, we extend MSI to Neighborhood-Consensus Multimodal Safety Index (NC-MSI) by aggregating gradients across locally perturbed model states. Using NC-MSI, we identify distinct safety-critical parameter distributions in LLMs and MLLMs and propose two targeted intervention strategies: Safety Enhancement Tuning (SET) aligns unsafe models by updating only a few safety-critical parameters, preserving general capabilities. Safety-Preserving Adaptation (SPA) freezes critical parameters and adopts our optimizer, SafeAdamW, enabling aligned models to acquire new capabilities without significant safety degradation. Experiments across LLMs and MLLMs demonstrate that SET reduces the attack success rate of under-aligned models by over 70% in only 100 steps using 1% of parameters, whereas SPA limits safety degradation of aligned models to within 0.5% on average after 1,000 steps of fine-tuning.
翻译:暂无翻译