Downloads · 30 days
5
1% of all-time downloads
ac8736/toxic-tweets-fine-tuned-distilbert
toxic-tweets-fine-tuned-distilbert is a text classification model from ac8736. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
Multilabel classification model trained on the Toxic Comments dataset from Kaggle. (https://www.kaggle.com/competitions/jigsaw-toxic-comment-classification-challenge/data)
Downloads · 30 days
5
1% of all-time downloads
All-time downloads
937
Public
Parameters
67M
804 MB on disk
Likes
0
Public
Click a slice to open those files.
.bin268 MB · 50%
From the Hugging Face model README
Multilabel classification model trained on the Toxic Comments dataset from Kaggle. (https://www.kaggle.com/competitions/jigsaw-toxic-comment-classification-challenge/data)
Fine tuned using DistilBert.
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained("pretrained_model")
tokenizer = AutoTokenizer.from_pretrained("model_tokenizer")
X_train = ["Why is Owen's retirement from football not mentioned? He hasn't played a game since 2005."]
batch = tokenizer(X_train, truncation=True, padding='max_length', return_tensors="pt")
labels = ["toxic", "severe_toxic", "obscene", "threat", "insult", "identity_hate"]
with torch.no_grad():
outputs = model(**batch)
predictions = torch.sigmoid(outputs.logits)*100
probs = predictions[0].tolist()
for i in range(len(probs)):
print(f"{labels[i]}: {round(probs[i], 3)}%")
Output expected below:
toxic: 0.676%
severe_toxic: 0.001%
obscene: 0.098%
threat: 0.007%
insult: 0.021%
identity_hate: 0.004%