Source-linked AI summary

Towards Efficient and Explainable Hate Speech Detection via Model Distillation

Paloma Piot, Javier Parapar

arXiv:2412.13698v1cs.CL

TL;DR

Hate-speech models often lack interpretability, while large language models are costly to run. This paper distills a larger model into a smaller multi-task model that predicts labels and generates rationales, finding comparable explanation quality and stronger classification performance.

  • Problem

    Many hate-speech models are black boxes that classify content without explaining their decisions, while large language models are computationally costly.

  • Method

    The authors use knowledge distillation and multi-task learning to train a small language model to predict hate-speech labels and generate rationales from a larger model.

  • Results

    The distilled model achieved approximately 0.85 F1, exceeding the Teacher model's 0.78 F1 and delivering explanation correctness close to the Teacher model's 92%.

  • Takeaways & Limitations

    A faster, greener, and more efficient small model can both detect and explain hate speech while improving classification performance over larger models and baselines.

  • Takeaways & Limitations

    The distillation setup assumes access to a large model with strong reasoning capabilities, selected from capable open-source models reported in recent work.

Abstract

from arXiv · show

Automatic detection of hate and abusive language is essential to combat its online spread. Moreover, recognising and explaining hate speech serves to educate people about its negative effects. However, most current detection models operate as black boxes, lacking interpretability and explainability. In this context, Large Language Models (LLMs) have proven effective for hate speech detection and to promote interpretability. Nevertheless, they are computationally costly to run. In this work, we propose distilling big language models by using Chain-of-Thought to extract explanations that support the hate speech classification task. Having small language models for these tasks will contribute to their use in operational settings. In this paper, we demonstrate that distilled models deliver explanations of the same quality as larger models while surpassing them in classification performance. This dual capability, classifying and explaining, advances hate speech detection making it more affordable, understandable and actionable.

1 Introduction

Hate speech is widespread online, while many detection models classify content without explaining their decisions. The paper proposes distilling LLM-generated rationales into smaller models that jointly classify and explain hate speech.

  • Online connectivity has exacerbated the global spread of hate speech, defined here as hostile or discriminatory language targeting groups based on attributes such as race, religion, ethnicity, or gender.
  • Many hate-speech models operate as black boxes and classify content without explaining why it was flagged.
  • The proposed method uses Few-Shot Chain-of-Thought prompts to extract rationales from 70B LLMs and fine-tunes a smaller model with multi-task learning.
  • The approach trains a small language model to predict both hate-speech labels and supporting rationales.
  • The study uses samples from 36 diverse human-curated datasets and evaluates classification against four state-of-the-art models alongside human assessment of rationale quality.

2 Related Work

Prior hate-speech systems increasingly use LLMs and generated explanations, but large models are costly and explanation quality is often not evaluated. This work addresses that gap by assessing both classification and rationale quality.

  • Traditional and recent systems often focus on binary, multicategory, or multilabel classification, while many methods lack explainability.
  • Existing explanation methods mark hateful spans, provide vague rationales, or use LLM-generated features and explanations.
  • Large LLM approaches are costly, motivating knowledge distillation to transfer capabilities to smaller, more efficient models.
  • Previous distillation studies improved classification but did not evaluate the quality of generated explanations.
  • This work evaluates generated rationales for both completeness and correctness in addition to detecting hate speech.

3 Proposal

The proposal transfers knowledge from a Llama-3-70B teacher to a Llama-3-8B student by generating labels and rationales with Few-Shot CoT, then training the student on both tasks.

  • The teacher generates hate-speech labels and rationales with Few-Shot CoT, which are transferred to the smaller student model.
  • Knowledge distillation trains a smaller student model to replicate the behavior of a larger teacher model more efficiently.
  • The rationale-extraction prompt supplies a hate-speech definition and examples pairing input texts, labels, and human-authored rationales.
  • For each dataset instance, the teacher generates both a rationale and classification, producing training targets for the smaller model.
  • Only teacher-generated samples whose labels match the gold labels are retained, and the student learns classification and rationale generation jointly.
  • The rationale-generation objective minimizes token-level cross-entropy over generated rationale sequences.

4 Experiments

The experiments use balanced MetaHate subsamples from 36 datasets and compare a 70B teacher, an 8B student, and other models under computational constraints.

  • 4.1 Datasets: MetaHate contains 1.2 million binary-labelled entries collected from 36 datasets across diverse social networks.
  • 4.1 Datasets: Two balanced subsamples of approximately 2,000 messages preserve equal hate and non-hate counts and the original dataset distribution.
  • 4.1 Datasets: The distillation subset contains 2,296 corrected classified posts, while the evaluation subset contains 2,001 posts.
  • 4.2 Chosen LLMs: The study selects a large reasoning-capable model as teacher and a smaller counterpart as student for knowledge distillation.
  • 4.2 Chosen LLMs: The teacher is Llama-3-70B-Instruct, while the student is Llama-3-8B-Instruct with 8B rather than 70B parameters.

4.3 Experimental Settings

