ToxCCIn: Toxic Content Classification with Interpretability

Tong Xiang, Sean MacAvaney, Eugene Yang, Nazli Goharian

Abstract

Despite the recent successes of transformer-based models in terms of effectiveness on a variety of tasks, their decisions often remain opaque to humans. Explanations are particularly important for tasks like offensive language or toxicity detection on social media because a manual appeal process is often in place to dispute automatically flagged content. In this work, we propose a technique to improve the interpretability of these models, based on a simple and powerful assumption: a post is at least as toxic as its most toxic span. We incorporate this assumption into transformer models by scoring a post based on the maximum toxicity of its spans and augmenting the training process to identify correct spans. We find this approach effective and can produce explanations that exceed the quality of those provided by Logistic Regression analysis (often regarded as a highly-interpretable model), according to a human study.

Introduction

While Transformer models like BERT have set new benchmarks in offensive language detection, they function largely as "black boxes." When content is flagged, the lack of transparency complicates the appeal process for users and moderators. Standard approaches rely on a single summary token (the [CLS] token), which offers no insight into the specific triggers for a classification. Conversely, older models like Logistic Regression are transparent but lack contextual awareness, often leading to false positives for words used in non-toxic contexts. ToxCCIn bridges this gap by combining the performance of Transformers with the "point-to-the-problem" interpretability of simpler models.

Methodology

The core of ToxCCIn is the assumption that a post is at least as toxic as its most toxic span. This is implemented through a multi-task learning framework:

  1. Architecture: Instead of relying solely on the [CLS] token, a linear layer is added on top of every token in the sequence.
  2. Max-Pooling: The final toxicity score for the entire post is determined by the maximum score among all individual tokens. This "max-pooling" operation ensures that the most offensive word or phrase dictates the final judgment.
  3. Multi-Task Training: The model is trained simultaneously on sequence classification (is the post toxic?) and span detection (which specific words are toxic?).
ToxCCIn architecture using max-pooling over token scores to determine toxicity.

By forcing the model to identify a "most toxic span," the architecture inherently provides a justification for its decision, highlighting the specific words that triggered the flag.

Datasets and Evaluation

The researchers utilized several datasets, including the Civil Comment Dataset (CCD) for large-scale training and the Toxic Spans Detection Dataset (TSDD) for fine-tuning span identification. To ensure robustness against adversarial examples, a Curated CCD was created, mixing clear-cut cases with ambiguous ones where toxic words appear in neutral contexts.

Key Results

The multi-task approach not only improves interpretability but also enhances detection accuracy. On the Curated CCD dataset, the ELECTRA-MT model achieved a Macro-F1 score of 0.893, significantly outperforming the standard ELECTRA-CLS baseline of 0.787.

Performance comparison of ToxCCIn models (MT) against various baselines.

Beyond raw metrics, a human preference study revealed that users preferred ToxCCIn’s explanations 53.7% of the time, compared to only 24.0% for Logistic Regression. This suggests that the contextual awareness of Transformers allows them to identify the intent of toxicity more accurately than word-weight-based models.

Conclusion

ToxCCIn demonstrates that interpretability does not have to come at the cost of performance. By leveraging the "most toxic span" assumption, the model provides human-readable explanations while maintaining state-of-the-art accuracy. Future work will focus on addressing implicit toxicity—such as sarcasm or dog whistles—where the offensive nature of a post is not tied to a single identifiable span.

Summary updated

BibTeX
@inproceedings{xiang2021toxccin,
  author = {Tong Xiang and Sean MacAvaney and Eugene Yang and Nazli Goharian},
  title = {{ToxCCIn: Toxic Content Classification with Interpretability}},
  booktitle = {WASSA@EACL},
  year = {2021},
  url = {https://openreview.net/forum?id=cu8RlouJgIS},
}
Figure