Detoxify is a Python library for detecting toxic comments using pre-trained transformer models. It provides a simple interface to classify text as toxic, severe toxic, obscene, threat, insult, identity hate, etc. The latest version is 0.5.2, with releases approximately every few months. It requires Python >=3.7 and supports Hugging Face transformers.
pip install detoxifyVerified import paths — ran on the pinned version, not inferred.
Loads the 'original' toxic comment model and predicts toxicity scores for a sample sentence.
Specify a model name explicitly: Detoxify('unbiased')Use the "toxicity" score directly; the library already applies a threshold for classification if needed. Check the `predict` method's threshold parameter.
Pre-download models using `detoxify.download_model('original')` before offline use, or set a local cache directory.Switch to Detoxify('unbiased') or Detoxify('multilingual').Run 'pip install detoxify' in your environment.
Ensure internet is available on first run, or pre-download the model using detoxify.download_model('original') while connected.Use 'from detoxify import Detoxify' to import the class.