Detoxifying Large Language Models via Localized Feature Editing with Sparse Autoencoders
Yuhu Shang, Xiang Cheng, Dianyun Wang, Yimeng Ren, Xuexiong Luo, Hang Yang, Huijia Wu, Zhaofeng He
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.
BibTeX
@inproceedings{ijcai2026_detoxifyinglarge,
title = {Detoxifying Large Language Models via Localized Feature Editing with Sparse Autoencoders},
author = {Yuhu Shang and Xiang Cheng and Dianyun Wang and Yimeng Ren and Xuexiong Luo and Hang Yang and Huijia Wu and Zhaofeng He},
booktitle = {IJCAI 2026},
year = {2026}
}