YoungSheldon at SemEval-2021 Task 5: Fine-tuning Pre-trained Language Models for Toxic Spans Detection using Token classification Objective

Mayukh Sharma, Ilanthenral Kandasamy, W.b. VasanthaACL 2021

TL;DR

This paper tackles the challenge of pinpointing toxic language within sentences, going beyond simple classification to identify the exact "toxic spans." The authors fine-tuned various pre-trained language models (PLMs) for this token classification task, achieving a strong F1 score of 0.6841 with RoBERTa and securing 16th place on the SemEval-2021 leaderboard.

What Problem Does This Paper Address?

The internet has become a double-edged sword: a powerful communication tool that also hosts a significant amount of toxic content and hate speech. While previous research has focused on classifying entire texts as toxic or non-toxic, this approach is insufficient for effective moderation. Manually sifting through vast amounts of online content to identify and remove harmful language is not only time-consuming but also emotionally taxing for human moderators. SemEval-2021 Task 5 specifically addresses this gap by aiming to identify the precise spans of text within a sentence that constitute toxic language. This allows for more granular and efficient moderation, saving time and reducing the burden on human annotators.

Methods

The core of the proposed system is a token classification approach. The authors frame the problem as identifying individual words within a sentence that are toxic. To achieve this, they leverage Pre-trained Language Models (PLMs), which have learned general language understanding from massive text corpora. The process involves:

  1. Fine-tuning PLMs: Several popular PLMs, including BERT, ELECTRA, RoBERTa, XLM-RoBERTa, T5, XLNet, and MPNet, were fine-tuned. This involves adding a classification layer on top of the PLM's learned features for each word.
  2. Tokenization and Labeling: Sentences were tokenized, and then each token was labeled as either toxic or non-toxic. A key detail is that when a word was broken down into sub-words by the tokenizer, only the first sub-word was used for classification, while others were masked during loss computation. This strategy aimed to leverage the full contextual information from all sub-words.
  3. Span Reconstruction: After identifying individual toxic words, their character offsets were used to reconstruct the toxic spans within the original sentence.
  4. Masked Loss: A binary cross-entropy loss was used, with a specific masking strategy to handle sub-word tokenization, ensuring that only relevant tokens contributed to the loss calculation.

Datasets

The study utilized the dataset provided for SemEval-2021 Task 5: Toxic Spans Detection. This dataset consists of sentences with character offsets indicating the toxic spans. The paper notes that the dataset was in English and provides statistics on the distribution of samples with varying numbers of toxic words, highlighting that samples with 1-3 toxic words were most common. It also points out that the test set had a significantly higher proportion of samples with no toxic words compared to the training and development sets.

Key Insights and Ideas

  • Token Classification is Effective for Span Detection: Framing toxic span detection as a token classification problem proved to be a viable approach, allowing models to identify individual toxic words that constitute a span.
  • PLMs are Powerful for this Task: The study demonstrates that fine-tuning various PLMs can yield strong performance on toxic span detection, with only minor variations between different models.
  • The Challenge of "No Toxic Spans": A significant insight is that while models excel at identifying toxic spans when they exist, they struggle with sentences that contain no toxic content. This is attributed to the token classification objective, which doesn't inherently decide if a sentence needs toxic span prediction.
  • Stopwords Can Be Misleading: The analysis revealed that common stopwords (like "the," "a," "of") can be identified as toxic words, even though they are not inherently toxic. This can occur when they are part of a multi-word toxic span or when the model misinterprets their context, especially in cases of sarcasm or humor.

Key Results

  • The best performing model, RoBERTa, achieved an F1 score of 0.6841 on the test set.
  • This performance secured the system a rank of 16 on the official SemEval-2021 leaderboard.
  • The study found that models performed significantly better on samples containing one or more toxic words (achieving a perfect F1 score on 66.06% of them) compared to samples with no toxic words (correctly classified only 6.09% of the time).
  • The analysis identified common words that were incorrectly predicted as toxic in samples with no actual toxic spans, suggesting a need for more nuanced contextual understanding.

Limitations and Future Work

The authors acknowledge a key limitation: their word-level classifier, while effective at identifying toxic words, struggles to efficiently handle sentences that contain no toxic spans. They propose future work to address this by incorporating a classifier that can first predict whether a sentence is toxic or non-toxic, in addition to identifying the specific spans. This would allow the model to avoid unnecessary span detection efforts for non-toxic content.

Summary updated

BibTeX
@inproceedings{sharma2021youngsheldon,
  author = {Mayukh Sharma and Ilanthenral Kandasamy and W.B. Vasantha},
  title = {{YoungSheldon at SemEval-2021 Task 5: Fine-tuning Pre-trained Language Models for Toxic Spans Detection using Token classification Objective}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
}
Figure