CoolFace
Apppublic

saiheinthuyasoe/offensive-language-detector-gradio-interface

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿ›ก๏ธ 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

  1. 1.Enter your text in the input box
  2. 2.Click "Analyze Text" or press Enter
  3. 3.View the prediction results:
  4. 4.Predicted category
  5. 5.Confidence score
  6. 6.Whether the text is considered offensive
  7. 7.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