Toxic Language and Threat Detection in Social Media
Bibliographic record
Abstract
Detecting toxic language and threats in social media is a critical task for ensuring safer online interactions and preventing the spread of harmful content. This paper presents a comprehensive approach to toxic language and threat detection using both traditional machine learning and state-of-the-art deep learning models. The study leverages two widely used datasets: the Jigsaw Toxic Comment Classification Dataset, which contains over 150,000 labeled comments categorized as toxic, severe toxic, obscene, threats, insults, and identity hate, and the Hate Speech Dataset, which classifies tweets into hate speech, offensive language, and neutral speech. To develop an efficient detection system, we explore a range of models including traditional classifiers such as Logistic Regression and Naïve Bayes, deep learning architectures like Long Short-Term Memory (LSTM) and Convolutional Neural Networks (CNN), and advanced transformer-based models such as BERT and RoBERTa. Each model is evaluated based on multiple performance metrics, including accuracy, precision, recall, F1-score, and AUC-ROC, to ensure a fair comparison. Our experimental results show that Logistic Regression achieves an overall accuracy of 94%, outperforming Naïve Bayes, which struggles with class imbalance, particularly in detecting minority classes like threats and hate speech. Deep learning models, including LSTM and CNN, improve performance by capturing the sequential structure of text. However, the best results are obtained with transformer-based architectures, where BERT achieves the highest accuracy of 96%, demonstrating its superior ability to capture contextual dependencies in toxic comments. Additionally, our study explores the impact of data preprocessing techniques, including text cleaning, tokenization, lemmatization, and class balancing using SMOTE (Synthetic Minority Over-sampling Technique). Our findings suggest that while classical machine learning models can provide a solid baseline, deep learning and transformers significantly enhance detection capabilities, especially in complex cases involving sarcasm, implicit threats, and nuanced hate speech.
Fetched live from OpenAlex and de-inverted. Abstracts are not stored in this database: the inverted indexes are 8.6 GB of the frame’s 9.3 GB of text, and the host has 13 GB free.
How this classification was reachedexpand
Full frame distilled prediction
Teacher imitationNot calibrated prevalence, not ground truth. Human validation pending. Learned from the 10,348 direct Codex labels and 10,348 direct Gemma labels. Candidate is the union of thresholded teacher heads; consensus is their intersection. These outputs are machine_predicted_unvalidated and are not human labels or direct frontier model labels.
Codex and Gemma teacher scores by category
| Category | Codex | Gemma |
|---|---|---|
| Metaresearch | 0.000 | 0.000 |
| Meta-epidemiology (narrow) | 0.000 | 0.000 |
| Meta-epidemiology (broad) | 0.000 | 0.000 |
| Bibliometrics | 0.000 | 0.001 |
| Science and technology studies | 0.000 | 0.000 |
| Scholarly communication | 0.000 | 0.000 |
| Open science | 0.000 | 0.000 |
| Research integrity | 0.000 | 0.000 |
| Insufficient payload (model declined to judge) | 0.000 | 0.000 |
Machine scores (provisional)
The two teacher heads of the student model, read on this work. A score orders the frame for review; it never asserts a category, and the validation status ships verbatim with every row.
Baseline scores from an immature model (maturity gate not passed, 7 training rounds). Scores rank; they never assert a category.
score_only:v0-immature-baseline · verbatim from the scoring run: score_only means the number may rank works, and no category label ships from itClassification
machine, unvalidatedMachine predicted; a candidate call from one teacher head, not a consensus.
How this classification was reached, model by model and score by score, is at the end of the page under "How this classification was reached".