journal article·2025-08-31Open access

Adversarially Robust Multitask Learning for Offensive and Hate Speech Detection in Arabic Text Using Transformer-Based Models and RNN Architectures

Eman S. Alshahrani, Mehmet S. Aksoy

Applied Sciences· Volume 15· Issue 17

Abstract

Offensive language and hate speech have a detrimental effect on victims and have become a significant problem on social media platforms. Recent research has developed automated techniques for detecting Arabic offensive language and hate speech but remains limited, and further research is required compared to the research on high-resource languages such as English due to limited resources, annotated corpora, and morphological analysis. Most social media users who use profanities attempt to modify their text while maintaining the same meaning, thereby deceiving detection methods that forbid offending phrases. Therefore, this study proposes an adversarially robust multitask learning framework for detection of Arabic offensive and hate speech. For this purpose, this study used the OSACT2020 dataset, augmented with additional posts collected from the X social media platform. To improve contextual understanding, classification models based on various configurations were constructed using four pre-trained Arabic language models integrated with various sequential layers that were trained and evaluated in three different settings: single-task learning with the original dataset, single-task learning with the augmented dataset, and multitask learning with the augmented dataset. The multitask MARBERTv2+BiGRU model achieved the best results, with an 88% macro-F1 for hate speech and 93% for offensive language on clean data. To improve the model’s robustness, adversarial samples were generated using attacks on both the character and sentence levels. These attacks subtly change the text to mislead the model while maintaining the overall appearance and meaning. The clean model’s performance dropped significantly under attack, especially for hate speech, to a 74% macro-F1; however, adversarial training, which re-trains the model using both clean and adversarial data, improved the results to a 78% macro-F1 for hate speech. Further improvements were achieved with input transformation techniques, boosting the macro-F1 to 81%. Notably, the adversarially trained model maintained high performance on clean data, demonstrating both robustness and generalization.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Hate Speech and Cyberbullying Detection · Adversarial Robustness in Machine Learning

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

Department of Information Systems, Faculty of Computer and Information Sciences, King Saud University, Riyadh 11543, Saudi Arabia

References (59)

