Submitted:
31 March 2025
Posted:
01 April 2025
You are already at the latest version
Abstract
Keywords:
1. Introduction
1.1. Background
1.2. Research Problem
1.3. Research Objectives
- Fine-tune transformer-based models (XLM-RoBERTa, DistilBERT, mBERT, mT5) to improve accuracy in hate speech detection within Spanglish, leveraging multilingual contextual embeddings.
- Benchmark the performance of transformer-based models against traditional machine learning classifiers (SVM, Logistic Regression, and Multinomial Naïve Bayes) using TF-IDF features, providing a comprehensive analysis of their effectiveness in handling the linguistic complexities of code-switched text.
- Explore low-resource fine-tuning strategies, including weak supervision with multilingual lexicons.
2. Literature Review
2.1. Hate Speech Detection in Monolingual Contexts
2.2. NLP Challenges in Code-Switched Contexts
2.3. Low-Resource NLP and Code-Switching
2.4. Summary of Literature and Research Gap
3. Methodology
3.1. Dataset Description
3.2. Data Preprocessing
- Lowercasing: Converting all text to lowercase for consistency.
- Noise Removal: Eliminating punctuation marks, URLs, special characters, numbers, and user mentions (@user).
- Whitespace Normalization: Standardization of spacing within and between sentences.
3.2.1. Tokenization
- represents the frequency of term t in document d.
- N is the total number of documents in the corpus.
- denotes the number of documents that contain the term t.
3.3. Models and Experiments
3.3.1. Transformer-Based Deep Learning Models
- XLM-RoBERTa: A cross-lingual transformer pre-trained on multilingual data.
- DistilBERT: A lightweight and distilled version of BERT optimized for efficiency.
- Multilingual BERT (mBERT): A BERT model pre-trained on multiple languages.
- Multilingual T5 (mT5): A transformer encoder-decoder model designed for text-to-text tasks.
- Learning Rate:
- Batch Size: 16 samples for training and validation.
- Epochs: 5
- Weight Decay: 0.01 (to reduce overfitting).
- Optimizer: AdamW, known for stabilizing transformer training.
3.3.2. Traditional Machine Learning Models
- Logistic Regression: Efficient and interpretable model.
- Support Vector Machines (SVM): Effective in high-dimensional text data.
- Multinomial Naïve Bayes: Probabilistic classifier commonly used for text classification.
3.4. Evaluation Metrics
- (True Positive): Correctly identified hate speech instances.
- (True Negative): Correctly identified non-hate speech instances.
- (False Positive): Incorrectly classified non-hate speech as hate speech.
- (False Negative): Hate speech instances misclassified as non-hate.
3.5. Computational Resources
- Training Duration
- Speed (Samples per Second)
- Total Floating-Point Operations (FLOPs)
3.6. Ethical Considerations
4. Results and Discussion
4.1. Comprehensive Performance Comparison
4.2. Discussion of Results
4.3. Computational Efficiency
5. Conclusion and Future Work
5.1. Summary of Findings
- Transformer-based models significantly outperformed traditional classifiers, with XLM-RoBERTa emerging as the best-performing model, achieving the highest accuracy (96.14%), precision (96.16%), recall (96.14%), and F1-score (96.12%). This underscores the superior capability of transformer architectures in capturing the linguistic complexities inherent in code-switched text.
- Among traditional classifiers, the Support Vector Machine (SVM) model demonstrated strong performance, with competitive accuracy (94.03%) and precision (99.95%), proving its effectiveness in scenarios with limited computational resources.
- The mT5 model exhibited significantly lower performance (accuracy: 63.05%), indicating the limitations of certain transformer architectures, particularly generative models, in handling code-switched language tasks.
- The error analysis revealed persistent linguistic challenges, including slang usage, idiomatic expressions, negations, and semantic ambiguities in code-switched text. These complexities pose significant challenges for existing NLP models, highlighting areas requiring further refinement to enhance model robustness in multilingual environments.
5.2. Contributions and Implications
- Provides in-depth evaluation of transformer-based and traditional ML methods, offering empirical evidence of the superiority of transformer models in handling the intricacies of code-switched text.
- The research introduces an enriched dataset enhanced through weak supervision by integrating extensive multilingual lexicons, thereby facilitating further research in multilingual and code-switched NLP applications.
- The study identifies critical linguistic challenges that affect model accuracy, particularly the detection of slang and implicit hate speech expressions, emphasizing the need for targeted enhancements in the design of the NLP model.
- The findings have practical implications for automated content moderation, online safety, and inclusive NLP applications, particularly in diverse and multilingual digital communities. Improved hate speech detection models can contribute to safer and more responsible online discourse by mitigating the spread of harmful content.
5.3. Future Work
- Data Augmentation Techniques: Expanding existing datasets through synthetic data generation, paraphrasing, and translation-based augmentation can help address data scarcity issues and improve model generalization.
- Few-Shot and Zero-Shot Learning Approaches: Developing models that can achieve high classification accuracy with minimal labeled data is crucial in resource-constrained multilingual settings. Exploring meta-learning and contrastive learning strategies can facilitate effective learning with limited training examples.
- Hybrid Models and Fusion Strategies: Integrating linguistic heuristics, lexicon-based methods, and transformer embeddings can improve the detection of implicit and nuanced hate speech, particularly in informal and context-dependent conversations.
- Domain Adaptation and Transfer Learning: Investigating the adaptability of transformer-based models across various digital platforms, such as social media, online forums, and conversational agents, will ensure consistent and reliable hate speech detection in real-world applications.
- Ethical AI and Bias Mitigation: Future studies should explore techniques to reduce biases in hate speech detection models to ensure fairness between different demographic and linguistic groups, minimizing the risk of unintended model biases and false positives.
Acknowledgments
References
- Solorio, T.; Liu, Y.; Rios, A.; Cruz, F.L. Part-of-speech tagging for English-Spanish code-switched text. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP); 2014; pp. 1051–1060. Available online: https://aclanthology.org/D14-1112.
- Davidson, T.; Warmsley, D.; Macy, M.; Weber, I. Automated hate speech detection and the problem of offensive language. In Proceedings of the Eleventh International AAAI Conference on Web and Social Media; 2017; pp. 512–515. Available online: https://ojs.aaai.org/index.php/ICWSM/article/view/14955.
- Waseem, Z.; Hovy, D. Hateful symbols or hateful people? Predictive features for hate speech detection on Twitter. In Proceedings of the NAACL Student Research Workshop; 2016; pp. 88–93. Available online: https://aclanthology.org/N16-2013.
- Molina, G.; Cabrera, A.; Solorio, T. Overview for the second shared task on language identification in code-switched data. In Proceedings of the Second Workshop on Computational Approaches to Code Switching; 2016; pp. 40–49. Available online: https://aclanthology.org/W16-5806.
- Devlin, J.; Chang, M.W.; Lee, K.; Toutanova, K. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics (NAACL); 2019; pp. 4171–4186. Available online: https://aclanthology.org/N19-1423.
- Caselli, T.; Basile, V.; Mitrović, J.; Kartoziya, I.; Granitzer, M. HateBERT: Retraining BERT for abusive language detection in English. arXiv 2020, arXiv:2010.12472. Available online: https://arxiv.org/abs/2010.12472.
- Nwaiwu, S.; Jongsawat, N.; Tungkasthan, A.; Thaloey, J. Fine-tuned BERT model for hate speech detection in political discourse. 2024 22nd International Conference on ICT and Knowledge Engineering (ICT&KE); 2024; pp. 1–8. [Google Scholar] [CrossRef]
- Pratapa, A.; Bhat, S.; Bali, K.; Choudhury, M. Language modeling for code-mixing: The role of linguistic theory-based synthetic data. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (ACL); 2018; pp. 1543–1553. Available online: https://aclanthology.org/P18-1143.
- Winata, G.I.; Madotto, A.; Fung, P. Code-switching language modeling using syntax-aware multi-task learning. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics (ACL); 2021; pp. 3786–3798. Available online: https://aclanthology.org/2021.acl-long.293.
- Conneau, A.; et al. Unsupervised cross-lingual representation learning at scale. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics (ACL); 2020; pp. 8440–8451. Available online: https://aclanthology.org/2020.acl-main.747.
- Pires, T.; Schlinger, E.; Garrette, D. How multilingual is multilingual BERT? In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (ACL); 2019; pp. 4996–5001. Available online: https://aclanthology.org/P19-1493.
- Aguilar, G.; Kar, S.; Solorio, T.; Molina, G. LinCE: A centralized benchmark for linguistic code-switching evaluation. In Proceedings of the 12th Language Resources and Evaluation Conference (LREC); 2020; pp. 1803–1813. Available online: https://aclanthology.org/2020.lrec-1.224.
- Hatebase. The world’s largest structured repository of regionalized hate speech. 2019. Available online: https://hatebase.org (accessed on 16 March 2025).
- Tiţa, T.; Zubiaga, A. Cross-lingual Hate Speech Detection using Transformer Models. arXiv 2021, arXiv:2111.00981. Available online: https://arxiv.org/abs/2111.00981.
- Zhang, Y.; Chen, P.-H.C.; Gadepalli, K.; et al. Transformer versus traditional natural language processing models for radiology report classification: A multi-institutional study. Radiol. Artif. Intell. 2023, 5, 220207. [Google Scholar] [CrossRef]
- Das, M.; Selvakumar, K.; Alphonse, P.J.A. A Comparative Study on TF-IDF Feature Weighting Method and its Analysis using Unstructured Dataset. arXiv 2023, arXiv:2308.04037. Available online: https://arxiv.org/abs/2308.04037.
- Shakeel, M.H.; Karim, A. Adapting Deep Learning for Sentiment Classification of Code-Switched Informal Short Text. arXiv 2020, arXiv:2001.01047, 1047. Available online: https://arxiv.org/abs/2001.01047.
- Dogruöz, A.S.; Çöltekin, Ç. Representativeness as a Forgotten Lesson for Multilingual and Code-Switching NLP. Findings of the Association for Computational Linguistics: EMNLP 2023; 2023; pp. 5190–5204. Available online: https://aclanthology.org/2023.findings-emnlp.382.pdf.
| Dataset Split | Number of Samples |
|---|---|
| Training Set | 11,999 |
| Validation Set | 3,000 |
| Test Set | 6,500 |
| Lexicon | Number of Terms |
|---|---|
| English Hate Lexicon | 5,963 |
| Spanish Hate Lexicon | 3,354 |
| Model | Accuracy | Precision | Recall | F1-score |
|---|---|---|---|---|
| Logistic Regression (Benchmark) | 0.9065 | 0.9920 | 0.7698 | 0.8669 |
| SVM (Benchmark) | 0.9403 | 0.9995 | 0.8495 | 0.9185 |
| Multinomial Naïve Bayes (Benchmark) | 0.9074 | 0.9616 | 0.7978 | 0.8721 |
| XLM-RoBERTa | 0.9614 | 0.9616 | 0.9614 | 0.9612 |
| DistilBERT | 0.9423 | 0.9432 | 0.9423 | 0.9419 |
| mBERT | 0.9594 | 0.9599 | 0.9594 | 0.9592 |
| mT5 | 0.6305 | 0.6146 | 0.6305 | 0.5942 |
| Model | Training Time (min) | Inference Speed (sec) |
|---|---|---|
| Logistic Regression | 1.2 | 3100 |
| SVM | 3.5 | 1200 |
| Multinomial Naïve Bayes | 1.4 | 2800 |
| XLM-RoBERTa | 52.7 | 120 |
| DistilBERT | 27.8 | 180 |
| mBERT | 49.3 | 130 |
| mT5 | 65.2 | 95 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).