The experiments generate label-and-rationale outputs with a 70B model, then fine-tune an 8B model on these outputs for joint classification and explanation. Evaluation compares the distilled, teacher, and smaller models on classification and explanation tasks.

  • The experimental pipeline uses two steps: rationale generation followed by smaller-model training.The study first generates rationales and labels, then trains the smaller model with them.
  • Llama-3-70B-Instruct generates labels and natural-language rationales from MiniMetaHate Distil using Few-Shot Chain-of-Thought prompting.The prompts include 12 human-authored examples and return classifications with explanatory input fragments.
  • Llama-3-8B-Instruct is fine-tuned on 2296 inferred instances using labels and rationales to learn both hate-speech classification and explanation.Only instances where the larger model’s label matched the available target were included in the described training process.
  • The distilled model is evaluated alongside the 70B teacher and 8B base model, with the distilled model receiving only task instructions at inference.The teacher and base models receive the same Few-Shot CoT examples used for rationale extraction.
  • The evaluation covers separate hate-speech classification and explanation tasks.Classification performance is compared with established hate-speech detection methods, while explanations are evaluated separately.

4.4 Experiment 1: Classification Task

The classification experiment compares the distilled model and base language models with established hate-speech detection baselines. The comparison includes transformer models, an API thresholded at 0.5, and controls against data overlap.

  • The experiment compares the distilled model and base LLMs with four established hate-speech detection baselines.The selected baselines are MetaHateBERT, HateBERT, HateXplain, and Perspective API.
  • MetaHateBERT is retrained without posts overlapping the MiniMetaHate subsamples.The retraining follows the original publication’s steps using bert-base-uncased for 3 epochs, with a learning rate of 5e-5 and batch size 32.
  • HateBERT is included as a well-established baseline trained on Reddit’s RAL-E dataset.The passage describes its established use in hate-speech detection as the reason for comparison.
  • HateXplain detects hate, offensive, and neutral content, with offensive content mapped to non-hate for this binary experiment.This baseline is included despite the study’s binary classification focus.
  • Perspective API scores toxicity from 0 to 1, using a threshold of 0.5 to obtain binary classifications.

4.5 Experiment 2: Explanation Task

The explanation experiment evaluates generated rationales through human annotation. It distinguishes hate speech from non-hate and offensive speech while assessing explanations for coverage and accuracy.

  • Human annotators evaluate generated rationales on a 100-entry subsample per model.The evaluation is designed specifically to assess the quality of explanations produced alongside classifications.
  • The study distinguishes hate speech from offensive speech, defining offensive speech as unacceptable language or targeted offense, including insults, threats, and profanity.

Annotation process

The annotation process defines completeness and correctness as complementary criteria for judging explanations. Three trained expert annotators independently assess blinded outputs, and agreement is reported across the three annotators.

  • Completeness requires an annotation to capture every hateful sentence or fragment in a post.At the post level, completeness is true only when all hate-related sentences or fragments are covered.
  • Correctness measures whether explanations accurately identify and justify why each sentence or fragment is hateful or not.Correctness is evaluated at the sentence or fragment level.
  • Three annotators received guidelines, examples, and hate-speech definitions before training and discussion refined the annotation procedure.They then annotated the full subsample.
  • Inter-annotator agreement is the percentage of instances where all three annotators assign the same label.Completeness agreement is measured at the post level, while correctness agreement is measured at the fragment level.
  • The annotators had expertise in hate speech, mental health, and Explainable AI, and assessed blinded, randomly presented outputs.

5 Results

The distilled model achieved the strongest hate-speech classification performance among the evaluated LLMs and surpassed several established benchmarks. Human evaluation also found its explanations comparable to the teacher model, while its lower resource requirements support a practical deployment pipeline.

  • Classification: The distilled model achieved an F1-score of approximately 0.85, exceeding the teacher model’s 0.78 and the smaller model’s score below 0.75.The paper attributes the improvement over the teacher to fine-tuning on both classification and explanation with over 2000 examples, compared with fewer than 20 teacher examples.
  • Classification: The distilled model surpassed HateBERT, HateXplain, and the Perspective API by approximately 60.4%, 32.9%, and 11.1%, respectively.
  • Explanation: Human evaluation found around 90% agreement for explanation correctness, while complete explanations received at least 95% agreement across the three models.
  • Explanation: The teacher and distilled models achieved complete explanations for all instances, while correctness reached 92% for the teacher and 91% for the distilled model.The small base model reached 97% completeness and 83% correctness.
  • Overall findings: The distilled model matched the teacher in explainability while outperforming it in hate-speech classification.
  • Deployment pipeline: The proposed pipeline uses MetaHateBERT for hate-speech classification and the distilled model to generate explanations for the resulting labels.

6 Conclusion

The study finds that a distilled small model can detect and explain hate speech as effectively as larger models, while improving classification performance and efficiency.

  • The distilled small model matched larger models in both hate-speech detection and explanation quality.Human evaluation found comparable explanation effectiveness, while classification results improved.
  • The distilled model achieved solid classification improvements while being faster, greener, and more efficient.
  • The authors plan to distill additional models, use more examples, and test other prompting strategies.

Computational Resources

The experiments used private infrastructure with an RTX A6000 for 15 hours, producing an estimated 1.94 kgCO2eq of emissions.

  • 15 hours of computation were performed on an RTX A6000 with a 300W TDP.
  • The private infrastructure had a carbon efficiency of 0.432 kgCO2eq/kWh.
  • Estimated total emissions were 1.94 kgCO2eq, with 0 percent directly offset.
Loading 2412.13698v1…