UIT-ISE-NLP at SemEval-2021 Task 5: Toxic Spans Detection with BiLSTM-CRF and ToxicBERT Comment Classification

Son T. Luu, Ngan NguyenACL 2021

TL;DR

This paper tackles the challenging task of identifying specific toxic words (spans) within longer social media posts, going beyond simple post-level toxicity classification. The authors propose a hybrid model combining a BiLSTM-CRF for span detection with ToxicBERT for overall comment classification, achieving a respectable 62.23% F1-score on the SemEval-2021 Task 5 dataset.

What Problem Does This Paper Address?

Social media platforms are rife with toxic content, making moderation a critical but labor-intensive task. While classifying an entire post as toxic or not is a common approach, it often misses the nuance of where the toxicity lies. Identifying specific toxic words or phrases (spans) within a post is crucial for moderators to understand the severity and context of the toxicity, enabling more targeted interventions. The SemEval-2021 Task 5 specifically addresses this by providing a dataset for "Toxic Spans Detection," aiming to pinpoint these toxic segments within lengthy comments.

Methods

The authors employ a two-pronged approach:

  • Toxic Span Detection: A BiLSTM-CRF (Bidirectional Long Short-Term Memory with Conditional Random Field) model is used. This is a standard deep learning architecture for sequence labeling tasks like Named Entity Recognition (NER), which is analogous to identifying toxic spans. The BiLSTM captures contextual information from both directions of the text, while the CRF layer helps to ensure the predicted sequence of labels is valid.
  • Comment Classification: ToxicBERT, a pre-trained transformer model specifically designed for toxicity classification, is used to determine if the overall post is toxic or not.

The system integrates these two components. The BiLSTM-CRF first identifies potential toxic spans. Then, ToxicBERT classifies the entire post. If ToxicBERT deems the post non-toxic, the output is an empty span. Otherwise, it retains the spans identified by the BiLSTM-CRF. Before feeding text into these models, words are encoded using GloVe embeddings, and texts are pre-processed (tokenized and lowercased).

Datasets

The primary dataset used is from SemEval-2021 Task 5: Toxic Spans Detection. This dataset includes training and test sets, each containing post content and character index spans denoting toxic words. The paper also references other datasets for toxic speech detection, including both flat and hierarchical label datasets, and mentions shared tasks like SemEval-2019 Task 5 and 6, PolEval 2019, GermEval 2018, EVALITA 2019, and VLSP 2019.

Key Insights and Ideas

  • Hybrid Approach Synergy: Combining a dedicated span detection model (BiLSTM-CRF) with a powerful post-level classifier (ToxicBERT) appears to be more effective than using either alone for this specific task. The BiLSTM-CRF excels at pinpointing the toxic words, while ToxicBERT provides a strong overall toxicity signal that can refine the final output.
  • Importance of Span Granularity: The paper highlights that simply classifying a post as toxic isn't enough. Identifying the exact toxic words is a more granular and useful task for practical moderation.
  • Challenges with Multi-Word Spans: The error analysis suggests that the model struggles with spans containing more than two words, indicating a potential area for improvement.

Key Results

The proposed model achieved an F1-score of 62.23% on the SemEval-2021 Task 5 test set. When only the BiLSTM-CRF was used, the F1-score was 61.32%, showing a modest but positive improvement with the addition of ToxicBERT. This result placed their system 63rd out of 92 teams in the competition.

Limitations and Future Work

The authors acknowledge several limitations:

  • Multi-Word Span Difficulty: The model performs less well on spans containing more than two words.
  • Empty Spans: While the ToxicBERT classifier helps in predicting non-toxic posts and thus empty spans, the overall number of empty toxic span comments in the test set was not very high, limiting the impact of this refinement.

For future work, the authors suggest:

  • Attention Mechanisms: Incorporating attention mechanisms into the detection model to better focus on relevant parts of the text.
  • Character-Level Representation: Exploring character-level representations (e.g., using models like CharBERT) in conjunction with word-level representations to potentially improve robustness and handle out-of-vocabulary words or misspellings.

Summary updated

BibTeX
@inproceedings{luu2021uit,
  author = {Son T. Luu and Ngan Nguyen},
  title = {{UIT-ISE-NLP at SemEval-2021 Task 5: Toxic Spans Detection with BiLSTM-CRF and ToxicBERT Comment Classification}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
}
Figure