From the Detection of Toxic Spans in Online Discussions to the Analysis of Toxic-to-Civil Transfer

John Pavlopoulos, Leo Laugier, Alexandros Xenos, Jeffrey Sorensen, Ion AndroutsopoulosACL 2022

Abstract: John Pavlopoulos, Leo Laugier, Alexandros Xenos, Jeffrey Sorensen, Ion Androutsopoulos. Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).

2022.

TL;DR

This research shifts the focus of content moderation from labeling entire posts as "toxic" to identifying specific "toxic spans"—the exact words or phrases that cause offense. By introducing the TOXICSPANS dataset and evaluating various sequence-labeling and attention-based models, the authors demonstrate how fine-grained detection can improve both automated moderation and the evaluation of systems designed to "detoxify" text.

What Problem Does This Paper Address?

Most toxicity detection systems act as "black boxes": they tell you a post is toxic but don't explain why. For a human moderator dealing with a 500-word comment, a simple "toxic" label isn't very helpful. They need to know which specific parts are the problem.

Furthermore, there is a growing interest in "toxic-to-civil transfer"—AI that rephrases rude comments into polite ones. However, evaluating these systems is tricky. Standard metrics like "Accuracy" (is the new version non-toxic?) or "Perplexity" (is it fluent?) don't measure whether the model actually addressed the specific offensive parts of the original text. This paper bridges the gap between detecting specific toxic snippets and evaluating how well we can remove them.

Datasets and the TOXICSPANS Task

The core contribution is the TOXICSPANS dataset, consisting of 11,035 English posts from the Civil Comments collection. Each post was annotated by multiple crowdworkers who highlighted the specific spans making the text toxic. This allows for a character-based evaluation of toxicity detection.

Examples of toxic span annotations in the TOXICSPANS dataset, showing character offsets and corresponding text.

In addition to the span detection data, the authors utilized Parallel (P) and Non-Parallel (NP) transfer datasets to evaluate "detoxification" models. The Parallel dataset contains 2,778 pairs of toxic posts and their human-written civil rephrasings.

Methods

The authors explore two primary technical approaches for detecting toxic spans:

  1. Supervised Sequence Labeling: These models treat the task like Named Entity Recognition (NER). They are trained to tag each token as "toxic" or "non-toxic." The authors tested several architectures, including CNNs, BiLSTMs, and Transformer-based models like BERT and SPAN-BERT.
  2. Weakly Supervised Learning (Rationale Extraction): This approach uses a binary classifier (toxic vs. non-toxic) trained on a massive dataset. At inference time, the model's attention mechanism is used to extract the tokens the model "paid the most attention to" when deciding a post was toxic.

To evaluate these, they used a character-based F1 score, measuring the overlap between predicted toxic character offsets and human ground truth.

Key Results and Insights

Performance comparison of sequence labeling and attention-based models for toxic span detection.
  • Top Performer: SPAN-BERT-SEQ achieved the highest performance with an F1 score of 63.0%, as shown in the comparative results above.
  • Context is King: Simple lookup-based methods performed poorly. Toxicity is often context-dependent; sequence labeling models, which "read" the surrounding text, performed significantly better.
  • Attention is a Strong Proxy: Attention-based models (like BiLSTM+ARE) performed surprisingly well—nearly matching supervised models—despite never being shown a "gold" toxic span during training. This suggests we can leverage millions of existing post-level labels to build span detectors.
  • The Challenge of Implicit Toxicity: Some posts are toxic because of their message (e.g., sarcasm or dehumanizing tropes) rather than specific "bad words." In these cases, there are no spans to highlight, representing a fundamental limit for span-based detection.
  • Evaluating Detoxification: By applying their span detector to the output of detoxification models (like T5), the authors created new metrics (ACC2, ACC3, ACC4) that specifically measure if the "poisonous" parts of the original sentence were actually removed or replaced.

Limitations and Future Work

The authors acknowledge that their current dataset is limited to English and focuses primarily on "explicit" toxicity. Future work is needed to handle implicit toxicity and to expand the dataset to other languages. Additionally, they suggest that future moderation pipelines should be two-stage: first, a fast classifier to flag toxic posts, followed by a span detector to assist human moderators in the final decision.

Summary updated

BibTeX
@inproceedings{pavlopoulos2022from,
  author = {John Pavlopoulos and Leo Laugier and Alexandros Xenos and Jeffrey Sorensen and Ion Androutsopoulos},
  title = {{From the Detection of Toxic Spans in Online Discussions to the Analysis of Toxic-to-Civil Transfer}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  url = {https://openreview.net/forum?id=3SdKQsZgs5},
}
Figure