DiffuDetox: A Mixed Diffusion Model for Text Detoxification

Griffin Floto, Mohammad Mahdi Abdollah Pour, Parsa Farinneya, Zhenwei Tang, Ali Pesaranghader, Manasa Bharadwaj, Scott Sanner

Abstract

Text detoxification aims to remove offensive language from text while preserving its original semantic meaning and linguistic fluency. This task is often hindered by the scarcity of high-quality parallel datasets. We present DiffuDetox, a mixed diffusion model that leverages both conditional and unconditional training strategies. By incorporating a "conditional gate" and classifier-free guidance, DiffuDetox effectively learns from limited parallel data while maintaining high fluency through exposure to massive non-parallel corpora. Our results demonstrate that DiffuDetox achieves a J-score of 0.67, outperforming state-of-the-art baselines and even human-written references.

1. Introduction

Online toxicity remains a pervasive challenge for digital communication. Automated text detoxification offers a solution by rewriting toxic sentences into neutral equivalents. An effective detoxification model must satisfy three primary criteria: toxicity reduction, content preservation, and grammatical fluency.

While Large Language Models (LLMs) are commonly used for this task, they often suffer from limited generative diversity, converging on a narrow set of "safe" outputs. Diffusion models, which have seen significant success in image generation, offer superior diversity. However, they typically require vast amounts of data to achieve high fluency. In the context of detoxification, parallel "toxic-to-clean" datasets are often several orders of magnitude smaller than those used in machine translation, leading standard diffusion models to produce ungrammatical results.

2. Methodology: The Mixed Diffusion Approach

DiffuDetox addresses the data scarcity problem through a "mixed" training strategy that decouples the learning of detoxification from the learning of general language fluency.

The DiffuDetox architecture featuring a conditional gate that toggles between conditional and unconditional diffusion processes.

2.1 Conditional and Unconditional Components

The model consists of two primary modes of operation:

  • Conditional Model: Trained on the ParaDetox dataset, this component learns the specific mapping required to transform toxic inputs into clean outputs.
  • Unconditional Model: To ensure fluency, the model is also trained to reconstruct general, non-toxic text without any specific condition. This allows the model to leverage massive, non-parallel corpora such as BookCorpus, WikiAuto, and MNLI.

2.2 The Conditional Gate and Guidance

During training, a "conditional gate" randomly toggles the model between these two modes. During the inference (sampling) phase, DiffuDetox employs classifier-free guidance for text. By combining the outputs of the conditional and unconditional components, the model "pushes" the generation toward the detoxification signal while remaining anchored by the unconditional fluency signal. This results in text that is both clean and highly readable.

3. Experimental Setup

The performance of DiffuDetox was evaluated using the ParaDetox dataset, which contains approximately 20,000 human-annotated pairs. To bolster fluency, the unconditional component was trained on a combined corpus of BookCorpus, WikiAuto, and MNLI, providing a diverse range of grammatical structures.

4. Results and Discussion

We compared DiffuDetox against several state-of-the-art baselines, including ParaDetox (a fine-tuned BART model), CondBERT, and DLSM.

Quantitative comparison of DiffuDetox against various baselines across multiple metrics including the composite J-score.

4.1 Quantitative Performance

As shown in the table above, DiffuDetox achieved a composite J-score of 0.67, surpassing the strongest baseline (0.62) and the human reference score (0.66). The model maintained a high style accuracy (STA) of 0.92, indicating successful toxicity removal in the vast majority of cases.

4.2 The Role of Unconditional Training

Ablation studies confirmed the importance of the mixed training strategy. Removing the unconditional component led to a significant drop in fluency (FL) scores. The inclusion of the unconditional signal was the key factor that allowed the diffusion model to exceed human-level performance.

4.3 Generative Diversity

Unlike traditional Transformer-based models, DiffuDetox's diffusion-based architecture allows for the generation of a wide array of detoxified candidates. This diversity is a significant advantage, enabling the selection of the most contextually appropriate rewrite.

5. Conclusion and Future Work

DiffuDetox demonstrates that mixed diffusion models can overcome the limitations of small parallel datasets in text detoxification. By balancing conditional signals with unconditional fluency, the model achieves state-of-the-art results.

However, several areas for future improvement remain. The iterative nature of diffusion models makes inference slower than one-shot models like BART. Additionally, the diversity of the output is sensitive to the guidance weight ($w$), creating a trade-off between detoxification strength and creative variety. Future research may explore more efficient sampling methods or architectures that work natively with discrete language tokens rather than continuous embeddings.

Summary updated

BibTeX
@inproceedings{floto2023diffudetox,
  author = {Griffin Floto and Mohammad Mahdi Abdollah Pour and Parsa Farinneya and Zhenwei Tang and Ali Pesaranghader and Manasa Bharadwaj and Scott Sanner},
  title = {{DiffuDetox: A Mixed Diffusion Model for Text Detoxification}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.478},
}
Figure