Introduction
Automatic toxicity detection remains a significant challenge in natural language processing. Traditional supervised models often struggle with implicit toxicity—harmful content that lacks explicit "bad words"—and frequently learn spurious correlations, such as associating minority group mentions with toxicity. Furthermore, the high cost and subjectivity of annotating nuanced toxicity data create a scarcity of high-quality training sets. This research explores a "generative" zero-shot approach using Large Language Models (LLMs) like GPT-2 to leverage their latent knowledge of language patterns for toxicity identification.
Methodology
The study compares two primary prompting strategies for zero-shot classification:
- Discriminative Classification: A standard "cloze-test" where the model is asked a binary question (e.g., "Does the above text contain toxic language? Answer: [yes/no]") and the probabilities of the "Yes" and "No" tokens are compared.
- Generative Classification: A novel approach where the model's likelihood of generating the specific input text $x$ is measured under two conditions: a "toxic" guiding prompt ($y^p$, e.g., "Write a text that contains ethnic slurs") and a "benign" guiding prompt ($y^n$, e.g., "Write a text that doesn't contain ethnic slurs"). The text is labeled based on which prompt makes the input more probable.
Additionally, the authors evaluate Task Demonstration, where a few unlabeled examples from the target dataset are included in the prompt to help the model adapt to the specific social media context. The methods were tested on three datasets: SBIC (social bias), HX (hate speech), and Civility (offensive language).
Results and Analysis
The generative approach consistently outperformed discriminative prompting across multiple benchmarks. As shown in the results table, the Generative Cls + demo method achieved the highest Macro-F1 scores on the SBIC (0.60) and HX (0.57) datasets.
Scaling and Robustness
A key finding is the relationship between model size and performance. As GPT-2 models scale from 117M to 774M parameters, the generative approach exhibits a clear upward trend in Macro-F1. In contrast, the discriminative approach remains relatively stagnant or noisy as model size increases. This suggests that modeling the distribution of the text itself is a more scalable way to extract knowledge from LLMs than direct questioning.
The research also highlighted the importance of prompt engineering. For instance, using specific terms like "ethnic slur" instead of generic "hatespeech" significantly improved performance on the HX dataset, indicating that LLMs have specific internal mappings for different types of harm. However, on the Civility dataset, a simple keyword-based "Toxicity Lexicon" performed best (0.65), likely due to the keyword-based nature of the original data collection.
Discussion and Limitations
While promising, the generative approach faces several hurdles. It is highly sensitive to prompt wording; minor changes can lead to significant performance drops. Additionally, calculating log-likelihoods for entire sequences is more computationally intensive than simple binary classification.
Ethically, the study points to a "self-diagnosis paradox": a model's ability to detect toxicity stems from its exposure to toxic data during pre-training. Efforts to completely "de-toxify" training data might inadvertently diminish a model's capacity to identify and filter harmful content in the future. Future work should focus on improving robustness to implicit hate and exploring more complex social bias frames.
Summary updated