khaoula-ghz/Cyberbullying-Detection
Multilingual Cyberbullying Detection System
Detecting Abusive Content in English, Arabic & Algerian Darija
An AI-powered system for detecting cyberbullying and abusive content across three languages. Built with transformer models, CNN feature extraction, contrastive learning, and ensemble learning on three datasets.
Performance: English 95.55% F1 • Arabic 68.31% F1 • Algerian Darija 85.84% F1
Try Live Demo • How to Use • Quick Start • Architecture • Datasets ---
Why This Project?
Most cyberbullying detection systems only work in English. This project provides detection for:
- English: Well-resourced language with abundant training data (95.55% F1)
- Arabic: Complex morphology and multiple dialects (68.31% F1)
- Algerian Darija: Extremely low-resource, no standardized written form, first dataset ever created (85.84% F1)
How to Use the App
No coding knowledge required. Just visit the live demo and start analyzing text.
Getting Started (3 Steps)
- Enter your text in English, Arabic, or Algerian Darija
- View results including confidence score and individual model votes
What You'll See
The app provides:
- Clear Verdict: Cyberbullying or Safe
- Confidence Score: 0-100% certainty
- Model Agreement: How many models agree
- Detailed Breakdown: Charts and visualizations
Quick Start
Installation & Running
# Clone and install
git clone https://github.com/khaoula-ghz/Cyberbullying-Detection.git
cd Cyberbullying-Detection
pip install -r requirements.txt
# Run the app
python app.pyOpen http://localhost:7860 in your browser.
Python API
from app import ensemble_predict
# Single prediction
result = ensemble_predict(
text="You're awesome!",
user_selected_lang="auto" # auto-detect or specify 'en', 'ar', 'dz'
)
# Check result
if result['is_cyberbullying']:
print(f"Detected: {result['label']}")
print(f"Confidence: {result['confidence']:.0%}")
else:
print("Safe text")Architecture Overview
Key Components
Transformer Encoders
- Generate rich contextual embeddings
- Pre-trained on massive multilingual corpora
- Fine-tuned on cyberbullying-labeled data
CNN Feature Layer
- Sits on top of transformer embeddings
- Extracts local n-gram patterns
- Specializes in abuse-specific terminology
- Improves detection of obfuscated abuse
Contrastive Learning
- Pulls similar cyberbullying examples together
- Pushes normal text away in embedding space
- Improves generalization to unseen patterns
Ensemble Methods
For each language, we use a different ensemble approach:
- English: Majority voting from 5 models (BERT, BERTweet, RoBERTa, DistilBERT, HateBERT)
- Arabic: Stacking with meta-model from 3 models (AraBERT, MARBERT, QARiB)
- Algerian: Soft voting from 3 models (DziriBERT, DziriBERT-Sentiment, mBERT)
Datasets
All datasets are publicly available for research purposes.
English Dataset
- Source: Twitter/X cyberbullying detection corpus
- Size: ~47,000 labeled tweets
- Labels: Age, Ethnicity, Gender, Religion, Other Cyberbullying, Not Cyberbullying
- Link: Kaggle - Cyberbullying Classification
Arabic Dataset
- Source: Instagram comments and social media posts
- Size: ~47,000 labeled comments
- Labels: Neutral, Positive, Bullying, Toxic
- Dialects: Modern Standard Arabic + regional variations
- Link: Dataset Repository (Accessed: February 3, 2025)
Algerian Darija Dataset (Original Contribution)
- Source: Authentic Algerian social media comments
- Size: ~4,000 manually annotated comments
- Labels: Cyberbullying, Not Cyberbullying
- Language: Algerian Darija (low-resource dialect)
- Significance: First cyberbullying detection dataset for Algerian Darija
- Link: Kaggle - DzBullying Dataset
About the Algerian Dataset: The Algerian Darija dataset was custom-created for this thesis. Since Algerian Darija has no standardized written form, building this dataset required manual annotation of authentic social media comments.
Project Structure
Cyberbullying-Detection/
├── app.py # Gradio web interface
├── models.py # CNN-Transformer architecture
├── language_detector.py # Language identification
├── text_preprocessing.py # Text cleaning pipeline
├── final_meta_model.pkl # Arabic stacking meta-model
├── requirements.txt # Dependencies
└── README.md # This fileDeploy It
Live Demo: https://huggingface.co/spaces/khaoula-ghz/Cyberbullying-Detection
Deploy your own: Create Space on Hugging Face → Connect GitHub repo → Auto-deploys on push ✨
Contributing
Have ideas to improve? We welcome contributions!
- Open an issue for bugs or suggestions
- Submit a pull request
- Email: khaoulaghimouze@gmail.com
Citation
If you use this work in research, please cite:
@mastersthesis{ghimouze2025cyberbullying,
author = {Ghimouze, Khaoula and Kemcha, Rania Rym},
title = {Cyberbullying Detection on Social Media: A Transformer-Based Hybrid Approach},
school = {Constantine 2 University},
year = {2025},
type = {Master's Thesis}
}Datasets:
@dataset{ghimouze2025dzbullying,
author = {Ghimouze, Khaoula and Kemcha, Rania Rym},
title = {DzBullying: Algerian Cyberbullying Detection Dataset},
year = {2025},
howpublished = {Kaggle},
url = {https://www.kaggle.com/datasets/khaoulaghz23/dzbullying-algerian-cyberbullying-dataset}
}License
MIT License – Free to use, modify, and distribute with attribution.
Authors
Khaoula Ghimouze Data Science & NLP Specialist, Constantine 2 University GitHub • Email • Hugging Face
Rania Rym Kemcha Research Collaborator & Co-author
<div align="center">
Built to make online spaces safer
Star us on GitHub • Try the Live Demo
</div>
