Hostname: page-component-76d6cb85b7-dqfph Total loading time: 0 Render date: 2026-07-16T14:26:28.233Z Has data issue: false hasContentIssue false

Improving hate speech detection with large language models

Published online by Cambridge University Press:  23 January 2026

Natalia Umansky
Affiliation:
Department of Political Science, University of Zurich , Zürich, Switzerland
Maël Kubli
Affiliation:
Department of Political Science, University of Zurich , Zürich, Switzerland
Ana Kotarcic
Affiliation:
Department of History, University of Zurich, Zürich, Switzerland
Laura Bronner
Affiliation:
Immigration Policy Lab, ETH Zurich, Zürich, Switzerland
Selina Kurer
Affiliation:
Immigration Policy Lab, ETH Zurich, Zürich, Switzerland
Philip Grech
Affiliation:
Immigration Policy Lab, ETH Zurich, Zürich, Switzerland
Dominik Hangartner
Affiliation:
Immigration Policy Lab, ETH Zurich, Zürich, Switzerland
Fabrizio Gilardi*
Affiliation:
Department of Political Science, University of Zurich , Zürich, Switzerland
Karsten Donnay
Affiliation:
Department of Political Science, University of Zurich , Zürich, Switzerland
*
Corresponding author: Fabrizio Gilardi; Email: gilardi@ipz.uzh.ch
Rights & Permissions [Opens in a new window]

Abstract

Efforts to curb online hate speech depend on our ability to reliably detect it at scale. Previous studies have highlighted the strong zero-shot classification performance of large language models (LLMs), offering a potential tool to efficiently identify harmful content. Yet for complex and ambivalent tasks like hate speech detection, pre-trained LLMs can be insufficient and carry systemic biases. Domain-specific models fine-tuned for the given task and empirical context could help address these issues, but, as we demonstrate, the quality of data used for fine-tuning decisively matters. In this study, we fine-tuned GPT-4o-mini using a unique corpus of online comments annotated by diverse groups of coders with varying annotation quality: research assistants, activists, two kinds of crowd workers, and citizen scientists. We find that only annotations from those groups of annotators that are better than zero-shot GPT-4o-mini in recognizing hate speech improve the classification performance of the fine-tuned LLM. Specifically, fine-tuning using the highest-quality annotator group – trained research assistants – boosts classification performance by increasing the model’s precision without notably sacrificing the good recall of zero-shot GPT-4o-mini. In contrast, lower-quality annotations do not improve and may even decrease the ability to identify hate speech. By examining tasks reliant on human judgment and context, we offer insights that go beyond hate speech detection.

Information

Type
Research Note
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2026. Published by Cambridge University Press on behalf of European Consortium for Political Research
Figure 0

Table 1. Comparison of annotation quality across various coder groups

Figure 1

Figure 1. F1, precision, and recall of the fine-tuned GPT-4o-mini for binary classification of harmful vs. non-harmful speech across annotator groups, using 100 or 250 training labels. Performance is shown relative to the expert gold standard; vertical lines mark zero-shot performance. Green bars indicate label quality. Error bars show 95% bootstrapped confidence intervals.

Figure 2

Figure 2. Average F1, precision, and recall of the fine-tuned GPT-4o-mini for classifying hate, toxic, and non-harmful speech across annotator groups, using 100 or 250 training labels. Performance is shown relative to the expert gold standard, alongside the label quality per group. Error bars indicate 95% bootstrapped confidence intervals.

Supplementary material: File

Umansky et al. supplementary material

Umansky et al. supplementary material
Download Umansky et al. supplementary material(File)
File 299.4 KB