A Feature Extraction based Model for Hate Speech Identification

Salar Mohtaj, Vera Schmitt, Sebastian MöllerarXiv 2022

TL;DR

This paper evaluates recurrent neural networks (LSTMs) and BERT-based transfer learning approaches for identifying online hate speech and offensive content in English tweets. The authors demonstrate that using BERT as a frozen feature extractor combined with a Gated Recurrent Unit (GRU) classifier outperforms standard end-to-end BERT fine-tuning and traditional LSTM architectures, achieving a top macro F1-score of 0.86.

What Problem Does This Paper Address?

Hate speech and offensive language on social media platforms can cause significant psychological harm to marginalized groups and even manipulate political campaigns. Automatically detecting this content is a major challenge due to the informal, anonymous, and rapidly evolving nature of social media text—where users frequently employ slang, emojis, and intentional misspellings to bypass basic filters.

While a large portion of natural language processing (NLP) research focuses exclusively on English, the Hate Speech and Offensive Content Identification (HASOC) track at FIRE 2021 provides a benchmark for multilingual evaluation. This paper details the TU Berlin team's approach to the HASOC 2021 English dataset, tackling both binary classification (Hate/Offensive vs. Non-Offensive) and fine-grained classification (distinguishing between Hate, Offensive, and Profane content).

Methods

The authors compared traditional deep learning architectures against modern transformer-based transfer learning approaches:

  1. Data Pre-processing: To clean the noisy Twitter data, the authors replaced user mentions with the token username, converted emojis into short text descriptions, replaced URLs with link, and collapsed multiple white spaces into a single space.
  2. LSTM-based Models: The team built two types of Long Short-Term Memory networks: a character-level LSTM (designed to catch subtle word alterations and typos) and a deeper word-level LSTM utilizing pre-trained GloVe embeddings.
  3. BERT Fine-Tuning: They performed standard end-to-end fine-tuning on an English BERT-base model.
  4. BERT Feature Extraction: Instead of updating the transformer's weights, they used frozen BERT models (both base and large variants) to extract contextualized token embeddings. These static vectors were then fed into a downstream Gated Recurrent Unit (GRU) network. The authors experimented with various hidden dimensions and dropout rates to optimize the GRU classifier.

Datasets

The models were trained and evaluated on the official HASOC 2021 English dataset, which consists of annotated Twitter posts:

  • Training Set: 3,843 total instances. For internal validation, the authors split this into 70% training, 10% validation, and 20% testing.
  • Subtask 1A Labels: 2,501 Hate and Offensive (HOF) posts vs. 1,342 Non-Hate-Offensive (NOT) posts.
  • Subtask 1B Labels: A fine-grained breakdown consisting of 683 Hate (HATE), 622 Offensive (OFFN), 1,196 Profane (PRFN), and 1,342 None (NONE).
  • Test Set: 1,281 tweets used for final competition submission.
Dataset Statistics

Key Insights and Ideas

  • Feature Extraction Beats Fine-Tuning: Surprisingly, keeping the BERT layers frozen and using them strictly for feature extraction paired with a GRU classifier yielded a higher F1-score (0.86) than full end-to-end BERT fine-tuning (0.83). For smaller datasets, training a lightweight recurrent layer on top of robust, frozen embeddings can mitigate overfitting better than updating millions of transformer parameters.
  • The Nuance of Pre-processing: Text normalization (cleaning emojis, links, and mentions) consistently boosted performance for the LSTMs and the feature-extracted BERT models. However, raw text actually performed slightly better during direct BERT fine-tuning, indicating that the fine-tuning process can inherently map raw social media artifacts effectively if given the chance.
  • Word Context Over Character Nuance: Word-level LSTMs comfortably outperformed character-level LSTMs (0.83 vs 0.79 F1). This suggests that broad semantic context matters more for identifying hate speech than catching character-level obfuscations or typos.

Key Results

The performance of the models on Subtask 1A was measured using the macro F1-score:

  • BERT Feature Extraction: Achieved the top performance of 0.86 using a BERT-base model configuration with a GRU hidden dimension of 256, a dropout rate of 0.25, and pre-processed text.
Table 4 The achieved results by the BERT feature extraction based model for the sub-task 1A
  • Word-level LSTM: Reached an F1-score of 0.83 using 300-dimension embeddings and a hidden dimension of 256.
  • BERT Fine-Tuning: Reached an F1-score of 0.83, but notably only when utilizing unprocessed raw text.
  • Character-level LSTM: Maxed out at an F1-score of 0.79.

Limitations and Future Work

The primary challenge identified by the authors was overfitting, a common issue given the relatively small size of the training dataset (under 4,000 samples).

To address this in future iterations, the authors plan to explore data augmentation strategies, specifically enriching the training set with data samples from external social media resources. Additionally, they aim to benchmark their feature-extraction methodology against massive generative large language models like GPT-3 to determine if scale alone provides a significant advantage in toxic text classification.

Summary updated

BibTeX
@misc{mohtaj2022feature,
  author = {Salar Mohtaj and Vera Schmitt and Sebastian Möller},
  title = {{A Feature Extraction based Model for Hate Speech Identification}},
  year = {2022},
  eprint = {2201.04227},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2201.04227},
}
Figure