Civil Rephrases Of Toxic Texts With Self-Supervised Transformers

Léo Laugier, John Pavlopoulos, Jeffrey Sorensen, Lucas Dixon

Abstract

Online platforms face a persistent challenge in managing toxic behavior. While traditional moderation tools often rely on punitive measures like flagging or deletion, they fail to guide users toward more constructive communication. This paper introduces CAE-T5, an unsupervised transformer-based model that automatically suggests civil rephrasings for toxic comments. By leveraging self-supervised learning, the model learns to neutralize toxicity while preserving the original message's meaning without requiring expensive, human-annotated parallel datasets.

Introduction

The primary obstacle in training models for text style transfer—specifically from toxic to civil—is the lack of "parallel datasets" containing pairs of toxic sentences and their exact civil equivalents. Collecting such data is prohibitively expensive and slow. CAE-T5 addresses this by performing unsupervised text style transfer, utilizing non-parallel data (separate corpora of toxic and civil comments) to learn the transformation.

Methodology

CAE-T5 (Conditional Auto-Encoder Text-to-Text Transfer Transformer) is built upon the pre-trained T5 architecture. It employs two primary self-supervised training objectives to learn without parallel examples:

  1. Denoising Auto-Encoder (DAE) Loss: The model is trained to reconstruct original sentences from intentionally corrupted versions (e.g., with masked words). This ensures the generation of fluent, natural language.
  2. Cycle-Consistency (CC) Loss: To preserve meaning, the model performs a "round trip": it translates a toxic sentence into a civil one, then attempts to translate it back to the original toxic form. Failure to reconstruct the original meaning results in a penalty, forcing the model to keep the core message intact while only altering the toxicity attribute.

Control codes (e.g., toxic: or civil:) are used to direct the decoder toward the target style during generation.

Experimental Setup

The model was evaluated using two primary datasets:

  • Civil Comments: A dataset of ~2 million public comments from news sites, processed into sentence-level pairs for training.
  • Yelp Review Dataset: A standard benchmark for style transfer (positive vs. negative sentiment) used to compare CAE-T5 against existing state-of-the-art systems.

Key Insights and Qualitative Analysis

A significant finding is the power of pre-training; starting with T5's broad language knowledge allows CAE-T5 to handle complex nuances better than previous RNN-based models. The researchers observed that the model successfully separates semantic meaning from the toxicity attribute.

Examples of toxic inputs and their civil rephrasings generated by CAE-T5, illustrating context-aware neutralization.

One notable example is the model's rephrasing of "dubya was a moron" to "dubya was a republican." While not a literal synonym, the model identified "republican" as a non-offensive category for the subject within its training context, demonstrating a sophisticated understanding of social and political descriptors.

Key Results

CAE-T5 demonstrated superior performance over previous unsupervised models on the Civil Comments dataset across several automated metrics:

  • Fluency: It achieved a lower Perplexity (PPL), indicating more human-like text generation.
  • Content Preservation: It maintained a higher Sentence Similarity (SIM) score compared to baselines.
  • Robustness: Using the Geometric Mean (GM) of all metrics, CAE-T5 proved to be the most stable model, balancing civility with semantic accuracy.
Automatic evaluation results on the Civil Comments dataset comparing CAE-T5 against various baselines in accuracy, perplexity, and similarity.

In human evaluations, CAE-T5's rephrasings were rated as successful (fluent, civil, and content-preserving) 13% of the time. While seemingly low, this is more than double the success rate of the next best baseline (6%).

Limitations and Future Work

Despite its success, CAE-T5 exhibits several failure modes:

  • Hallucination: The model occasionally adds details not present in the source text.
  • Position Reversal: It may accidentally flip the author's intent (e.g., turning criticism into praise) to achieve civility.
  • Semantic Drift: Meaning preservation remains difficult for longer, more complex sentences.

Future research will explore Non-Autoregressive (NAR) generation for increased speed and more robust attribute classifiers to mitigate the introduction of unintended biases during the detoxification process.

Summary updated

BibTeX
@inproceedings{laugier2021civil,
  author = {Léo Laugier and John Pavlopoulos and Jeffrey Sorensen and Lucas Dixon},
  title = {{Civil Rephrases Of Toxic Texts With Self-Supervised Transformers}},
  booktitle = {EACL},
  year = {2021},
  doi = {10.18653/v1/2021.eacl-main.124},
}
Figure