completed Jan 2023 - May 2024

Unmasking Hate: An Integrated Approach to Detecting Hate Speech in Social Media

#NLP #Hate Speech Detection #Contrastive Learning #Emotion Analysis #Author Profiling #Social Media
Unmasking Hate: An Integrated Approach to Detecting Hate Speech in Social Media

Overview

The freedom of communication offered by social media has led to an increasing prevalence of hate speech, fuelling cyber conflicts that affect individuals and society. The state-of-the-art Dual Contrastive Learning (DCL) framework for hate speech detection relies primarily on fine-tuning a pre-trained BERT model to capture contextual semantics, which may not be sufficient given the evolving nature of hate speech and the complex emotions embedded in it.

This project, AiLERT, proposes an integrated approach that extends DCL along three directions. First, the general BERT encoder is replaced with domain-suited, fine-tuned language models, BERTweet, RoBERTa and the time-aware TimeLMs, which are trained with self-supervised and supervised contrastive losses combined with focal loss. Second, an emotion model produces an eleven-dimensional emotion vector for each tweet. Third, author profiling contributes stylistic and linguistic features, such as readability, lexical diversity, part-of-speech patterns, hashtags and emojis, together with Big Five personality traits inferred from the text. These representations are concatenated and passed to a feed-forward classifier. Experiments were run on the SemEval-2019 Task 5 (HatEval), Davidson and Unified datasets, with Optuna and Neptune.ai used for hyperparameter tuning and experiment tracking, and feature-importance analysis of the emotion features. To address the severe class imbalance in the Davidson dataset, the team also investigated back-translation through six languages as a data augmentation strategy.

Motivation & Objectives

The rise of hate speech in the digital age poses a major threat to societal values and norms. Motivated by the urgent need to create a safer and more inclusive online environment, the project pursued four research objectives:

Enhanced Detection Accuracy – Improve hate speech detection within the DCL framework by using fine-tuned embeddings for context-aware accuracy.

Emotion Modeling – Integrate emotional context recognition into the DCL framework to further improve detection accuracy.

Author Profiling – Use personality detection and user writing-style features to better understand authors and context, further improving the DCL framework.

Scalable Platform – Transform the AI algorithm into a practical, cloud-deployable platform for combating hate speech online.

Impact & Results

Performance

On the HatEval dataset, every fine-tuned encoder surpassed the BERT-base DCL baseline (77.94% accuracy, 77.74% macro F1), with BERTweet reaching 80.10% accuracy and 79.97% macro F1. Adding emotion features improved all models, with TimeLMs + Emotion achieving 81.20% accuracy and 81.09% macro F1, and TimeLMs + Author profiling reached 81.39% accuracy and 81.28% macro F1. The best combined DCL + Emotion + Author configuration achieved 81.28% accuracy and 81.21% macro F1 on HatEval (versus 77.94%/77.74%) and 76.48% on the Unified dataset (versus a 74.59% baseline). On the highly imbalanced Davidson dataset, gains were less consistent, and random over- and down-sampling reduced performance. Back-translation proved more effective: with RoBERTa embeddings and an SVC classifier, augmenting the hate class with tweets back-translated from Chinese, French, German, Japanese, Portuguese and Romanian raised macro F1 from 54.45 to 58.40 for Portuguese alone and to 61.50 (+7.05 points) when all languages were combined.

Key Contributions

Extended DCL Framework

An enhanced Dual Contrastive Learning pipeline integrating BERTweet, RoBERTa and TimeLMs encoders with emotion vectors and author profiling features, showing that emotions such as anger, joy, fear, anticipation and sadness all play significant roles in hate speech detection.

Back-Translation Augmentation

A back-translation approach that generates new hate speech instances through six languages to mitigate class imbalance in the Davidson dataset, with the augmented datasets made publicly available.

Deployed Detection Tool

A Gradio application on Hugging Face Spaces that classifies input text as hate or non-hate with confidence scores and reports the detected emotions and predicted personality characteristics.

Real-world Impact

The work demonstrates that considering emotional context and author characteristics alongside contextual embeddings leads to more accurate hate speech detection, and that back-translation is a practical remedy for the class imbalance common in hate speech datasets. The open code, experiment datasets and accessible web deployment allow non-technical users and researchers to apply and build on the framework in efforts to combat online hate speech. The research was co-supervised by Prof. Damminda Alahakoon and Dr. Nisansa de Silva, with co-authors from the Research Centre for Data Analytics and Cognition at La Trobe University, Australia.

Gallery

Thushalya Weerasuriya presenting the project poster

Thushalya Weerasuriya presenting the project poster

Pasan Kalansooriya at the final year poster presentation

Pasan Kalansooriya at the final year poster presentation

Project Poster - Unmasking Hate: An Integrated Approach to Detecting Hate Speech in Social Media

Project Poster - Unmasking Hate: An Integrated Approach to Detecting Hate Speech in Social Media

Final classifier combining emotion vectors, author profiling features and fine-tuned sentence embeddings

Final classifier combining emotion vectors, author profiling features and fine-tuned sentence embeddings

Project Team

K

Krishan Chavinda

Undergraduate Researcher

First author of the ICCCI 2024 paper; maintains the project's experiment code for the extended DCL framework.

P

Pasan Kalansooriya

Undergraduate Researcher

First author of the RepL4NLP 2024 back-translation paper; maintains the project's public code and paper repository.

T

Thushalya Weerasuriya

Undergraduate Researcher

Co-author of both project papers, contributing to the integrated hate speech detection framework and data augmentation study.

Awards & Recognition

Publication at ICCCI 2024

The integrated hate speech detection framework was published at the International Conference on Computational Collective Intelligence (ICCCI) 2024

“Unmasking Hate: An Integrated Approach to Detecting Hate Speech in Social Media”

Krishan Chavinda, Pasan Kalansooriya, Thushalya Weerasuriya, Damminda Alahakoon, Nisansa de Silva, Uthayasanker Thayasivam, Kogul Srikandabala, Kirishnni Prabagar

International Conference on Computational Collective Intelligence (ICCCI 2024)

Publication at RepL4NLP 2024

The back-translation approach for mitigating data imbalance was published at the Workshop on Representation Learning for NLP (RepL4NLP) 2024

“Mitigating Data Imbalance in Hate Speech Detection: A Back Translation Approach”

Pasan Kalansooriya, Thushalya Weerasuriya, Krishan Chavinda, Damminda Alahakoon, Nisansa de Silva, Uthayasanker Thayasivam, Kirishnni Prabagar, Srikandabala Kogul

Workshop on Representation Learning for NLP (RepL4NLP 2024)