Towards Understanding Safety Alignment: A Mechanistic Perspective from Safety Neurons
Jianhui Chen, Xiaozhi Wang, Zijun Yao, Yushi Bai, Lei Hou, Juanzi Li
Abstract
Large language models (LLMs) excel in various capabilities but pose safety risks such as generating harmful content and misinformation, even after safety alignment. In this paper, we explore the inner mechanisms of safety alignment through the lens of mechanistic interpretability, focusing on identifying and analyzing safety neurons within LLMs that are responsible for safety behaviors. We propose inference-time activation contrasting to locate these neurons and dynamic activation patching to evaluate their causal effects on model safety. Experiments on multiple prevalent LLMs demonstrate that we can consistently identify about safety neurons, and by only patching their activations we can restore over of the safety performance across various red-teaming benchmarks without influencing general ability. The finding of safety neurons also helps explain the''alignment tax''phenomenon by revealing that the key neurons for model safety and helpfulness significantly overlap, yet they require different activation patterns for the same neurons. Furthermore, we demonstrate an application of our findings in safeguarding LLMs by detecting unsafe outputs before generation. The source code is available at https://github.com/THU-KEG/SafetyNeuron.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers13
- GateBreaker: Gate-Guided Attacks on Mixture-of-Expert LLMsLichao Wu, Sasha Behrouzi, Mohamadreza Rostami, Stjepan Picek et al.USENIX Security 2026 · 14 citations
- Superficial Safety Alignment HypothesisJianwei Li, Jung-Eun KimICLR 2026 · 11 citations
- Safe + Safe = Unsafe? Exploring How Safe Images Can Be Exploited to Jailbreak Large Vision-Language ModelsChenhang Cui, Gelei Deng, An Zhang, Jingnan Zheng et al.NeurIPS 2025 · 10 citations
- Mechanistic Data Attribution: Tracing the Training Origins of Interpretable LLM UnitsJianhui Chen, Yuzhang Luo, Liangming PanICML 2026 · 6 citations
- SafeSeek: Universal Attribution of Safety Circuits in Language ModelsMiao Yu, Siyuan Fu, Moayad Aloqaily, Zhenhong Zhou et al.ICML 2026 · 3 citations
Builds on35
- Training language models to follow instructions with human feedbackLong Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida et al.NeurIPS 2022 · 24,707 citations
- Direct Preference Optimization: Your Language Model is Secretly a Reward ModelRafael Rafailov, Archit Sharma, Eric Mitchell, Christopher D. Manning et al.NeurIPS 2023 · 10,924 citations
- Measuring Massive Multitask Language UnderstandingDan Hendrycks, Collin Burns, Steven Basart, Andy Zou et al.ICLR 2021 · 7,905 citations
- Locating and Editing Factual Associations in GPTKevin Meng, David Bau, Alex Andonian, Yonatan BelinkovNeurIPS 2022 · 3,415 citations
- TruthfulQA: Measuring How Models Mimic Human FalsehoodsStephanie Lin, Jacob Hilton, Owain EvansACL 2022 · 3,228 citations
Related papers
- Understanding and Enhancing Safety Mechanisms of LLMs via Safety-Specific NeuronYiran Zhao, Wenxuan Zhang, Yuxi Xie, Anirudh Goyal et al.ICLR 2025
- Why Safeguarded Ships Run Aground? Aligned Large Language Models' Safety Mechanisms Tend to Be Anchored in The Template RegionChak Tou Leong, Qingyu Yin, Jian Wang, Wenjie LiACL 2025
- Safety Alignment via Constrained Knowledge UnlearningZesheng Shi, Yucheng Zhou, Jing Li, Yuxin Jin et al.ACL 2025 · 8 citations
- Small Changes, Big Impact: How Manipulating a Few Neurons Can Drastically Alter LLM AggressionJaewook Lee, Junseo Jang, Oh-Woog Kwon, Harksoo KimACL 2025
- Gaining Wisdom from Setbacks: Aligning Large Language Models via Mistake AnalysisKai Chen, Chunwei Wang, Kuo Yang, Jianhua Han et al.ICLR 2024 · 47 citations
