HLE-UPC at SemEval-2021 Task 5: Multi-Depth DistilBERT for Toxic Spans Detection

Rafel Palliser-Sans, Albert Rial-FarràsACL 2021

TL;DR

This paper tackles the challenging task of identifying toxic spans within text, going beyond simple word-level toxicity. They propose a novel multi-depth DistilBERT approach that leverages information from multiple layers of the transformer model, significantly improving performance. Their method achieved a strong F1-score, ranking them among the top teams in the SemEval-2021 competition.

What Problem Does This Paper Address?

Online communication has become ubiquitous, making the moderation of toxic content crucial for fostering healthy digital environments. However, detecting toxicity is complex because it's often subjective and can manifest not just in individual offensive words but also in entire phrases or expressions. Traditional approaches often treat this as a document-level classification problem or focus on single words. This paper addresses the need for a more nuanced approach that can pinpoint the exact "toxic spans" (sequences of characters or words) within a text, recognizing that toxicity can be context-dependent and spread across multiple words.

Methods

The core of the HLE-UPC team's approach is a modification of the DistilBERT model, a smaller, faster version of BERT. Instead of using only the final layer's output for token classification (predicting whether each token is toxic or not), they employ a "multi-depth" strategy. This involves concatenating the hidden state outputs from multiple transformer blocks (layers) of DistilBERT. This combined representation is then fed into a classification layer to make the final toxicity prediction. This allows the model to capture richer, context-aware representations of words by considering information from various stages of the model's processing.

They also implemented a data cleaning pipeline to address inconsistencies in the dataset's annotations, such as including whitespace or single characters as toxic spans. This cleaning process aimed to ensure that toxic spans more accurately reflected complete words or phrases.

Datasets

The primary dataset used is the Toxic Spans Detection (TSD) dataset, provided by the SemEval-2021 Task 5 organizers. This dataset consists of phrases and comments, with annotations marking the specific character indices considered toxic. The dataset is split into trial, train, and test sets. The authors also mention using pre-trained models (BERT and DistilBERT) which were trained on large, diverse corpora, though the specifics of these pre-training datasets are not detailed in this paper.

Key Insights and Ideas

  • Multi-depth representations are key: The paper strongly suggests that combining information from multiple layers of a transformer model significantly boosts performance in toxic span detection, outperforming models that rely on a single layer.
  • Context is king: Toxicity is not always explicit. The model's ability to capture context from different layers helps it identify toxicity in expressions where individual words might not be inherently offensive.
  • Data cleaning matters: Addressing inconsistencies in the ground truth annotations (e.g., marking whitespace as toxic) is crucial for building robust models and improving performance.
  • Smaller models can be powerful: DistilBERT, a distilled version of BERT, proved to be a strong contender, and when combined with the multi-depth approach, it achieved excellent results, even outperforming its larger BERT counterpart in some configurations.

Key Results

The HLE-UPC team's ensemble of three multi-depth DistilBERT models achieved an F1-score of 68.54% on the test set, ranking them 14th out of 91 participating teams. This was only 2.29% below the best-performing model.

Qualitative analysis revealed that their model was highly capable of identifying toxic and offensive words, both individually and in multi-word expressions. However, it also showed some limitations, such as missing context-dependent toxicity or misidentifying toxicity when it wasn't annotated. A significant finding was the potential for racial bias in the model's predictions, likely stemming from biases present in the training data. The model was observed to identify "black" as toxic but not "white" in comparative examples, and "immigrants" as toxic only when paired with "Mexican" but not "American."

Limitations and Future Work

The authors acknowledge the presence of racial bias in their model's predictions, which they attribute to biases in the dataset and potentially the pre-training data of BERT models. They suggest that debiasing techniques from the literature could be applied to alleviate this issue.

Future work could involve exploring more advanced ensemble strategies, further investigating the optimal combination of layers for multi-depth models, and developing more robust methods for handling context-dependent toxicity and annotation inconsistencies. Addressing the identified biases is also a critical area for future research.

Summary updated

BibTeX
@inproceedings{pallisersans2021hle,
  author = {Rafel Palliser-Sans and Albert Rial-Farràs},
  title = {{HLE-UPC at SemEval-2021 Task 5: Multi-Depth DistilBERT for Toxic Spans Detection}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
}
Figure