Cracking the Code: Enhancing Implicit Hate Speech Detection through Coding Classification

Lu Wei, Liangzhi Li, Tong Xiang, Liu Xiao, Noa Garcia

TL;DR

This paper introduces "codetypes," a novel taxonomy of rhetorical strategies used in implicit hate speech (im-HS), to improve detection by Large Language Models (LLMs). By integrating these codetypes into prompts or embeddings, the authors demonstrate significant improvements in im-HS detection accuracy across both Chinese and English datasets, offering a more nuanced approach to a challenging NLP problem.

What Problem Does This Paper Address?

Hate speech (HS) is a pervasive issue online, but while explicit hate speech (ex-HS) is relatively straightforward to detect, implicit hate speech (im-HS) poses a significant challenge. Im-HS uses subtle language, sarcasm, and insinuation to convey prejudice, making it harder for automated systems to identify. Existing methods often struggle with these nuanced forms, and there's a lack of a fine-grained taxonomy that explains why im-HS is implicit. This paper aims to bridge this gap by developing a structured way to understand and detect im-HS, moving beyond simple classification to understanding the underlying linguistic mechanisms.

Methods

The core contribution of this paper is the introduction of a "codetype taxonomy" for im-HS. This taxonomy defines six rhetorical strategies (codetypes) that are commonly used to encode implicit hate. The authors developed this taxonomy through a systematic process involving linguistic analysis and filtering based on Chinese and English Wikipedia.

They then propose two main methods for integrating these codetypes into LLM-based im-HS detection:

  1. Prompt-based Method: LLMs are directly prompted with the text and the identified codetypes. This can involve simply including the codetype names or providing more context like explanations and examples.
  2. Embedding-based Method: LLMs are used as frozen encoders. The hidden states from the LLM's inner layers are extracted as features and then fed into a separate classifier (like logistic regression). Three strategies are proposed for constructing these embeddings, varying how codetype information is combined with the input text.

Datasets

The authors evaluated their methods on three datasets:

  • ToxiCN: A Chinese dataset derived from online platforms covering sensitive topics like gender, race, and LGBTQ+ issues.
  • Latent-hatred: An English dataset consisting of tweets from online hate groups and their followers.
  • ISHate: An English dataset that builds upon existing ones to provide a more nuanced categorization of HS, including implicit and subtle forms.

Key Insights and Ideas

  • Codetypes are Crucial for Im-HS: The research strongly suggests that understanding the specific rhetorical strategies (codetypes) used in im-HS is key to improving detection. Simply having a taxonomy isn't enough; integrating this knowledge into LLMs is what drives performance gains.
  • Embedding-based Methods Outperform Prompting: For im-HS detection, embedding-based methods, which leverage LLMs as feature extractors, generally show more significant and consistent improvements over baselines compared to prompt-based methods.
  • Less is Sometimes More (for Prompts): When using codetypes in prompts, providing too much information (e.g., Name+Samp+Expl) can sometimes lead to overcorrection and worse performance. Simpler combinations, like just the codetype name or name with a sample, can be more effective, acting as a form of few-shot learning.
  • Cross-Lingual Applicability: The identified codetypes are effective in both Chinese and English datasets, suggesting that these rhetorical strategies are not language-specific and can be generalized.
  • Model Differences Matter: Different LLMs (e.g., Baichuan2 vs. Llama2) exhibit varying performance, with Llama2 models often showing superior results, especially on English datasets.

Key Results

  • The introduction of codetype information consistently improved im-HS detection performance across all three datasets and models.
  • The embedding-based methods showed substantial improvements over baselines, with an average F1 score increase of 5.63% for one method (E_II) and 5.09% for another (E_III) compared to a baseline without codetypes.
  • One specific combination, Llama2-Chinese-7B-Chat with the E_II method, achieved approximately a 7.5% F1 score increase on the Latent-hatred dataset.
  • The best overall F1 score reported was 0.8091 using Llama2-Chinese-13B-Chat with the Name+Samp+Expl codetype combination and the E_II embedding method on the ISHate dataset.
  • Embedding-based methods generally performed better on the Chinese dataset (ToxiCN: 0.7598) than on English datasets (Latent-hatred: 0.6121, ISHate: 0.6062).

Limitations and Future Work

The authors acknowledge several limitations:

  • Taxonomy Comprehensiveness: The current codetype taxonomy might not cover all possible implicit hate speech encoding strategies, and its applicability across diverse linguistic contexts needs further exploration.
  • Handling Complex Im-HS: The methodology has limited capability in handling highly complex im-HS instances.
  • Dynamic Codetype Determination: Future work could focus on developing models that can dynamically determine appropriate codetypes based on the input sentence, rather than relying on pre-assigned ones.
  • Multi-Codetype Statements: For statements containing more than two codetypes, further optimization is needed, potentially through chain-of-thought prompting.
  • Ethical Considerations: The authors highlight the risk of psychological distress to readers from offensive examples and the potential for LLMs to misuse these examples for harmful discourse. They emphasize that their goal is to improve im-HS detection accuracy.

Summary updated

BibTeX
@inproceedings{wei2025cracking,
  author = {Lu Wei and Liangzhi Li and Tong Xiang and Liu Xiao and Noa Garcia},
  title = {{Cracking the Code: Enhancing Implicit Hate Speech Detection through Coding Classification}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
}
Figure