Show source-provided references
1. Chen, Y., Zhou, Y., Zhu, S., and Xu, H. (2012, January 3–5). Detecting offensive language in social media to protect adolescent online safety. Proceedings of the 2012 International Conference on Privacy, Security, Risk and Trust and 2012 International Confernece on Social Computing, Amsterdam, The Netherlands.10.1109/SocialCom-PASSAT.2012.55 ↗
2. Shende, S.B., and Deshpande, L. (2017, January 3–5). A computational framework for detecting offensive language with support vector machine in social communities. Proceedings of the 2017 8th International Conference on Computing, Communication and Networking Technologies (ICCCNT), Delhi, India.10.1109/ICCCNT.2017.8204020 ↗
3. Arabic Offensive and Hate Speech Detection Using a Cross-Corpora Multi-Task Learning Model10.3390/informatics8040069 ↗
4. Vogel, I., and Regev, R. (2019, January 9–11). FraunhoferSIT at GermEval 2019: Can Machines Distinguish Between Offensive Language and Hate Speech? Towards a Fine-Grained Classification. Proceedings of the 15th Conference on Natural Language Processing (KONVENS 2019), KONVENS, Erlangen, Germany. Available online: https://www.researchgate.net/profile/Inna-Vogel-2/publication/336373536_FraunhoferSIT_at_GermEval_2019_Can_Machines_Distinguish_Between_Offensive_Language_and_Hate_Speech_Towards_a_Fine-Grained_Classification/links/5d9eb6c292851cce3c910f74/FraunhoferSIT-at-GermEval-2019-Can-Machines-Distinguish-Between-Offensive-Language-and-Hate-Speech-Towards-a-Fine-Grained-Classification.pdf.
5. Haddad, B., Orabe, Z., Al-Abood, A., and Ghneim, N. (2020, January 11–16). Arabic Offensive Language Detection with Attention-based Deep Neural Networks. Proceedings of the 4th Workshop on Open-Source Arabic Corpora and Processing Tools, with a Shared Task on Offensive Language Detection, Marseille, France.
6. Alshalan, R., and Al-Khalifa, H. (2020). A Deep Learning Approach for Automatic Hate Speech Detection in the Saudi Twittersphere. Appl. Sci., 10.10.3390/app10238614 ↗
7. Wiedemann, G., Ruppert, E., Jindal, R., and Biemann, C. (2018). Transfer learning from lda to bilstm-cnn for offensive language detection in twitter. arXiv.
8. Zampieri, M., Malmasi, S., Nakov, P., Rosenthal, S., Farra, N., and Kumar, R. (2019, January 2–7). Predicting the Type and Target of Offensive Posts in Social Media. Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Minneapolis, MN, USA.10.18653/v1/N19-1144 ↗
9. Schmidt, A., and Wiegand, M. (2017). A survey on hate speech detection using natural language processing. Proceedings of the Fifth International Workshop on Natural Language Processing for Social Media, Association for Computational Linguistics.10.18653/v1/W17-1101 ↗
10. Generalizing hate speech detection using multi-task learning: A case study of political public figures10.1016/j.csl.2024.101690 ↗
11. ElSherief, M., Ziems, C., Muchlinski, D., Anupindi, V., Seybolt, J., De Choudhury, M., and Yang, D. (2021). Latent hatred: A benchmark for understanding implicit hate speech. arXiv.10.18653/v1/2021.emnlp-main.29 ↗
12. Mao, C., Gupta, A., Nitin, V., Ray, B., Song, S., Yang, J., and Vondrick, C. (2021, January 11). Multitask learning strengthens adversarial robustness. Proceedings of the European Conference on Computer Vision, Montreal, QC, Canada.10.1007/978-3-030-58536-5_10 ↗
13. Improving the reliability of deep neural networks in NLP: A review10.1016/j.knosys.2019.105210 ↗
14. Huq, A., and Pervin, M. (2020). Adversarial attacks and defense on texts: A survey. arXiv.
15. Gröndahl, T., Pajola, L., Juuti, M., Conti, M., and Asokan, N. (2018, January 15–19). All You Need is” Love” Evading Hate Speech Detection. Proceedings of the 11th ACM Workshop on Artificial Intelligence and Security, New York, NY, USA.10.1145/3270101.3270103 ↗
16. A survey on multi-task learning10.1109/TKDE.2021.3070203 ↗
17. Crawshaw, M. (2020). Multi-task learning with deep neural networks: A survey. arXiv.
18. A Deep Learning Framework for Automatic Detection of Hate Speech Embedded in Arabic Tweets10.1007/s13369-021-05383-3 ↗
19. A survey of offensive language detection for the arabic language10.1145/3421504 ↗
20. Al-Hassan, A., and Al-Dossari, H. (2019, January 23–24). Detection of hate speech in social networks: A survey on multilingual corpus. Proceedings of the 6th International Conference on Computer Science and Information Technology, Zurich, Switzerland.10.5121/csit.2019.90208 ↗
21. Boulouard, Z., Ouaissa, M., Ouaissa, M., Krichen, M., Almutiq, M., and Gasmi, K. (2022). Detecting Hateful and Offensive Speech in Arabic Social Media Using Transfer Learning. Appl. Sci., 12.10.3390/app122412823 ↗
22. Husain, F., and Uzuner, O. (2022, January 27–28). Transfer Learning Across Arabic Dialects for Offensive Language Detection. Proceedings of the 2022 International Conference on Asian Language Processing (IALP), Singapore.10.1109/IALP57159.2022.9961263 ↗
23. A hybrid approach based on personality traits for hate speech detection in Arabic social media
24. An efficient approach for data-imbalanced hate speech detection in Arabic social media
25. Al-Dabet, S., ElMassry, A., Alomar, B., and Alshamsi, A. (2023, January 1–3). Transformer-based arabic offensive speech detection. Proceedings of the 2023 International Conference on Emerging Smart Computing and Informatics (ESCI), Pune, India.10.1109/ESCI56872.2023.10100134 ↗
26. Deep learning-based analysis of Algerian dialect dataset targeted hate speech, offensive language and cyberbullying10.12785/ijcds/130177 ↗
27. Detection of hateful social media content for Arabic language
28. AlSukhni, E., AlAzzam, I., and Hanandeh, S. (2024, January 13–15). Offensive Language Detection of Arabic Tweets Using Deep Learning Algorithm. Proceedings of the 2024 15th International Conference on Information and Communication Systems (ICICS), Irbid, Jordan.10.1109/ICICS63486.2024.10638282 ↗
29. Advancing offensive language detection in Arabic social media: A BERT-based ensemble learning approach10.1007/s13278-024-01347-1 ↗
30. Detection of Arabic offensive language in social media using machine learning models
31. Comparative performance of ensemble machine learning for Arabic cyberbullying and offensive language detection10.1007/s10579-023-09683-y ↗
32. Mnassri, K., Rajapaksha, P., Farahbakhsh, R., and Crespi, N. (June, January 28). Hate speech and offensive language detection using an emotion-aware shared encoder. Proceedings of the ICC 2023-IEEE International Conference on Communications, Rome, Italy.10.1109/ICC45041.2023.10279690 ↗
33. Farha, I.A., and Magdy, W. (2020, January 11–16). Multitask learning for arabic offensive language and hate-speech detection. Proceedings of the 4th Workshop on Open-Source Arabic Corpora and Processing Tools, with a Shared Task on Offensive Language Detection, Marseille, France.
34. Mulki, H., and Ghanem, B. (2021). Let-mi: An Arabic levantine twitter dataset for Misogynistic language. arXiv.
35. Shapiro, A., Khalafallah, A., and Torki, M. (2022). AlexU-AIC at Arabic Hate Speech 2022: Contrast to Classify. arXiv.
36. Alrashidi, B., Jamal, A., and Alkhathlan, A. (2023). Abusive content detection in arabic tweets using multi-task learning and transformer-based models. Appl. Sci., 13.10.3390/app13105825 ↗
37. AlKhamissi, B., and Diab, M. (2022). Meta ai at arabic hate speech 2022: Multitask learning with self-correction for hate speech classification. arXiv.
38. Djandji, M., Baly, F., Antoun, W., and Hajj, H. (2020, January 11–16). Multi-task learning using AraBert for offensive language detection. Proceedings of the 4th Workshop on Open-Source Arabic Corpora and Processing Tools, with a Shared Task on Offensive Language Detection, Marseille, France.
39. Kapil, P., and Ekbal, A. (2024). A Unified Multi-Task Learning Architecture for Hate Detection Leveraging User-Based Information. arXiv.
40. Dai, W., Yu, T., Liu, Z., and Fung, P. (2020). Kungfupanda at semeval-2020 task 12: Bert-based multi-task learning for offensive language detection. arXiv.10.18653/v1/2020.semeval-1.272 ↗
41. Kapil, P., and Ekbal, A. (2021). Leveraging multi-domain, heterogeneous data using deep multitask learning for hate speech detection. arXiv.
42. Halat, S., Plaza-Del-Arco, F.M., Padó, S., and Klinger, R. (2022). Multi-Task Learning with Sentiment, Emotion, and Target Detection to Recognize Hate Speech and Offensive Language. arXiv.
43. A multi-task learning approach to hate speech detection leveraging sentiment analysis10.1109/ACCESS.2021.3103697 ↗
44. Offensive language identification with multi-task learning10.1007/s10844-023-00787-z ↗
45. Jia, R., and Liang, P. (2017). Adversarial examples for evaluating reading comprehension systems. arXiv.10.18653/v1/D17-1215 ↗
46. Liang, B., Li, H., Su, M., Bian, P., Li, X., and Shi, W. (2017). Deep text classification can be fooled. arXiv.10.24963/ijcai.2018/585 ↗
47. Ebrahimi, J., Rao, A., Lowd, D., and Dou, D. (2017). Hotflip: White-box adversarial examples for text classification. arXiv.10.18653/v1/P18-2006 ↗
48. Belinkov, Y., and Bisk, Y. (2017). Synthetic and natural noise both break neural machine translation. arXiv.
49. Gao, J., Lanchantin, J., Soffa, M.L., and Qi, Y. (2018, January 24). Black-box generation of adversarial text sequences to evade deep learning classifiers. Proceedings of the 2018 IEEE Security and Privacy Workshops (SPW), San Francisco, CA, USA.10.1109/SPW.2018.00016 ↗
50. Li, J., Ji, S., Du, T., Li, B., and Wang, T. (2018). Textbugger: Generating adversarial text against real-world applications. arXiv.10.14722/ndss.2019.23138 ↗
51. Ren, S., Deng, Y., He, K., and Che, W. (August, January 28). Generating natural language adversarial examples through probability weighted word saliency. Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, Florence, Italy.
52. Alshemali, B., and Kalita, J. (2019, January 5–7). Adversarial examples in arabic. Proceedings of the 2019 International Conference on Computational Science and Computational Intelligence (CSCI), Las Vegas, NV, USA.10.1109/CSCI49370.2019.00072 ↗
53. Jin, D., Jin, Z., Zhou, J.T., and Szolovits, P. (2020, January 7–12). Is bert really robust? a strong baseline for natural language attack on text classification and entailment. Proceedings of the AAAI Conference on Artificial Intelligence, New York, NY, USA.10.1609/aaai.v34i05.6311 ↗
54. Li, L., Zhu, Z., Du, D., Ren, S., Zheng, Y., and Chang, G. (2020, January 18–20). Adversarial Convolutional Neural Network for Text Classification. Proceedings of the 2020 4th International Conference on Electronic Information Technology and Computer Engineering, Xiamen, China.10.1145/3443467.3443837 ↗
55. Garg, S., and Ramakrishnan, G. (2020). Bae: Bert-based adversarial examples for text classification. arXiv.10.18653/v1/2020.emnlp-main.498 ↗
56. Mubarak, H., Rashed, A., Darwish, K., Samih, Y., and Abdelali, A. (2020). Arabic offensive language on twitter: Analysis and experiments. arXiv.
57. Mulki, H., Haddad, H., Ali, C.B., and Alshabani, H. (2019, January 1). L-hsab: A levantine twitter dataset for hate speech and abusive language. Proceedings of the Third Workshop on Abusive Language Online, Florence, Italy.10.18653/v1/W19-3512 ↗
58. Haddad, H., Mulki, H., and Oueslati, A. (2019, January 16–17). T-hsab: A tunisian hate speech and abusive dataset. Proceedings of the International Conference on Arabic Language Processing, Nancy, France.10.1007/978-3-030-32959-4_18 ↗
59. Hassan, S., Samih, Y., Mubarak, H., Abdelali, A., Rashed, A., and Chowdhury, S.A. (2020, January 11–16). ALT submission for OSACT shared task on offensive language detection. Proceedings of the 4th Workshop on Open-Source Arabic Corpora and Processing Tools, with a Shared Task on Offensive Language Detection, Marseille, France.