cs.LGFeb 24, 2026

Detoxifying LLMs via Representation Erasure-Based Preference Optimization

Authors: Nazanin Mohammadi Sepahvand, Eleni Triantafillou, Hugo Larochelle, Doina Precup, Daniel M. Roy, Gintare Karolina Dziugaite

Organizations: McGill University, Canada · Mila, Canada · Google DeepMind · University of Toronto, Canada · 

Abstract

Large language models (LLMs) trained on webscale data can produce toxic outputs, raising concerns for safe deployment. Prior defenses, based on applications of DPO, NPO, and similar algorithms, reduce the likelihood of harmful continuations, but not robustly so: they are vulnerable to adversarial prompting and easily undone by fine-tuning-based relearning attacks. Indeed, research has shown that these edits to the model are superficial: linear probing reveals that harmful "directions" remain present in representations. To address this, we propose Representation Erasure-based Preference Optimization (REPO), reformulating detoxification as a token-level preference problem. Using a novel objective with preference data, we force the representations of toxic continuations to converge toward their benign counterparts. Our mechanistic analysis reveals that this granular approach is critical: unlike baselines, REPO induces deep, localized edits to toxicity-encoding neurons while preserving general model utility. Exhaustive evaluations show that REPO achieves state-of-the-art robustness, stopping sophisticated threats-including relearning attacks and enhanced GCG jailbreaks-where existing representation- and output-based methods fail.

Figures & tables

Appendix figures & tables5 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Detoxification for LLM: From Dataset Itself

    Apr 21, 2026Wei Shao, Yihang Wang, Gaoyu Zhu +4Training Data CurationLLM Safety

  2. CausalDetox: Causal Head Selection and Intervention for Language Model Detoxification

    Apr 16, 2026Yian Wang, Yuen Chen, Agam Goyal +1Causal Reasoning in Language ModelsLLM Safety

  3. Model Unlearning Objectives Vary for Distinct Language Functions

    May 26, 2026Berk Atil, Vipul Gupta, Rebecca J. PassonneauLLM SafetyMachine Unlearning