TL;DR
This paper introduces GENES, a novel method for generating counterfactual hate speech examples that better balance attribute alignment and semantic preservation. By combining energy-based sampling with gradient-assisted proposal generation, GENES significantly improves hate speech classifiers, even outperforming larger models and prompt-based methods.
What Problem Does This Paper Address?
Hate speech detection models often struggle with generalizability and can exhibit biases due to issues like imbalanced datasets and skewed topics. Counterfactual Data Augmentation (CDA) is a promising solution, aiming to create synthetic data by modifying existing text to flip a target attribute (e.g., from non-hate to hate speech) while preserving the original meaning. However, automatically generating such counterfactuals is challenging. Existing methods either prioritize attribute control at the expense of meaning or vice-versa. Prompting large language models (LLMs) can be unreliable due to built-in safeguards and the inherent difficulty of generating subjective concepts like "abusiveness." This paper addresses the need for a more reliable, resource-efficient method for counterfactual text generation that can effectively balance attribute alignment and semantic preservation.
Methods
The core contribution is Gradient-assisted Energy-based Sampling (GENES). GENES is a plug-and-play framework that builds upon energy-based models (EBMs) for text generation. Here's a breakdown of its key components:
- Energy-based Model: This model defines an "energy" score for a text based on two components:
- Attribute-based energy ($E_a(X)$): Quantifies how well the text aligns with the desired attribute (e.g., hate speech), using a hate speech classifier.
- Similarity-based energy ($E_s(X, \hat{X})$): Measures how semantically similar the generated text ($\hat{X}$) is to the original text ($X$), using BERTScore and BLEU.
- Truncated EBM Sampling: To ensure semantic preservation, GENES introduces a hard rejection rule based on a minimum BERTScore threshold ($\beta_{min}$). This restricts sampling to proposals that are semantically close to the original text, effectively creating a "truncated" energy-based model.
- Gradient-Assisted Proposal Generation: To overcome the increased rejection rate from truncation and improve attribute alignment, GENES incorporates gradient-based weighted decoding. This technique perturbs the hidden states of the language model during generation to steer it towards the desired attribute while minimizing divergence from the original token distribution. This is achieved by minimizing a loss function that combines attribute energy and KL divergence.
Datasets
- CADD Dataset: Used for training classifiers and evaluating counterfactual text generation quality and data augmentation performance. It contains normal and hate speech comments.
- AbuseEval: A Twitter-based benchmark used for out-of-domain evaluation.
- LatentHate: Another Twitter-based benchmark used for out-of-domain evaluation, noted for its focus on implicit hate speech and group-directed attacks.
Key Insights and Ideas
- The Trade-off is Real: There's an inherent tension between making a text clearly "hateful" and ensuring it still sounds like the original. GENES's success lies in finding a better balance.
- Hard Rejection is Key for Meaning: Simply trying to force attribute alignment can destroy the original meaning. A strict semantic similarity threshold (BERTScore) is crucial for generating useful counterfactuals.
- Gradients Help Overcome Rejection: The "gradient-assisted" part is vital. It helps the model generate better initial proposals that are more likely to pass the semantic filter, making the whole process more efficient.
- Smaller Models Can Compete: GENES, using a smaller Flan-T5-Large model, achieved performance comparable to or better than prompt-based methods using much larger models like GPT-4o-mini. This highlights its efficiency.
- Dataset Specificity Matters: The performance on LatentHate (which focuses on implicit hate and group targeting) was weaker, suggesting that current methods might struggle with nuanced forms of hate speech. Simulating dataset-specific characteristics (e.g., using a LatentHate-trained classifier) can improve performance.
Key Results
- Improved Attribute Alignment & Semantic Preservation: GENES achieved the best macro F1-score in two of three test sets when applied to data augmentation. It demonstrated a better balance between attribute alignment and semantic preservation compared to other methods.
- Enhanced Classifier Robustness: Models augmented with GENES showed improved robustness, particularly in detecting targeted abusive language.
- Competitive Performance: GENES outperformed prompt-based methods using GPT-4o-mini in some cases, despite using a smaller Flan-T5-Large model.
- Efficiency: GENES is presented as a lightweight and open-source alternative.
- Qualitative Findings: GENES generated counterfactuals that were more fluent and similar to the original text compared to methods that strongly enforced attribute control.
Limitations and Future Work
- Classifier Accuracy Dependency: GENES's effectiveness relies on the accuracy of the discriminator (hate speech classifier). Weaker classifiers lead to less reliable attribute control.
- Task and Domain Specificity: Performance might vary across different tasks and domains.
- Nuance in Hate Speech: Current methods, including GENES, may struggle with generating implicit hate speech or capturing specific group targeting. The paper notes that simulating dataset-specific characteristics can help.
- Future Work: The authors suggest exploring more precise control over both the main attribute (hate/abusiveness) and its specific target (e.g., social groups) to better capture the nuances of hate speech. Further human evaluation is also recommended.
Summary updated