Understanding and Enhancing Safety Mechanisms of LLMs via Safety-Specific Neuron

Yiran Zhao, Wenxuan Zhang, Yuxi Xie, Anirudh Goyal, Kenji Kawaguchi, Michael ShiehICLR 2025

TL;DR

Researchers have discovered that safety in Large Language Models (LLMs) is governed by a tiny fraction of "safety neurons"—comprising less than 1% of total parameters. By surgically tuning only these specific neurons using a method called SN-Tune, they can drastically reduce model harmfulness without degrading general intelligence, and even protect safety during downstream fine-tuning with RSN-Tune.

What Problem Does This Paper Address?

While we’ve become proficient at "safety aligning" LLMs (making them refuse to help build bombs or generate hate speech), we don't actually know how the models store this safety logic. Current alignment techniques often treat the model as a black box, focusing on data-level tweaks or adding external guardrails.

This lack of understanding leads to two major issues:

  1. Inefficiency: We often update far more parameters than necessary, which can accidentally degrade the model's general reasoning or "helpfulness."
  2. Fragility: It is well-documented that fine-tuning a "safe" model on a benign downstream task (like medical records or coding) can accidentally "break" the safety alignment, making the model harmful again.

Methods

The authors propose a "neuron-level" approach, defining a neuron as a single row or column within the model's parameter matrices.

Overview of the Safety Neuron Tuning (SN-Tune) process.
  1. Safety Neuron Detection: They developed an accelerated method to identify neurons that are "consistently crucial" for defending against harmful queries. They measure "importance" by deactivating a neuron (setting it to zero) and observing how much the model's output changes when processing harmful vs. benign prompts.
  2. SN-Tune (Safety Neuron Tuning): Instead of fine-tuning the whole model, they only update the identified safety neurons. By freezing the rest of the model, they ensure that the "foundation" knowledge remains untouched.
  3. RSN-Tune (Robust Safety Neuron Tuning): To prevent safety from breaking during downstream fine-tuning, they identify "foundation neurons" (used for general tasks) and "safety neurons." RSN-Tune selectively tunes only the safety neurons that do not overlap with foundation neurons, creating a buffer that preserves safety integrity.

Datasets

  • Safety Detection/Tuning: A corpus of harmful queries and refusal outputs derived from the training set split in Zou et al. (2024), covering categories like terrorism, self-harm, and political campaigning.
  • Safety Evaluation: Harmful Behavior dataset (Zou et al., 2023), Adv Behavior (Mazeika et al., 2024), and MultiJail-En (Deng et al., 2024). They also used HarmBench for adversarial attack testing (GCG, AutoDAN, PAIR).
  • General Capability: MMLU (general knowledge), ARC-Challenge (science questions), and GSM8K (math word problems).
  • Foundation Neuron Detection: A Wikipedia corpus was used to identify neurons responsible for general knowledge.

Key Insights and Ideas

  • The 1% Rule: Safety mechanisms are incredibly sparse. Less than 1% of an LLM's parameters are dedicated to safety.
  • Self-Attention Dominance: Safety neurons are not distributed evenly; they are predominantly located in self-attention layers (e.g., 77% in Llama2-7B-Chat) rather than feed-forward layers. This suggests safety is more about contextual understanding of a threat than raw knowledge extraction.
Proportion of safety neurons in Attention vs. Feed-Forward layers.
  • Early Birds: Safety is managed collectively by neurons located in the first several layers of the model. Deactivating neurons in the first 10–16 layers causes a total collapse of safety alignment.
  • Language Specificity: Safety neurons are highly language-specific. There is minimal overlap between the neurons used to handle harmful queries in English versus Italian or Chinese. This explains why "jailbreaking" is often easier in non-English languages if the model wasn't specifically aligned for them.

Key Results

The results of SN-Tune are striking across several popular models:

  • Llama3-8B-Instruction: Reduced harmfulness score from 65.5 to 2.0.
  • Mistral-7B-Instruct-v0.2: Reduced harmfulness score from 70.8 to 4.5.
  • Vicuna-13B-1.5: Reduced harmfulness score from 93.5 to 3.0.

Crucially, these gains came with zero training cost to general capabilities. In some cases, MMLU and GSM8K scores actually improved slightly because the tuning was so targeted. Furthermore, RSN-Tune successfully mitigated safety "drift"; when fine-tuning Llama2-7B-Chat on math problems (GSM8K), the harmfulness score only rose to 26.0 compared to 41.0 with standard tuning.

Limitations and Future Work

  • The Overlap Problem: RSN-Tune is limited by the fact that some safety neurons do overlap with foundation neurons. If the overlap is too high, you cannot protect safety perfectly without also hindering the model's ability to learn new tasks.
  • Detection Corpus Dependency: The identification of safety neurons depends on the quality and diversity of the "harmful corpus" used during the detection phase.
  • Future Directions: The authors suggest exploring how these safety neurons emerge during the initial pre-training phase and whether "safety-by-design" architectures can be built by isolating these neurons from the start.

Summary updated

BibTeX
@inproceedings{zhao2025understanding,
  author = {Yiran Zhao and Wenxuan Zhang and Yuxi Xie and Anirudh Goyal and Kenji Kawaguchi and Michael Shieh},
  title = {{Understanding and Enhancing Safety Mechanisms of LLMs via Safety-Specific Neuron}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=yR47RmND1m},
}
Figure