The rapid proliferation of social networks has led to a surge in harmful online content, including hate speech, which poses significant challenges for automated detection systems in terms of accuracy, generalization, and scalability. This study fine-tunes three transformer-based models—BERT, RoBERTa, and HateBERT—for binary hate speech classification. To mitigate class imbalance, we rebalanced the Jigsaw Toxic Comment Classification dataset, ensuring an equitable distribution of toxic and nontoxic samples. The models were optimized using NLP techniques, including tokenization, learning rate warm-up, mixed precision training, and early stopping, to improve convergence and performance. The experimental results indicate that BERT achieved the highest test accuracy (90.21%) and the F1 score (90.90%), demonstrating superior generalization, while RoBERTa demonstrates competitive performance with a slightly lower accuracy. HateBERT, designed specifically for detecting toxic language, excels in recall but exhibits a lower overall accuracy. An ablation study reveals the impact of mixed-precision training, gradient accumulation, and early stopping on model performance. Furthermore, our error analysis highlights the trade-offs between false positives and false negatives across models, with HateBERT providing a more balanced error distribution. Computational efficiency is also considered, with BERT requiring longer training times than HateBERT but converging faster than RoBERTa. A comparative evaluation against existing hate speech detection models highlights the effectiveness of fine-tuned transformer models in identifying harmful content across social media platforms. These findings emphasize the importance of exploiting transformer architectures to develop scalable, high-accuracy hate speech detection systems that can contribute to safer online spaces.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Evaluating Transformer-Based Models for Hate Speech Detection: A Comparative Study

  • Hardi Joshi,
  • Pankti Sheta,
  • Miral Patel

摘要

The rapid proliferation of social networks has led to a surge in harmful online content, including hate speech, which poses significant challenges for automated detection systems in terms of accuracy, generalization, and scalability. This study fine-tunes three transformer-based models—BERT, RoBERTa, and HateBERT—for binary hate speech classification. To mitigate class imbalance, we rebalanced the Jigsaw Toxic Comment Classification dataset, ensuring an equitable distribution of toxic and nontoxic samples. The models were optimized using NLP techniques, including tokenization, learning rate warm-up, mixed precision training, and early stopping, to improve convergence and performance. The experimental results indicate that BERT achieved the highest test accuracy (90.21%) and the F1 score (90.90%), demonstrating superior generalization, while RoBERTa demonstrates competitive performance with a slightly lower accuracy. HateBERT, designed specifically for detecting toxic language, excels in recall but exhibits a lower overall accuracy. An ablation study reveals the impact of mixed-precision training, gradient accumulation, and early stopping on model performance. Furthermore, our error analysis highlights the trade-offs between false positives and false negatives across models, with HateBERT providing a more balanced error distribution. Computational efficiency is also considered, with BERT requiring longer training times than HateBERT but converging faster than RoBERTa. A comparative evaluation against existing hate speech detection models highlights the effectiveness of fine-tuned transformer models in identifying harmful content across social media platforms. These findings emphasize the importance of exploiting transformer architectures to develop scalable, high-accuracy hate speech detection systems that can contribute to safer online spaces.