This project is a RESTful API for automated moderation of user-generated content. It performs binary classification of text input to detect toxic language, insults, and hate speech.
The API delegates inference to hosted models on Hugging Face Inference Endpoints. Each classifier is optimized for a specific moderation task:
- Toxic Comment Classifier – Detects general toxicity.
- Insult Comment Classifier – Detects offensive or insulting language.
- Hate Speech Classifier – Detects hate speech or discriminatory language.
All models are finetuned on labeled datasets and are intended to be used as modular components of the moderation pipeline.
Interactive API documentation is automatically generated via Swagger UI and available at:
/docs/
Each endpoint accepts a POST request with a JSON body containing a single text field.
Example:
{
"text": "You're worthless and stupid."
}The response includes a label and a score (confidence).
- Install the dependencies in a virtual environment:
python -m venv venv
source venv/bin/activate # or .\venv\Scripts\activate on Windows
pip install -r requirements.txt- Create your environment file:
Copy the .env.example to .env and provide the values:
DJANGO_SECRET_KEY=your-secret-key
DJANGO_DEBUG=True
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1- Prepare the backend:
python manage.py migrate
python manage.py collectstatic --noinput- Run the development server:
python manage.py runserverOnce the development server is running, you can access the application in your browser at the URL shown in the terminal.
To prevent abuse, the API uses django-ratelimit to limit excessive requests. Requests exceeding the threshold will receive HTTP 429 responses.
This project is released under the MIT License.
You are free to use, modify, and distribute it — with attribution.
Developed by Francisco Jesús Montero Martínez
For suggestions, improvements, or collaboration, feel free to reach out.