Leveraging Transformers for Hate Speech Detection in Conversational Code-Mixed Tweets

Zaki Mustafa Farooqi, Sreyan Ghosh, Rajiv Ratn Shah

Introduction: The Challenge of Context and Code-Mixing

Hate speech detection on social media is often treated as a task of classifying isolated comments. However, real-world interactions are inherently conversational. A seemingly neutral statement can become offensive depending on the context of the preceding discussion. This challenge is particularly acute in multilingual societies like India, where users frequently employ "Hinglish"—a code-mixed blend of Hindi and English often written in the Roman alphabet.

Standard monolingual classifiers struggle with the phonetic variations and "noisy" nature of Romanized Hindi. Furthermore, they often miss implicit hate that only emerges through the relationship between a parent tweet and its replies. Researchers from IIIT-Delhi addressed these issues in the HASOC 2021 competition, focusing on identifying Hate and Offensive (HOF) content within multi-turn conversation chains.

A conversational chain where context determines the offensiveness of a reply.

Methodology: Contextual Ensembles

The proposed system leverages an ensemble of three state-of-the-art Transformer models: Indic-BERT, Multilingual BERT (mBERT), and XLM-RoBERTa (XLM-R). The core innovation lies in a data pipeline designed to capture conversational context and bridge the script gap.

The Pipeline

  1. Contextual Concatenation: Instead of analyzing individual tweets, the system concatenates the parent tweet, comments, and replies into a single sequence, separated by a special [SENSEP] token. This allows the model's self-attention mechanism to process the entire dialogue history simultaneously.
  2. Transliteration: To align the Romanized Hindi tweets with the Devanagari script used in pre-training many multilingual models, the authors utilized the AI4Bharat library for transliteration.
  3. Ensembling: The final classification is determined by combining the outputs of the three models using either Hard Voting (majority rule) or Soft Voting (summing probability scores).
The proposed model architecture, featuring contextual concatenation, transliteration, and ensemble voting.

Key Results and Insights

The MIDAS-IIITD team secured first place in the HASOC 2021 Subtask 2. Their Hard Voting Ensemble achieved a Macro F1 score of 0.7253, significantly outperforming standalone models like Indic-BERT, which managed an F1 of 0.6811.

The study highlighted several critical findings:

  • Contextual Awareness: Flattening conversations into a single input string successfully enables Transformers to detect implicit hate by attending to cues in the parent tweet.
  • Script Alignment: Transliterating Romanized text back to Devanagari is a vital preprocessing step for multilingual models pre-trained on native scripts.
  • Ensemble Stability: The ensemble approach effectively "smoothed out" errors. While individual models like Indic-BERT had high misclassification rates for non-hateful (NOT) content, the majority-voting mechanism corrected many of these false positives.

Limitations and Future Directions

While successful, the authors noted that removing hashtags and emojis during preprocessing might discard valuable emotional signals. Future work could involve more sophisticated hierarchical architectures to model conversation structures more naturally than simple concatenation. Additionally, incorporating author profiling—understanding a user's historical behavior—could further improve the detection of subtle, implicit hate speech.

Summary updated

BibTeX
@inproceedings{farooqi2021leveraging,
  author = {Zaki Mustafa Farooqi and Sreyan Ghosh and Rajiv Ratn Shah},
  title = {{Leveraging Transformers for Hate Speech Detection in Conversational Code-Mixed Tweets}},
  booktitle = {FIRE (Working Notes)},
  year = {2021},
  url = {https://openreview.net/forum?id=tta9S4t1Wq},
}
Figure