When Prompts Know the Story: Improving LLM Detection of Online Hate Speech
DOI:
https://doi.org/10.5753/jidm.2026.7421Keywords:
LLM, Prompt engineering, hate speech detection, Social NetworksAbstract
Recent advances in Large Language Models (LLMs) have created new possibilities for automated hate speech detection in online platforms. This manuscript investigates how prompt design choices, e.g., contextualization and domain delimitation, affect LLMs' ability to accurately identify online hateful content. We evaluate a range of prompt formulations, varying the presence of explicit instructions and illustrative examples, to analyze their influence on classification performance across both state-of-the-art commercial models and smaller open-weight alternatives. The results demonstrate that constraining the thematic scope of hate speech through domain delimitation improves detection accuracy by minimizing semantic ambiguity and reducing false positives. More broadly, this manuscript shows that providing explicit domain-specific information in the prompt is a key driver for the ethical, reliable, and responsible deployment of LLM-based systems in efforts to mitigate hate speech in online environments.
Downloads
References
Albladi, A. et al. (2025). Hate Speech Detection Using Large Language Models: A Comprehensive Review. IEEE Access, 13:20871–20892.
Aluru, S. S., Mathew, B., Saha, P., and Mukherjee, A. (2020). Deep learning models for multilingual hate speech detection.
Anagnostidis, S. and Bulian, J. (2024). How susceptible are llms to influence in prompts?
Assis, G. et al. (2024a). Explorando técnicas de aprendizado em modelos de linguagem para classificação de discurso de Ódio e ofensivo em português. Linguamática, 16(2):91–113.
Assis, G. et al. (2024b). Exploring Portuguese Hate Speech Detection in Low-Resource Settings: Lightly Tuning Encoder Models or In-context Learning of Large Models? In Proc. of 16th PROPOR, pages 301–311, Santiago de Compostela. ACL.
Brown, T. B. et al. (2020). Language Models are Few-Shot Learners.
Chiu, K.-L., Collins, A., and Alexander, R. (2022). Detecting Hate Speech with GPT-3.
Choi, H. K. and Li, Y. (2024). PICLe: Eliciting Diverse Behaviors from Large Language Models with Persona In-Context Learning. In Proc. of the 41st PMLR, volume 235 of Proceedings of Machine Learning Research, pages 8722–8739. PMLR.
Cohere (2025). Command A: An Enterprise-Ready Large Language Model.
DeepSeek-AI (2025a). Deepseek-r1: Incentivizing reasoning capability in llms via reinforcement learning.
DeepSeek-AI (2025b). Deepseek-V3 Technical Report.
Dong, Q., Li, L., Dai, D., Zheng, C., Ma, J., Li, R., Xia, H., Xu, J., Wu, Z., Chang, B., et al. (2024a). A survey on in-context learning. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pages 1107–1128.
Dong, Q. et al. (2024b). A Survey on In-context Learning. In Al-Onaizan, Y., Bansal, M., and Chen, Y.-N., editors, Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pages 1107–1128, Miami, Florida, USA. Association for Computational Linguistics.
Guo, K., Hu, A., Mu, J., Shi, Z., Zhao, Z., Vishwamitra, N., and Hu, H. (2024). An Investigation of Large Language Models for Real-World Hate Speech Detection.
Kim, J. W., Guess, A., Nyhan, B., and Reifler, J. (2021). The distorting prism of social media: How self-selection and exposure to incivility fuel online comment toxicity. Journal of Communication, 71(6):922–946.
Lester, B. et al. (2021). The power of scale for parameter-efficient prompt tuning. In Proc. of the 2021 EMNLP, pages 3045–3059, Punta Cana. ACL.
Li, L., Fan, L., Atreja, S., and Hemphill, L. (2024). “HOT” ChatGPT: The Promise of ChatGPT in Detecting and Discriminating Hateful, Offensive, and Toxic Comments on Social Media. ACM Trans. Web, 18(2).
Li, X. L. and Liang, P. (2021). Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing, pages 4582–4597. ACL.
Liu, P., Yuan, W., Fu, J., Jiang, Z., Hayashi, H., and Neubig, G. (2023). Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processing. ACM Comput. Surv., 55(9).
Nguyen, N. D., Truong, N., Dao, P. Q., and Nguyen, H. H. (2025). Can online behaviors be linked to mental health? active versus passive social network usage on depression via envy and self-esteem. Comput. Hum. Behav., 162:108455.
Oliveira, A. et al. (2023). How good is ChatGPT for detecting Hate Speech in Portuguese? In Anais do XIV STIL, pages 94–103, Porto Alegre, RS, Brasil. SBC.
Oliveira, A. et al. (2024a). Toxic Speech Detection in Portuguese: A Comparative Study of Large Language Models. In Proc.s of the 16th PROPOR, pages 108–116, Santiago de Compostela. ACL.
Oliveira, A. et al. (2024b). Toxic Text Classification in Portuguese: Is LLaMA 3.1 8B All You Need? In Anais do XV STIL, pages 57–66, Porto Alegre, RS, Brasil. SBC.
OpenAI (2024). GPT-4o System Card.
OpenAI (2025). gpt-oss-120b and gpt-oss-20b model card.
Paes, A., Vianna, D., and Rodrigues, J. (2024). Modelos de linguagem. In Processamento de Linguagem Natural: Conceitos, Técnicas e Aplicações em Português, book chapter 17. BPLN, 3 edition.
Paiva, L., Assis, G., Amorim, A., Dias, L. G., Paes, A., and de Oliveira, D. (2025). Domínio delimitado, Ódio exposto: O uso de prompts para identificação de discurso de Ódio online com llms. In Anais do XL Simpósio Brasileiro de Bancos de Dados, pages 493–506, Porto Alegre, RS, Brasil. SBC. DOI: 10.5753/sbbd.2025.247279.
Pérez, J. M. et al. (2025). Exploring Large Language Models for Hate Speech Detection in Rioplatense Spanish. In NAACL 2025, pages 7174–7187, Albuquerque, New Mexico. ACL.
Saraiva, G. D. et al. (2021). A semi-supervised approach to detect toxic comments. In Proc. of the RANLP 2021, pages 1261–1267, Online. INCOMA Ltd.
Touvron, H. et al. (2023). LLaMA: Open and Efficient Foundation Language Models.
Vargas, F. et al. (2021). Contextual-lexicon approach for abusive language detection. In Proc. of the RANLP 2021, pages 1438–1447, Online. INCOMA Ltd.
Vaswani, A. et al. (2017). Attention is All you Need. In Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc.
Wei, J. et al. (2022). Chain-of-thought prompting elicits reasoning in large language models. In Proceedings of the 36th International Conference on Neural Information Processing Systems, NIPS ’22, Red Hook, NY, USA. Curran Associates Inc.
Zhao, W. X. et al. (2023). A survey of large language models. arXiv:2303.18223, 1(2).
Zhou, Y., Muresanu, A. I., Han, Z., Paster, K., Pitis, S., Chan, H., and Ba, J. (2023). Large language models are human-level prompt engineers.

