Arabic Hate Speech Identification and Masking in Social Media using Deep Learning Models and Pre-trained Models Fine-tuning
Summary
The paper tackles two tasks for Arabic social media text: recognising hateful or offensive posts, and "cleaning" them by hiding the offending words. For detection, the authors compare recurrent, convolutional and Transformer-based classifiers on the Arabic data of the SemEval-2020 (OffensEval 2020) offensive language shared task. They report that a fine-tuned QARiB model with the AraBERT preprocessor performs best, reaching 92% macro F1 and 95% accuracy, which they say beats the top published shared-task result. For cleaning, they treat masking as sequence-to-sequence translation. The source is the original sentence, and the target is the same sentence with each bad word replaced by asterisks, one per letter. To train this, human annotators built a small parallel corpus that also contains untouched non-hateful sentences. The best masking model scores 0.30 BLEU-1. The authors frame this as the first attempt at Arabic hate speech masking and the opening of a new task, moving moderation from flagging posts to rewriting them.
Key points
- The detection data comes from the SemEval-2020 Arabic offensive language task, and the evaluated model families are RNN, CNN and Transformers.
- The best detector is QARiB with AraBERT preprocessing, at 92% macro F1 and 95% accuracy. In related work, the strongest OffensEval 2020 Arabic system reached 90.17% macro F1.
- The masking corpus was tested at two sizes:
- With 3,183 pairs (1,592 non-hate), the best result came at vocabulary 8,000, with BLEU 1–4 of 0.29 / 0.17 / 0.10 / 0.07.
- With 4,383 pairs (2,791 non-hate), the best result came at vocabulary 12,000, with BLEU 1–4 of 0.30 / 0.18 / 0.12 / 0.08.
- Each experiment ran five vocabulary sizes (6,000–15,000), and the count of unknown tokens after prediction is reported next to BLEU.
- Materials are on GitHub (motazsaad/hate-speech). Future work includes:
- a larger parallel corpus;
- releasing the categorised hate/offensive lexicon built during annotation;
- web deployment;
- hate speech paraphrasing.
Interesting ideas
- I1. Redaction is cast as a monolingual rewrite in which the output mirrors the input except for the masked spans; this turns a detection problem into an editing problem a generator can learn. — For Mova (back): Mova's text → graph → text path could support "same text, selected spans altered" as a controlled generation mode, checking that unchanged spans regenerate verbatim.
- I2. The masking corpus deliberately includes many clean sentences whose target equals the source, which teaches the model when to leave text alone and works like a built-in negative control. — For Mova (learn): Mova's training and evaluation sets could mix in no-change items for each repair rule or rewrite, so over-triggering is measured directly.
- I3. Each masked word becomes as many stars as it has letters, so length and positions are preserved and outputs stay aligned with inputs token by token. — For Mova (tokens): Mova could use length-preserving placeholders when anonymising or masking spans, so token offsets, tags and tree attachments remain valid without re-tokenising.
- I4. The number of unknown tokens is reported next to BLEU for each vocabulary size, revealing how much of the score is limited by vocabulary coverage rather than by the model. — For Mova (tokens): Mova's tokenizer and lemma evaluations could report out-of-vocabulary counts beside accuracy, so errors from coverage gaps are separated from modelling errors.
- I5. Building the parallel corpus yielded a categorised offensive lexicon as a by-product, so one annotation pass produced two resources. — For Mova (world): Mova annotation passes could log the categorised lexical items they mark, feeding the compiled knowledge layer (for example, evaluative or pejorative word classes) at little extra cost.
Cite
@misc{doghmash2025arabic,
title = {{Arabic Hate Speech Identification and Masking in Social Media using Deep Learning Models and Pre-trained Models Fine-tuning}},
author = {Doghmash, Salam Thabet and Saad, Motaz},
year = {2025},
doi = {10.48550/arxiv.2507.23661},
eprint = {2507.23661},
archivePrefix = {arXiv},
url = {https://doi.org/10.48550/arxiv.2507.23661}
}References
- Fortuna, P., Nunes, S.: A survey on automatic detection of hate speech in text. ACM Computing Surveys (CSUR) 51(4), 1–30 (2018) find
- Fortuna, P.: Automatic detection of hate speech in text: an overview of the topic and dataset annotation with hierarchical classes. (2017) find
- Basile, V., Bosco, C., Fersini, E., Nozza, D., Patti, V., Rangel Pardo, F.M., Rosso, P., Sanguinetti, M.: SemEval-2019 task 5: Multilingual detection of hate speech against immigrants and women in Twitter. In: Proceedings of the 13th International Workshop on Semantic Evaluation, pp. 54–63. Association for Computational Linguistics, Minneapolis, Minnesota, USA (2019). https://doi.org/10.18653/v1/S19-2007. https://aclanthology.org/ S19-2007 ↗ our card
- Davidson, T., Bhattacharya, D., Weber, I.: Racial bias in hate speech and abusive language detection datasets, pp. 25–35 (2019). https://doi.org/ 10.18653/v1/W19-3504 ↗ our card
- Zampieri, M., Nakov, P., Rosenthal, S., Atanasova, P., Karadzhov, G., Mubarak, H., Derczynski, L., Pitenis, Z., ltekin, .: SemEval-2020 Task 12: Multilingual Offensive Language Identification in Social Media (OffensEval 2020) find
- Teubert, W.: Units of meaning, parallel corpora, and their implications for language teaching. Language and Computers, 171–189 (2004) find
- Mulki, H., Haddad, H., Bechikh Ali, C., Alshabani, H.: L-HSAB: A Levantine Twitter dataset for hate speech and abusive language. In: Proceedings of the Third Workshop on Abusive Language Online, pp. 111–118. Association for Computational Linguistics, Florence, Italy (2019). https://doi.org/10.18653/v1/W19-3512. https://aclanthology.org/W19-3512 ↗
- Albadi, N., Kurdi, M., Mishra, S.: Are they our brothers? analysis and detection of religious hate speech in the arabic twittersphere. 2018 IEEE/ACM International Conference on Advances in Social Networks Analysis and Mining (ASONAM), 69–76 (2018) find
- Mubarak, H., Darwish, K., Magdy, W.: Abusive language detection on Arabic social media. In: Proceedings of the First Workshop on Abusive Language Online, pp. 52–56. Association for Computational Linguistics, Vancouver, BC, Canada (2017). https://doi.org/10.18653/v1/W17-3008. https://aclanthology.org/W17-3008 ↗ our card
- Saksesi, A.S., Nasrun, M., Setianingsih, C.: Analysis text of hate speech detection using recurrent neural network. In: 2018 International Conference on Control, Electronics, Renewable Energy and Communications (ICCEREC), pp. 242–248 (2018). https://doi.org/10.1109/ICCEREC. 2018.8712104 ↗
- Qiang, J., Wu, X.: Unsupervised statistical text simplification. IEEE Transactions on Knowledge and Data Engineering 33(4), 1802–1806 (2021). https://doi.org/10.1109/TKDE.2019.2947679 ↗
- Alami, H., Ouatik El Alaoui, S., Benlahbib, A., En-nahnahi, N.: LISAC FSDM-USMBA team at SemEval-2020 task 12: Overcoming AraBERT’s pretrain-finetune discrepancy for Arabic offensive language identification. In: Proceedings of the Fourteenth Workshop on Semantic Evaluation, pp. 2080–2085. International Committee for Computational Linguistics, Barcelona (online) (2020). https://doi.org/10.18653/v1/2020.semeval-1. 275. https://aclanthology.org/2020.semeval-1.275 ↗
- Hassan, S., Samih, Y., Mubarak, H., Abdelali, A.: ALT at SemEval-2020 task 12: Arabic and English offensive language identification in social media. In: Proceedings of the Fourteenth Workshop on Semantic Evaluation, pp. 1891–1897. International Committee for Computational Linguistics, Barcelona (online) (2020). https://doi.org/10.18653/v1/2020. semeval-1.249. https://aclanthology.org/2020.semeval-1.249 ↗
- Wang, S., Liu, J., Ouyang, X., Sun, Y.: Galileo at semeval-2020 task 12: Multi-lingual learning for offensive language identification using pre-trained language models, pp. 1448–1455 (2020). https://doi.org/10. 18653/v1/2020.semeval-1.189 ↗
- Safaya, A., Abdullatif, M., Yuret, D.: Kuisail at semeval-2020 task 12: Bert-cnn for offensive speech identification in social media, pp. 2054–2059 (2020). https://doi.org/10.18653/v1/2020.semeval-1.271 ↗ our card
- Keleg, A., El-Beltagy, S.R., Khalil, M.: ASU OPTO at OSACT4 -offensive language detection for Arabic text. In: Proceedings of the 4th Workshop on Open-Source Arabic Corpora and Processing Tools, with a Shared Task on Offensive Language Detection, pp. 66–70. European Language Resource Association, Marseille, France (2020). https://aclanthology.org/2020.osact-1.10 ↗
- Mnassri, K., Rajapaksha, P., Farahbakhsh, R., Crespi, N.: Hate Speech and Offensive Language Detection using an Emotion-aware Shared Encoder (2023) find
- Mohaouchane, H., Mourhir, A., Nikolov, N.S.: Detecting offensive language on arabic social media using deep learning. In: 2019 Sixth International Conference on Social Networks Analysis, Management and Security (SNAMS), pp. 466–471 (2019). https://doi.org/10.1109/SNAMS.2019. 8931839 ↗
- Husain, F., Uzuner, Ö.: Transfer learning approach for arabic offensive language detection system - bert-based model. CoRR abs/2102.05708 (2021) https://arxiv.org/abs/2102.05708 ↗ our card
- Alakrot, A., Murray, L., Nikolov, N.S.: Dataset construction for the detection of anti-social behaviour in online communication in arabic. Procedia Computer Science 142, 174–181 (2018). https://doi.org/10.1016/j.procs. 2018.10.473. Arabic Computational Linguistics ↗
- Alshalan, R., Al-Khalifa, H.: A deep learning approach for automatic hate speech detection in the saudi twittersphere. Applied Sciences 10(23) (2020). https://doi.org/10.3390/app10238614 ↗
- Faris., H., Aljarah., I., Habib., M., Castillo., P.A.: Hate Speech Detection Using Word Embedding and Deep Learning in the Arabic Language Context. In: Proceedings of the 9th International Conference on Pattern Recognition Applications and Methods - ICPRAM,, pp. 453– 460. SciTePress, ??? (2020). https://doi.org/10.5220/0008954004530460. INSTICC ↗
- Mohammad, A.B., Eissa, K., El-Beltagy, S.: Aravec: A set of arabic word embedding models for use in arabic nlp. Procedia Computer Science 117, 256–265 (2017). https://doi.org/10.1016/j.procs.2017.10.117 ↗
- Abdelali, A., Hassan, S., Mubarak, H., Darwish, K., Samih, Y.: Pre-training BERT on arabic tweets: Practical considerations. CoRR abs/2102.10684 (2021) https://arxiv.org/abs/2102.10684 ↗ our card
- Abdul-Mageed, M., Elmadany, A., Nagoudi, E.M.B.: Arbert & marbert: Deep bidirectional transformers for arabic, pp. 7088–7105 (2021). https://doi.org/10.18653/v1/2021.acl-long.551 ↗ our card
- Papineni, K., Roukos, S., Ward, T., Zhu, W.J.: Bleu: a method for automatic evaluation of machine translation (2002). https://doi.org/10.3115/ 1073083.1073135 ↗ our card
- Coughlin, D.: Correlating automated and human assessments of machine translation quality. In: Proceedings of Machine Translation Summit IX: Papers, New Orleans, USA (2003). https://aclanthology.org/2003. mtsummit-papers.9 ↗
- Sharma, S., Asri, L.E., Schulz, H., Zumer, J.: Relevance of unsupervised metrics in task-oriented dialogue for evaluating natural language generation. CoRR abs/1706.09799 (2017) https://arxiv.org/abs/1706. 09799 ↗
This page in Markdown → https://md.research.elamur.ai/free/en/papers/doghmash-2025-arabic-hate-speech-identification-masking/