Beyond words: a hybrid transformer-ensemble approach for detecting hate speech and offensive language on social media
Saved in:
| Title: | Beyond words: a hybrid transformer-ensemble approach for detecting hate speech and offensive language on social media |
|---|---|
| Authors: | Uzair Iftikhar, Syed Farooq Ali, Ghulam Mustafa, Nurhidayah Bahar, Kashif Ishaq |
| Source: | PeerJ Computer Science, Vol 11, p e3214 (2025) |
| Publisher Information: | PeerJ Inc., 2025. |
| Publication Year: | 2025 |
| Collection: | LCC:Electronic computers. Computer science |
| Subject Terms: | Hate speech, Offensive language, Sentiment analysis, Social media, Text classification, Electronic computers. Computer science, QA75.5-76.95 |
| Description: | Over the past decade, there has been an increase in hateful content on social media platforms, specifically in tweets. Hence, it brings a challenge to identify and classify tweets containing racism, discrimination, offense, toxicity, or abuse. This article proposes a novel hybrid approach that combines the power of Transformer-based language modeling with ensemble learning to classify offensive, toxic, and hateful tweets. Specifically, the robustly optimized bidirectional encoder representations from Transformers pretraining approach (RoBERTa)-large model is employed for feature extraction, followed by a hyperparameter-tuned extreme gradient boosting (XGBoost) classifier for final classification. The approach was evaluated on three widely used datasets ToxicTweets, Davidson, and HateSpeechDetection and compared against state-of-the-art methods, including deep architectures such as convolutional neural network (CNN), bidirectional encoder representations from Transformers (BERT), and AngryBERT; transformer models including DistilBERT, RoBERTa, A Lite BERT (ALBERT), and efficiently learning an encoder that classifies token replacements accurately (ELECTRA); and logistic regression. The experimental results demonstrate that the proposed hybrid model significantly outperforms existing approaches in terms of accuracy, precision, recall, and F1-score, achieving the highest accuracy of 97% on the HateSpeechDetection dataset and 92.42% on the Davidson dataset. Furthermore, the approach was compared with other ensemble methods, including Adaptive Boosting (AdaBoost), random forest, support vector classifier (SVC), light gradient boosting machine (LightGBM), and bagging, to highlight its superior performance. This study suggests that integrating RoBERTa-large with XGBoost is an effective approach for hate speech detection and provides a robust solution to the increasing problem of online hate and toxicity. |
| Document Type: | article |
| File Description: | electronic resource |
| Language: | English |
| ISSN: | 2376-5992 |
| Relation: | https://peerj.com/articles/cs-3214.pdf; https://peerj.com/articles/cs-3214/; https://doaj.org/toc/2376-5992 |
| DOI: | 10.7717/peerj-cs.3214 |
| Access URL: | https://doaj.org/article/d16bfe0899e34dfda34b7e89a1dbbfd7 |
| Accession Number: | edsdoj.16bfe0899e34dfda34b7e89a1dbbfd7 |
| Database: | Directory of Open Access Journals |
| Abstract: | Over the past decade, there has been an increase in hateful content on social media platforms, specifically in tweets. Hence, it brings a challenge to identify and classify tweets containing racism, discrimination, offense, toxicity, or abuse. This article proposes a novel hybrid approach that combines the power of Transformer-based language modeling with ensemble learning to classify offensive, toxic, and hateful tweets. Specifically, the robustly optimized bidirectional encoder representations from Transformers pretraining approach (RoBERTa)-large model is employed for feature extraction, followed by a hyperparameter-tuned extreme gradient boosting (XGBoost) classifier for final classification. The approach was evaluated on three widely used datasets ToxicTweets, Davidson, and HateSpeechDetection and compared against state-of-the-art methods, including deep architectures such as convolutional neural network (CNN), bidirectional encoder representations from Transformers (BERT), and AngryBERT; transformer models including DistilBERT, RoBERTa, A Lite BERT (ALBERT), and efficiently learning an encoder that classifies token replacements accurately (ELECTRA); and logistic regression. The experimental results demonstrate that the proposed hybrid model significantly outperforms existing approaches in terms of accuracy, precision, recall, and F1-score, achieving the highest accuracy of 97% on the HateSpeechDetection dataset and 92.42% on the Davidson dataset. Furthermore, the approach was compared with other ensemble methods, including Adaptive Boosting (AdaBoost), random forest, support vector classifier (SVC), light gradient boosting machine (LightGBM), and bagging, to highlight its superior performance. This study suggests that integrating RoBERTa-large with XGBoost is an effective approach for hate speech detection and provides a robust solution to the increasing problem of online hate and toxicity. |
|---|---|
| ISSN: | 23765992 |
| DOI: | 10.7717/peerj-cs.3214 |
Full Text Finder
Nájsť tento článok vo Web of Science