Civil Rephrases Of Toxic Texts With Self-Supervised Transformers

Leo Laugier, John Pavlopoulos, Jeffrey Sorensen, Lucas Dixon

TL;DR

Researchers have developed CAE-T5, a self-supervised transformer model designed to rewrite toxic online comments into civil ones while preserving their original meaning. By leveraging a combination of denoising and cycle-consistency losses, the model outperforms existing unsupervised style-transfer baselines in fluency and content preservation, offering a potential path toward real-time "civil rephrasing" suggestions for users.

What Problem Does This Paper Address?

Online platforms currently rely heavily on automated moderation to flag or delete toxic comments. However, this "delete-first" approach provides no constructive feedback to the author. Ideally, a system could nudge users toward healthier conversations by suggesting civil alternatives to vituperative comments before they are posted.

The technical challenge is that high-quality, parallel datasets—where each toxic comment is paired with a human-written civil rephrasing—are incredibly expensive and difficult to collect. Most existing toxicity datasets are "unpaired," meaning they contain labels for toxicity but no "gold standard" rewrites. This paper tackles the problem of unsupervised text attribute transfer: learning to flip the "toxic" switch to "civil" without ever seeing a direct example of how to do so.

Methods

The authors introduce CAE-T5 (Conditional Auto-Encoder T5), which builds upon the pre-trained T5 (Text-to-Text Transfer Transformer) architecture. The core innovation lies in how they fine-tune this model using two self-supervised objectives:

  1. Denoising Auto-Encoder (DAE) Loss: The model is trained to reconstruct a sentence that has been corrupted (e.g., by masking tokens) given its original attribute (toxic or civil). This teaches the model fluency and basic reconstruction.
  2. Cycle-Consistency (CC) Loss: Borrowed from computer vision (like CycleGAN), this objective ensures content preservation. The model translates a sentence from toxic to civil, then attempts to translate that generated civil version back to the original toxic sentence. If the meaning is lost during the first step, the second step becomes impossible, penalizing the model.

Architecturally, the authors made a specific tweak: they removed the standard cross-attention between the encoder and decoder. Instead, they use a compressed latent representation ($z$) summed into the decoder's embeddings. This prevents the model from simply copying the input text and forces it to rely on the destination attribute code (e.g., "civil: ") to generate the output.

Examples of offensive sentences and their civil rephrasings generated by CAE-T5.

Datasets

The study utilizes two primary datasets:

  • Civil Comments: The largest toxicity detection dataset to date (approx. 2M comments). The authors processed this into a sentence-level version, selecting highly polar examples (toxicity scores > 0.9 for the toxic set and < 0.1 for the civil set).
  • Yelp Review Dataset: A standard benchmark for sentiment transfer (positive vs. negative reviews), used here to compare CAE-T5 against a wide array of existing style-transfer models.

Key Insights and Ideas

  • Fluency vs. Accuracy Trade-off: Many previous models achieved high "accuracy" (successfully removing toxic words) but produced gibberish or used placeholders (e.g., replacing a slur with "big"). CAE-T5 prioritizes fluency, often producing text that is more natural than human-written rephrasings in the dataset.
  • The "Un-rephrasable" Problem: The authors discovered that roughly 83% of toxic comments in their sample were deemed "impossible to rewrite" by human annotators because they were pure insults, threats, or identity attacks with no constructive core to preserve.
  • Geometric Mean for Evaluation: To prevent "gaming" the metrics, the authors used the geometric mean (GM) of Accuracy, Fluency (measured by perplexity), and Semantic Similarity. This ensures that a model must perform well across all dimensions to be ranked highly.

Key Results

CAE-T5 demonstrated significant improvements over baselines like StyleTransformer (ST) and CrossAlignment (CA).

  • Quantitative Performance: On the Civil Comments dataset, CAE-T5 achieved a Geometric Mean of 0.466, significantly higher than the next best baseline, IE (BERT) at 0.401.
  • Human Evaluation: In blind tests, human annotators rated CAE-T5's rephrasings as "successful" (high scores in attribute transfer, fluency, and content) 13% of the time, more than double the success rate of the baselines (5-6%).
Table showing CAE-T5 outperforming baselines in Geometric Mean (GM) on the Civil Comments dataset.

Limitations and Future Work

Despite the progress, the authors identify three major failure modes:

  1. Hallucination (34%): The model sometimes generates fluent but entirely unrelated content.
  2. Supererogation (17%): The model adds unnecessary, though related, information.
  3. Position Reversal: The model occasionally flips the user's opinion (e.g., turning a political disagreement into an agreement) rather than just making the disagreement polite.
Examples of valid rewritings and highlighted flaws like position reversal and hallucination.

Future research will focus on Non-Autoregressive (NAR) generation to improve decoding speed and exploring continuous token representations to allow for more flexible integration of attribute classifiers during training. The authors also warn about the potential misuse of such models to add toxicity to civil text.

Summary updated

BibTeX
@inproceedings{laugier2021civil,
  author = {Leo 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