Skip to main content
QUICK REVIEW

[Paper Review] Contextual Hate Speech Detection in Code Mixed Text using Transformer Based Approaches

Ravindra Nayak, Raviraj Joshi|arXiv (Cornell University)|Oct 18, 2021
Hate Speech and Cyberbullying DetectionComputer Science13 citations
TL;DR

This paper proposes a dual-encoder transformer-based approach using multilingual BERT and Indic-BERT for contextual hate speech detection in code-mixed English-Hindi (Hinglish) tweets. By separately encoding context and target tweets, averaging their [CLS] embeddings, and combining with a static offensive word dictionary and model ensembling, the method achieves a new state-of-the-art F1 score of 73.07% on the HASOC 2021 ICHCL dataset.

ABSTRACT

In the recent past, social media platforms have helped people in connecting and communicating to a wider audience. But this has also led to a drastic increase in cyberbullying. It is essential to detect and curb hate speech to keep the sanity of social media platforms. Also, code mixed text containing more than one language is frequently used on these platforms. We, therefore, propose automated techniques for hate speech detection in code mixed text from scraped Twitter. We specifically focus on code mixed English-Hindi text and transformer-based approaches. While regular approaches analyze the text independently, we also make use of content text in the form of parent tweets. We try to evaluate the performances of multilingual BERT and Indic-BERT in single-encoder and dual-encoder settings. The first approach is to concatenate the target text and context text using a separator token and get a single representation from the BERT model. The second approach encodes the two texts independently using a dual BERT encoder and the corresponding representations are averaged. We show that the dual-encoder approach using independent representations yields better performance. We also employ simple ensemble methods to further improve the performance. Using these methods we report the best F1 score of 73.07% on the HASOC 2021 ICHCL code mixed data set.

Motivation & Objective

  • To address the challenge of detecting hate speech in code-mixed social media content, particularly Hinglish (English-Hindi) text on Twitter.
  • To improve detection performance by incorporating contextual information from parent tweets, which may not be evident from isolated replies.
  • To evaluate the effectiveness of multilingual BERT and Indic-BERT in low-resource, multilingual hate speech detection scenarios.
  • To investigate whether frozen embeddings and static offensive word dictionaries enhance model generalization and performance.
  • To achieve state-of-the-art performance on the HASOC 2021 ICHCL benchmark for code-mixed hate speech detection.

Proposed method

  • The model uses a dual-encoder architecture where context and target tweet texts are encoded separately using BERT, producing individual [CLS] token embeddings.
  • The [CLS] embeddings from context and target tweets are averaged to form a joint sentence representation for classification.
  • A single-encoder baseline is used for comparison, where context and target texts are concatenated with a separator token and processed as one input sequence.
  • The embedding layers of m-BERT and Indic-BERT are frozen during fine-tuning to preserve pre-trained representations and reduce overfitting.
  • A static dictionary of offensive words is used as a deterministic filter to improve detection, with no data leakage from training or test sets.
  • Ensemble methods combine predictions from top-performing models—specifically, averaging predictions from Indic-BERT and m-BERT in dual-encoder and single-encoder configurations.

Experimental results

Research questions

  • RQ1Does incorporating contextual information from parent tweets improve hate speech detection performance in code-mixed Hinglish text?
  • RQ2How do single-encoder and dual-encoder BERT architectures compare in classifying hate speech in conversational threads?
  • RQ3Does freezing BERT embeddings improve performance on low-resource, code-mixed hate speech detection tasks?
  • RQ4To what extent does integrating a static offensive word dictionary enhance model performance without data leakage?
  • RQ5Can ensemble learning of multiple BERT-based models further improve F1 score beyond individual models?

Key findings

  • The dual-encoder approach, which averages [CLS] embeddings from context and target tweets, outperforms the single-encoder method that concatenates both texts.
  • Freezing the embedding layers of m-BERT and Indic-BERT led to improved generalization, with the best F1 score of 73.07% achieved using this strategy.
  • The Indic-BERT model with frozen embeddings, dual-encoder setup, and dictionary integration achieved an F1 score of 70.37%, outperforming the m-BERT baseline of 65.53%.
  • Incorporating a static offensive word dictionary improved F1 scores across all configurations, with the highest gain observed in the dual-encoder setup.
  • The ensemble of four models—Indic-BERT and m-BERT in both dual-encoder and single-encoder modes—achieved the best overall F1 score of 73.07%.
  • Confusion matrices confirmed that the ensemble model reduced misclassification of non-hateful content, especially in contextually ambiguous cases.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.