Logo Lanfrica

0khacha/darija-toxicity-detection

Domain:

natural language processing

Record type:

modelsoftware
Creator:
0kh
Host:
NLP pipeline for toxicity detection in Moroccan Darija and Arabizi. Powered by a fine-tuned ArabERT model, it robustly detects detects bad words, insults, hate speech, and evasion attempts. # Darija Toxicity Detection πŸ›‘οΈ A specialized NLP pipeline for detecting toxic content (bad words, insults, hate speech, spam) in **Moroccan Darija** and **Arabizi** using transformer-based models. This project tackles the unique challenge of "Arabizi" (Arabic chat alphabet latin), where numbers are used as letters (e.g., `3` for `ΨΉ`, `7` for `Ψ­`) and informal spelling is common. ## 🌟 Features - **πŸ€– Pre-trained Model**: Zero-setup inference using models hosted on Hugging Face Hub. - **🌍 Multi-Lingual Support**: Robust handling of Darija mixed with Arabic, English, French, and Tamazight. - **πŸ“š Rich Dataset**: Trained on over **16,000 Darija/Arabizi sentences** covering diverse social contexts. - **🧹 Advanced Cleaning**: Specialized preprocessing for Arabizi patterns (e.g., `in3al` detection, repetitive characters). - **⚑ Fast Inference**: GPU-accelerated predictions with granular confidence scores. - **🎯 High Accuracy**: Fine-tuned specifically on a curated Moroccan Darija dataset. ## πŸš€ Quick Start ### Installation ```bash # Clone the repository git clone github.com cd darija-toxicity-detection # Install dependencies pip install -r requirements.txt ``` ### Basic Usage ```python from src.predict import DarijaPredictor # Initialize predictor (downloads model from Hugging Face) predictor = DarijaPredictor() # Predict toxicity label, probs = predictor.predict_toxicity("salam khouya") print(f"Label: {label}") print(f"Confidence: {probs[label]:.2%}") ``` ### Interactive Mode ```bash python test_pipeline.py ``` ### Demo Script ```bash python run_project.py ``` ## πŸ“– Usage Examples ### Single Prediction ```python from src.predict import DarijaPredictor predictor = DarijaPredictor() label, probs = predictor.predict_toxicity("bghit nakol") print(f"Prediction: {label}") print(f"Probabilities: {probs}") # Output: Prediction: Safe # Probabilities: {'Safe': 0.9845, 'Toxic': 0.0155} ``` ### Batch Processing ` …