detoxify
A python library for detecting toxic comments
What it is and what it does
Detoxify is a Python library that wraps pre-trained transformer models to classify text comments for toxic content. It provides three model variants—original, unbiased, and multilingual—each trained on Jigsaw challenge datasets to detect different types of toxicity including threats, obscenity, insults, and identity-based attacks. The models return confidence scores for each toxicity category, allowing developers to programmatically flag harmful content.
The package is built on transformers and PyTorch Lightning, with low installation friction via a pure Python wheel. It's designed for research and content moderation workflows rather than as a production-grade system; the documentation explicitly acknowledges limitations around bias (e.g., flagging swearing regardless of intent) and recommends fine-tuning on carefully constructed datasets for real-world deployment. The multilingual model supports seven languages with documented per-language performance metrics.
Use it for:
- Flag potentially harmful user comments in forums or social platforms for human review by moderators.
- Rank or filter comments in a dataset by toxicity score to prioritize moderation efforts.
- Build a content safety pipeline that rejects or quarantines submissions exceeding a toxicity threshold.
- Analyze multilingual comment datasets across seven languages to identify toxic patterns by region or language.
- Fine-tune the pre-trained models on domain-specific comment data (e.g., gaming, healthcare) to improve detection accuracy.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Detoxify classifies text comments for toxic content using pre-trained transformer models, returning confidence scores across categories like toxicity, obscenity, threats, and identity-based attacks.
Yes, if you need to add toxicity classification to a Python application or research pipeline. The package is actively maintained, has no known vulnerabilities, and offers permissive licensing. However, treat it as a research tool or first-pass filter rather than a production content moderation system—the documentation warns of bias limitations and recommends careful validation and fine-tuning before deployment in high-stakes scenarios.
Install
detoxify on PyPI
pip
pip install detoxifyuv
uv add detoxifypoetry
poetry add detoxifyInstalling detoxify
Before you install
Low friction install with a pure Python wheel. The package is actively maintained with a recent commit on 2026-07-06 and has been in active development since 2020-11-09, suggesting stable ongoing support.
License in practice
Licensed under Apache Software License (permissive), meaning you can use, modify, and distribute the package freely with minimal restrictions, making it suitable for both commercial and research applications.
Quickstart
pip install detoxify
from detoxify import Detoxify
results = Detoxify('original').predict('example text')
results = Detoxify('multilingual').predict(['example text', 'ejemplo de texto'])
Requires transformers, torch, and sentencepiece as runtime dependencies; torch installation may require system-level setup depending on your platform (CPU vs GPU).
Verify before relying
- Whether the multilingual model covers languages beyond the documented seven (English, French, Spanish, Italian, Portuguese, Turkish, Russian).
- Performance characteristics and latency for batch inference on large comment volumes.
- How model predictions handle edge cases like sarcasm, code-switching, or domain-specific terminology.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — transformers, torch, sentencepiece |
| Maintenance | actively maintained — 925 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 110,480/month — #12,457 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: detoxify-0.5.2-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
alt-profanity-checkDetects offensive or profane language in text…
permissive · top 15,000 on PyPI
setfitSetFit fine-tunes Sentence Transformers for…
permissive · top 15,000 on PyPI
GenderizeGenderize is a client library that queries the…
permissive · top 15,000 on PyPI
pytorch-pretrained-bertProvides PyTorch implementations of BERT, GPT,…
permissive · top 15,000 on PyPI
model2vecModel2Vec converts sentence transformers into…
permissive · top 5,000 on PyPI
azure-ai-contentsafetyDetects harmful content in text and images by…
permissive · top 5,000 on PyPI
torchtexttorchtext provides text datasets, preprocessing…
permissive · top 15,000 on PyPI
fasttextfastText is a library for learning word…
permissive · top 5,000 on PyPI
facenet-pytorchProvides pretrained PyTorch models for face…
permissive · top 15,000 on PyPI
bertopicBERTopic performs topic modeling on text…
permissive · top 15,000 on PyPI