Back to Projects
NLP / Deep Learning· 2024

Hate Speech Detection

GRU vs BERT comparison for social media content moderation

91%
BERT Accuracy
0.97
ROC AUC
26.9K
Dataset Size
3
Classes
Problem

Social media platforms struggle to effectively moderate harmful content at scale. Manual moderation is slow and inconsistent, while basic keyword filtering misses contextual hate speech.

Solution

Implemented and compared two deep learning architectures — GRU and BERT — for classifying tweets into hate speech, offensive language, and neutral content. BERT achieved 91% accuracy with superior contextual understanding.

Tech Stack

PyTorchTensorFlowHuggingFace Transformersscikit-learnPandasNumPy

Key Features

Multi-stage text preprocessing with lemmatization and POS tagging
Custom GRU model with embedding layer and dropout regularization
Fine-tuned BERT (bert-base-uncased) for sequence classification
Comprehensive evaluation with confusion matrices and ROC curves

Results

BERT achieved 91% accuracy vs GRU's 87%

ROC AUC of 0.97 for BERT — excellent discrimination ability

BERT F1-score of 0.91 vs GRU's 0.85

Visualizations

ROC Curve — GRU (AUC 0.966) vs BERT (AUC 0.977)

ROC Curve — GRU (AUC 0.966) vs BERT (AUC 0.977)

Model Comparison
GRU Confusion Matrix — Hate Speech vs Offensive vs Neither

GRU Confusion Matrix — Hate Speech vs Offensive vs Neither

BERT Confusion Matrix — Higher accuracy across all classes

BERT Confusion Matrix — Higher accuracy across all classes