saiheinthuyasoe/offensive-language-detector-gradio-interface
0
๐ก๏ธ Offensive Language Detection Model
This Hugging Face Space hosts an offensive language detection model built with DistilBERT. The model can classify text into three categories:
- hate_speech: Content targeting specific groups based on identity (race, religion, gender, etc.)
- offensive_language: General offensive content, insults, or profanity
- neither: Non-offensive content
๐ Features
- Real-time Analysis: Instant classification of text input
- Confidence Scores: Get probability scores for all categories
- Interactive Interface: Easy-to-use Gradio web interface
- Example Texts: Pre-loaded examples to test the model
- Detailed Results: Complete breakdown of predictions
๐ง Model Details
- Base Model: DistilBERT (distilled version of BERT)
- Task: Multi-class text classification
- Classes: 3 (hatespeech, offensivelanguage, neither)
- Framework: Transformers + PyTorch
๐ Usage
- Enter your text in the input box
- Click "Analyze Text" or press Enter
- View the prediction results:
- Predicted category
- Confidence score
- Whether the text is considered offensive
- Probability distribution across all classes
โ ๏ธ Important Notes
- This model is for research and educational purposes
- Always review automated decisions in production systems
- The model may have biases based on its training data
- Consider human oversight for critical content moderation tasks
๐ ๏ธ Technical Implementation
The model uses:
- Tokenizer: DistilBERT tokenizer with 512 max tokens
- Architecture: DistilBERT for sequence classification
- Inference: PyTorch with softmax for probability distribution
- Interface: Gradio for interactive web UI
๐ Example Classifications
- "I love spending time with family" โ neither (high confidence)
- "This movie is terrible" โ offensive_language (medium confidence)
- "You're an idiot" โ offensive_language (high confidence)
- Identity-based attacks โ hate_speech (varies by content)
๐ค Contributing
This model can be improved through:
- Better training data with balanced examples
- Fine-tuning on domain-specific content
- Adjusting classification thresholds
- Adding more nuanced categories
๐ License
MIT License - Feel free to use and modify for your projects.
Built with โค๏ธ using Hugging Face Transformers and Gradio
