Views
No views yet
1from transformers import pipeline
2
3model_path = "citizenlab/distilbert-base-multilingual-cased-toxicity"
4
5toxicity_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
6toxicity_classifier("this is a lovely message")
7> [{'label': 'not_toxic', 'score': 0.9954179525375366}]
8
9toxicity_classifier("you are an idiot and you and your family should go back to your country")
10> [{'label': 'toxic', 'score': 0.9948776960372925}]
11 Accuracy Score = 0.9425
F1 Score (Micro) = 0.9450549450549449
F1 Score (Macro) = 0.8491432341169309