Skip to content

Instantly share code, notes, and snippets.

@pemagrg1
Last active March 29, 2022 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pemagrg1/08a84755538df01fa81a18730aa22250 to your computer and use it in GitHub Desktop.
Save pemagrg1/08a84755538df01fa81a18730aa22250 to your computer and use it in GitHub Desktop.
"""
Github Source: https://github.com/unitaryai/detoxify
saving a glimpse of https://www.section.io/engineering-education/building-a-toxicity-classifier/
Toxicity detection using Detoxify
pip install detoxify
"""
from detoxify import Detoxify
predictor = Detoxify('multilingual')
print(predictor.predict('Why are you so fat?'))
"""
OUTPUT: {'identity_attack': 0.0020285994,
'insult': 0.8864248,
'obscene': 0.0039239605,
'severe_toxicity': 9.833861e-05,
'sexual_explicit': 0.0007071728,
'threat': 0.00047757424,
'toxicity': 0.9415722}
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment