CoR-Hate: counterfactual retrieval and fairness-regularized hate-speech detection
Abstract
The growing presence of hate speech on social media, targeting groups based on race, religion, gender, and sexual orientation, raises critical concerns regarding fairness and reliability in automated moderation systems. This study introduces CoR-Hate, a fairness-regularized framework that integrates Sentence-Transformer-based semantic retrieval with pretrained transformer models to mitigate algorithmic bias while maintaining strong classification performance. Unlike prior approaches that construct synthetic counterfactuals through identity-term substitutions, manually defined templates, or large-language-model generation, CoR-Hate retrieves corpus-grounded counterfactual proxies from naturally occurring samples using FAISS-based similarity search. A consistency-driven regularization objective is then applied to improve prediction stability across identity-sensitive variations and reduce reliance on identity-specific cues. Comprehensive bias analysis at both entity and pairwise levels is conducted to evaluate fairness robustness across demographic attributes. Experiments on the HateXplain dataset using two Sentence-Transformer variants, all-mpnet-base-v2 and all-MiniLM-L6-v2 , demonstrate consistent improvements over baseline models. Notably, the CoR-Hate BERT model with MPNet embeddings achieves the strongest overall fairness-performance trade-off, attaining an F1-score of 0.79 and an accuracy of 0.80 while reducing the flip rate to 0.10, the lowest among all evaluated models. Furthermore, Grad-CAM-based interpretability provides transparent insights into model behaviour by visualizing token-level importance across identity substitutions. The results indicate reduced sensitivity to identity-specific terms for few evaluated substitutions, although residual bias remains for certain terms and model architectures. Importantly, a lower flip rate reflects prediction consistency only for the predefined identity substitutions and should not be interpreted as evidence that all forms of algorithmic bias have been eliminated. Overall, CoR-Hate provides a unified, corpus-grounded, and explainable framework for mitigating identity-related bias in hate speech detection.