The Toxic Comment Detector leverages Hugging Face’s unitary/toxic-bert model to identify harmful, offensive, or abusive language in user-generated content. Built with a ReactJS (Vite) frontend and a Flask backend, this tool provides real-time toxicity analysis for enhancing online safety and moderation.
- Toxicity Detection: Classifies user-provided text as "Toxic" or "Non-Toxic".
- Detailed Insights: Provides confidence scores for specific toxic traits like hate speech or profanity.
- Real-Time Feedback: Processes and returns results instantly through an intuitive interface.
- Open-Source and Customizable: Easily extendable for additional features or use cases.
- ReactJS with Vite for a fast and responsive UI.
- Axios for API communication.
- Flask for handling API requests and processing text.
- Hugging Face’s unitary/toxic-bert for toxicity detection.
git clone [email protected]:allanninal/toxic-comment-detector.git
cd toxic-comment-detector
-
Create and activate a virtual environment:
python3.12 -m venv venv source venv/bin/activate # Linux/Mac venv\Scripts\activate # Windows
-
Install dependencies using
requirements.txt
from the backend folder:pip install -r backend/requirements.txt
-
Run the Flask backend:
python backend/app.py
-
Navigate to the
frontend
directory:cd frontend
-
Install dependencies:
npm install
-
Start the React development server:
npm run dev
Visit the app at http://localhost:5173
.
- Input Text: Enter a comment or text to analyze for toxicity.
- Backend Processing: Flask processes the input text using Hugging Face’s
unitary/toxic-bert
model. - Display Results: The frontend shows the toxicity classification and confidence scores in real-time.
- Multi-Language Support: Integrate multilingual models like
xlm-roberta-large
to analyze non-English text. - Custom Toxicity Categories: Allow fine-tuning models for user-defined toxicity classifications.
- Explainability: Provide detailed insights into why a comment is classified as toxic.
- Live Moderation: Integrate real-time toxicity detection with chat systems for instant moderation.
- cardiffnlp/twitter-roberta-base-offensive: Best for social media applications like Twitter.
- facebook/bart-large-mnli: Offers zero-shot classification for custom toxicity categories.
- Perspective API (Google): Provides multi-dimensional toxicity scores for hate speech, threats, and more.
- TextBlob with Custom Rules: A lightweight library for sentiment and basic toxicity analysis.
This project is licensed under the MIT License. See the LICENSE
file for details.
If you find this project helpful, consider supporting me on Ko-fi:
ko-fi.com/allanninal
For more exciting projects, check out my list of AI Mini Projects:
Mini AI Projects GitHub List