Proceedings

Detoxifying Large Language Models via Localized Feature Editing with Sparse Autoencoders

Download BibTeX Cite

Proceedings of the Thirty-Fifth International Joint Conference on Artificial Intelligence. Main Track. Pages 735-743.

https://doi.org/10.24963/ijcai.2026/83

Abstract

Large Language Models (LLMs) powerful generative capabilities also pose significant risks, underscoring the need for effective detoxification methods to ensure safer deployment. Due to the polysemantic nature of LLM neurons, recent neuron intervention methods inevitably entangle unrelated concepts, compromising generation quality and interpretability. Sparse Autoencoders (SAEs) have opened new horizons for decomposing model activations into monosemantic features, offering interpretability and targeted feature-level steering. Empirical findings reveal that, despite capturing interpretable features, indiscriminate interventions on toxicity-related features expose the fragility of LLMs, achieving toxicity mitigation at the cost of degraded fluency. Building upon this finding, we propose DeLFE, a lightweight controlled detoxification approach that identifies specific toxic features across model layers and performs targeted interventions on them. DeLFE learns toxicity subspaces from label-guided SAE feature subsets to characterize toxic v.s. non-toxic activation patterns. When auto-completing a response token-by-token, DeLFE tracks the toxicity-triggering risks and steers toxic features away from the subspace via a flow-matching feature transformation. We further design three feature-level strategies that adjust intervention timing and strength to reconstruct the target model’s original activations. Extensive experiments demonstrate that our method achieves strong detoxification effectiveness while maintaining high generation quality across models of varying sizes and diverse base LLMs.

  1. [Bloom et al., 2024] Joseph Bloom, Curt Tigges, Anthony Duong, and David Chanin. Saelens. https://github.com/ decoderesearch/SAELens, 2024. Link
  2. [Brown et al., 2020] Tom Brown, Benjamin Mann, Nick Ry- der, Melanie Subbiah, Jared D Kaplan, Prafulla Dhari- wal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing sys- tems, 33:1877-1901, 2020.
  3. [Chen et al., 2018] Ricky TQ Chen, Yulia Rubanova, Jesse Bettencourt, and David K Duvenaud. Neural ordinary dif- ferential equations. Advances in neural information pro- cessing systems, 31, 2018.
  4. [Cunningham et al., 2023] Hoagy Cunningham, Aidan Ewart, Logan Riggs, Robert Huben, and Lee Sharkey. Sparse autoencoders find highly interpretable features in language models. arXiv preprint arXiv:2309.08600, 2023.
  5. [Dale et al., 2021] David Dale, Anton Voronov, Daryna De- mentieva, Varvara Logacheva, Olga Kozlova, Nikita Se- menov, and Alexander Panchenko. Text detoxification us- ing large pre-trained neural models. In Proceedings of the 2021 Conference on Empirical Methods in Natural Lan- guage Processing, pages 7979-7996, 2021.
  6. [Feng et al., 2024] Zijian Feng, Hanzhang Zhou, Kezhi Mao, and Zixiao Zhu. Freectrl: Constructing control centers with feedforward layers for learning-free controllable text generation. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 7627-7640, 2024.
  7. [Gao et al., 2024] Leo Gao, Tom Dupré la Tour, Henk Tillman, Gabriel Goh, Rajan Troll, Alec Radford, Ilya Sutskever, Jan Leike, and Jeffrey Wu. Scaling and evaluating sparse autoencoders. arXiv preprint arXiv:2406.04093, 2024.
  8. [Gehman et al., 2020] Samuel Gehman, Suchin Gururangan, Maarten Sap, Yejin Choi, and Noah A Smith. Realtoxic- ityprompts: Evaluating neural toxic degeneration in lan- guage models. In Findings of the Association for Compu- tational Linguistics: EMNLP 2020, 2020.
  9. [Goyal et al., 2025] Agam Goyal, Vedant Rathi, William Yeh, Yian Wang, Yuen Chen, and Hari Sundaram. Break- ing bad tokens: Detoxification of llms using sparse autoen- coders. In Proceedings of the 2025 Conference on Empiri- cal Methods in Natural Language Processing. Association for Computational Linguistics, 2025.
  10. [Hendrycks et al., 2021] Dan Hendrycks, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn Song, and Jacob Steinhardt. Measuring massive multitask lan- guage understanding. In International Conference on Learning Representations, 2021.
  11. [Kissane et al., 2024] Connor Kissane, Robert Krzyzanowski, Joseph Isaac Bloom, Arthur Conmy, and Neel Nanda. Interpreting attention layer outputs with sparse autoencoders. arXiv preprint arXiv:2406.17759, 2024.
  12. [Klein and Nabi, 2025] Tassilo Klein and Moin Nabi. Con- trastive perplexity for controlled generation: An applica- tion in detoxifying large language models. In Proceedings of the 63rd Annual Meeting of the Association for Compu- tational Linguistics, pages 2493-2508, 2025.
  13. [Ko et al., 2025] Ching-Yun Ko, Pin-Yu Chen, Payel Das, Youssef Mroueh, Soham Dan, Georgios Kollias, Subhajit Chaudhury, Tejaswini Pedapati, and Luca Daniel. Large language models can become strong self-detoxifiers. In The Thirteenth International Conference on Learning Rep- resentations, 2025.
  14. [Kwak et al., 2023] Jin Myung Kwak, Minseon Kim, and Sung Ju Hwang. Language detoxification with attribute- discriminative latent space. In 61st Annual Meeting of the Association for Computational Linguistics, ACL 2023, pages 10149-10171. Association for Computational Lin- guistics (ACL), 2023.
  15. [Leong et al., 2023] Chak Tou Leong, Yi Cheng, Jiashuo Wang, Jian Wang, and Wenjie Li. Self-detoxifying lan- guage models via toxification reversal. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pages 4433-4449, 2023.
  16. [Liang et al., 2024] Xun Liang, Hanyu Wang, Shichao Song, Mengting Hu, Xunzhi Wang, Zhiyu Li, Feiyu Xiong, and Bo Tang. Controlled text generation for large language model with dynamic attribute graphs. In Findings of the Association for Computational Linguistics ACL 2024, pages 5797-5814, 2024.
  17. [Lieberum et al., 2024] Tom Lieberum, Senthooran Raja- manoharan, Arthur Conmy, Lewis Smith, Nicolas Son- nerat, Vikrant Varma, János Kramár, Anca Dragan, Rohin Shah, and Neel Nanda. Gemma scope: Open sparse au- toencoders everywhere all at once on gemma 2. In Pro- ceedings of the 7th BlackboxNLP Workshop: Analyzing and Interpreting Neural Networks for NLP, pages 278- 300, 2024.
  18. [Lin, 2023] Johnny Lin. Neuronpedia: Interactive reference and tooling for analyzing neural networks, 2023. Software available from neuronpedia.org.
  19. [Liu et al., 2021] Alisa Liu, Maarten Sap, Ximing Lu, Swabha Swayamdipta, Chandra Bhagavatula, Noah A Smith, and Yejin Choi. Dexperts: Decoding-time con- trolled text generation with experts and anti-experts. In Proceedings of the 59th Annual Meeting of the Associa- tion for Computational Linguistics and the 11th Interna- tional Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 6691-6706, 2021.
  20. [Logacheva et al., 2022] Varvara Logacheva, Daryna De- mentieva, Sergey Ustyantsev, Daniil Moskovskiy, David Dale, Irina Krotova, Nikita Semenov, and Alexander Panchenko. Paradetox: Detoxification with parallel data. In Proceedings of the 60th Annual Meeting of the Associ- ation for Computational Linguistics (Volume 1: Long Pa- pers), pages 6804-6818, 2022.
  21. [Lu et al., 2022] Ximing Lu, Sean Welleck, Jack Hessel, Liwei Jiang, Lianhui Qin, Peter West, Prithviraj Am- manabrolu, and Yejin Choi. Quark: Controllable text gen- eration with reinforced unlearning. Advances in neural information processing systems, 35:27591-27609, 2022.
  22. [Lu et al., 2025] Huimin Lu, Masaru Isonuma, Junichiro Mori, and Ichiro Sakata. Unidetox: Universal detoxifica- tion of large language models via dataset distillation. arXiv preprint arXiv:2504.20500, 2025.
  23. [Marks et al., 2024] Samuel Marks, Can Rager, Eric J Michaud, Yonatan Belinkov, David Bau, and Aaron Mueller. Sparse feature circuits: Discovering and edit- ing interpretable causal graphs in language models. arXiv preprint arXiv:2403.19647, 2024.
  24. [O'Brien et al., 2024] Kyle O'Brien, David Majercak, Xavier Fernandes, Richard Edgar, Blake Bullwinkel, Jingya Chen, Harsha Nori, Dean Carignan, Eric Horvitz, and Forough Poursabzi-Sangdeh. Steering language model refusal with sparse autoencoders. arXiv preprint arXiv:2411.11296, 2024.
  25. [Ren et al., 2025] Yimeng Ren, Yanhua Yu, Lizi Liao, Yuhu Shang, Kangkang Lu, and Mingliang Yan. R2dqg: A qual- ity meets diversity framework for question generation over knowledge bases. 2025. IJCAI
  26. [Shang et al., 2026] Yuhu Shang, Xiang Cheng, Yimeng Ren, Huijia Wu, Xuexiong Luo, Kangkang Lu, Jian Zhao, and Zhaofeng He. From chaos to cure: A prefix heuristics guided model-agnostic adaptive detoxification framework. In Proceedings of the AAAI Conference on Artificial Intel- ligence, volume 40, pages 32902-32910, 2026.
  27. [Suau et al., 2024] Xavier Suau, Pieter Delobelle, Katherine Metcalf, Armand Joulin, Nicholas Apostoloff, Luca Zap- pella, and Pau Rodríguez. Whispering experts: neural in- terventions for toxicity mitigation in language models. In Proceedings of the 41st International Conference on Ma- chine Learning, pages 46843-46867, 2024.
  28. [Tang et al., 2024] Zecheng Tang, Keyan Zhou, Juntao Li, Yuyang Ding, Pinzheng Wang, Yan Bowen, Renjie Hua, and Min Zhang. Cmd: a framework for context-aware model self-detoxification. In Proceedings of the 2024 Con- ference on Empirical Methods in Natural Language Pro- cessing, pages 1930-1949, 2024.
  29. [Uppaal et al., 2024] Rheeya Uppaal, Apratim Dey, Yiting He, Yiqiao Zhong, and Junjie Hu. Model editing as a ro- bust and denoised variant of dpo: A case study on toxicity. In Neurips Safe Generative AI Workshop 2024, 2024.
  30. [Wang et al., 2024] Mengru Wang, Ningyu Zhang, Ziwen Xu, Zekun Xi, Shumin Deng, Yunzhi Yao, Qishen Zhang, Linyi Yang, Jindong Wang, and Huajun Chen. Detoxify- ing large language models via knowledge editing. In Pro- ceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 3093-3118, 2024.
  31. [Wang et al., 2025] Dianyun Wang, Qingsen Ma, Yuhu Shang, Zhifeng Lu, Zhenbo Xu, Lechen Ning, Huijia Wu, and Zhaofeng He. Interpretable safety alignment via sae- constructed low-rank subspace adaptation. arXiv preprint arXiv:2512.23260, 2025.
  32. [Xiao et al., 2025] Yisong Xiao, Aishan Liu, Siyuan Liang, Zonghao Ying, Xianglong Liu, and Dacheng Tao. Detox- ifying large language models via autoregressive reward guided representation editing. In Advances in Neural In- formation Processing Systems, 2025.
  33. [Yang et al., 2026] Haocheng Yang, Xiang Cheng, Chenhao Sun, Pengfei Zhang, and Sen Su. Privsv: Differentially private steering vector for large language models. In Pro- ceedings of the AAAI Conference on Artificial Intelligence, volume 40, pages 34241-34249, 2026.
  34. [Yi et al., 2025] Xin Yi, Linlin Wang, Xiaoling Wang, and Liang He. Fine-grained detoxification framework via instance-level prefixes for large language models. Neu- rocomputing, 611:128684, 2025.
  35. [Yidou-Weng et al., 2025] Gwen Yidou-Weng, Benjie Wang, and Guy Van den Broeck. Trace back from the future: A probabilistic reasoning approach to control- lable language generation. In Proceedings of the 42nd International Conference on Machine Learning, 2025.
  36. [Zhang and Song, 2022] Hanqing Zhang and Dawei Song. Discup: Discriminator cooperative unlikelihood prompt- tuning for controllable text generation. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 3392-3406, 2022.
  37. [Zhang et al., 2025] Hanyu Zhang, Xiting Wang, Chengao Li, Xiang Ao, and Qing He. Controlling large language models through concept activation vectors. In Proceed- ings of the AAAI Conference on Artificial Intelligence, vol- ume 39, pages 25851-25859, 2025.
  38. [Zhao et al., 2025] Ying Zhao, Yuanzhao Guo, Xuemeng Weng, Yuan Tian, Wei Wang, and Yi Chang. Detoxify- ing large language models via the diversity of toxic sam- ples. In Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, pages 5869- 5882, 2025.

References were extracted automatically from the PDF and may contain errors.

Welcome Future Conferences AI Journal Division IJCAI Proceedings About IJCAI IJCAI Awards