martin-ha/toxic-comment-model

text classificationtransformersentransformerspytorchdistilberttext-classificationenendpoints_compatible
272.6K

Model description

This model is a fine-tuned version of the DistilBERT model to classify toxic comments.

How to use

You can use the model with the following code.

from transformers import AutoModelForSequenceClassification, AutoTokenizer, TextClassificationPipeline

model_path = "martin-ha/toxic-comment-model"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSequenceClassification.from_pretrained(model_path)

pipeline =  TextClassificationPipeline(model=model, tokenizer=tokenizer)
print(pipeline('This is a test text.'))

Limitations and Bias

This model is intended to use for classify toxic online classifications. However, one limitation of the model is that it performs poorly for some comments that mention a specific identity subgroup, like Muslim. The following table shows a evaluation score for different identity group. You can learn the specific meaning of this metrics here. But basically, those metrics shows how well a model performs for a specific group. The larger the number, the better.

subgroupsubgroup_sizesubgroup_aucbpsn_aucbnsp_auc
muslim1080.6890.8110.88
jewish400.7490.860.825
homosexual_gay_or_lesbian560.7950.7060.972
black840.8660.7580.975
white1120.8760.7840.97
female3060.8980.8870.948
christian2310.9040.9170.93
male2250.9220.8620.967
psychiatric_or_mental_illness260.9240.9070.95

The table above shows that the model performs poorly for the muslim and jewish group. In fact, you pass the sentence "Muslims are people who follow or practice Islam, an Abrahamic monotheistic religion." Into the model, the model will classify it as toxic. Be mindful for this type of potential bias.

Training data

The training data comes this Kaggle competition. We use 10% of the train.csv data to train the model.

Training procedure

You can see this documentation and codes for how we train the model. It takes about 3 hours in a P-100 GPU.

Evaluation results

The model achieves 94% accuracy and 0.59 f1-score in a 10000 rows held-out test set.

DEPLOY IN 60 SECONDS

Run toxic-comment-model on Runcrate

Deploy on H100, A100, or RTX GPUs. Pay only for what you use. No setup required.