Introduction
Automated detection of offensive language is a critical component of modern social media moderation. However, the effectiveness of these systems is frequently limited by severe class imbalance in training datasets. Minority categories, such as "hateful" speech, often constitute a tiny fraction of the total data, leading to models that struggle to generalize and often overfit to the majority "normal" class.
The Dager Framework
To address this, we introduce Dager (Data Augmenter), a generation-based data augmentation method designed to produce high-quality synthetic examples for minority classes. Unlike traditional augmentation techniques that rely on simple word substitutions, Dager leverages an off-the-shelf GPT-2 model to generate entirely new, contextually relevant sentences.
The core innovation of Dager lies in its conditional decoding process. Rather than fine-tuning the entire model, Dager steers the generation by updating the model's hidden states using gradients from two specific loss functions:
- Bag-of-Words (BoW) Loss: This pushes the model toward generating text containing class-specific keywords (e.g., the top 500 TF-IDF words for the "hateful" class).
- KL Loss: This ensures the generated text remains fluent and grammatically correct by minimizing the divergence from the original GPT-2 distribution.
Experimental Results
The effectiveness of Dager was evaluated using the Founta et al. (2019) dataset, which contains approximately 100,000 tweets categorized into normal, spam, abusive, and hateful labels.
Performance in Low-Resource Settings
Dager provides the most significant benefits when training data is extremely scarce. For a BERT classifier trained on only 1% of the available dataset, augmenting with Dager-generated data resulted in an absolute Macro-F1 improvement of 11%, rising from 0.3893 to 0.5037.
Label Preservation and Robustness
A key concern with synthetic data is the potential for "label drift," where generated examples lose the semantic properties of the target class. Stress tests revealed that Dager is remarkably robust; even when 50% of the training data was replaced with synthetic examples, the performance drop was less than 5%. This indicates that the generated text successfully preserves the intended class labels.
Architecture-Agnostic Benefits
Dager is not tied to a specific classifier. Experiments across CNN, RNN+Attention, Transformer, and BERT architectures showed consistent improvements, with absolute F1 gains ranging from 1% to 7%. This demonstrates that the synthetic data produced by Dager is universally beneficial for improving offensive language detection.
Conclusion
Dager offers a powerful, efficient way to mitigate class imbalance in toxic language datasets without the need for expensive manual labeling or large-scale model retraining. By steering the decoding process of pre-trained language models, it generates high-quality synthetic data that significantly enhances classifier performance, particularly in the most challenging low-resource scenarios.
Summary updated