CoolFace
Modelpublic

onnx-community/distilbert-multilingual-toxicity-classifier-ONNX

sourceHugging Faceopenrail++updated 7mo agoView on Hugging Face
0likes320downloads
Model Card

distilbert-multilingual-toxicity-classifier (ONNX)

This is an ONNX version of gravitee-io/distilbert-multilingual-toxicity-classifier. It was automatically converted and uploaded using this Hugging Face Space.

Usage with Transformers.js

See the pipeline documentation for text-classification: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.TextClassificationPipeline


distillbert-multilingual-toxicity-classifier

This is a DistilBERT-based multilingual toxicity classifier fine-tuned using the gravitee-io/textdetox-multilingual-toxicity-dataset. The model supports a wide range of languages and is trained for toxicity classification ("not-toxic", "toxic").

We perform an 85/15 train-test split per language based on the textdetox dataset. All credits go to the authors of the original corpora.

Performance Overview

Original model

LanguageValidation F1Training F1ΔF1
Russian0.95720.9897-0.0324
English0.95280.9853-0.0325
Hindi0.92480.9599-0.0351
Armenian0.65130.6915-0.0402
French0.94460.9874-0.0428
Tatar0.92000.9682-0.0482
Ukrainian0.89970.9511-0.0514
Japanese0.86580.9253-0.0595
German0.89040.9547-0.0643
Spanish0.85640.9399-0.0835
Chinese0.68650.7807-0.0942
Arabic0.75630.8550-0.0987
Italian0.82230.9271-0.1048
Hinglish0.72340.8533-0.1299
Hebrew0.64550.8441-0.1987

Quantized model (ONNX)

LanguageVal F1Quantized Val F1Δ Val F1Train F1Quantized Train F1Δ Train F1
Russian0.95720.9609+0.00370.98970.9875−0.0022
English0.95280.9495−0.00330.98530.9857+0.0004
German0.89040.8842−0.00620.95470.9369−0.0178
Hindi0.92480.8940−0.03000.95990.9335−0.0264
French0.94460.9351−0.00950.98740.9814−0.0060
Japanese0.86580.8584−0.00740.92530.9081−0.0172
Ukrainian0.89970.8988−0.00090.95110.9476−0.0035
Tatar0.92000.9148−0.00520.96820.9631−0.0051
Amharic0.65130.6377−0.01360.69150.6863−0.0052
Spanish0.85640.8439−0.01250.93990.9273−0.0126
Chinese0.68650.6697−0.01680.78070.7596−0.0211
Arabic0.75630.7535−0.00280.85500.8481−0.0069
Italian0.82230.8033−0.01900.92710.9193−0.0078
Hinglish0.72340.7260+0.00260.85330.8436−0.0097
Hebrew0.64550.6190−0.02650.84410.8204−0.0237

The quantized model maintains high accuracy and generalization on the evaluation set, with negligible performance loss for most languages.

🤗 Usage

python
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSequenceClassification
import numpy as np

# Load model and tokenizer using optimum
model = ORTModelForSequenceClassification.from_pretrained(
 "gravitee-io/distilbert-multilingual-toxicity-classifier",
 file_name="model.quant.onnx"
)
tokenizer = AutoTokenizer.from_pretrained("gravitee-io/distilbert-multilingual-toxicity-classifier")

# Tokenize input
text = "Your text here"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)

# Run inference
outputs = model(**inputs)
logits = outputs.logits

# Optional: convert to probabilities
probs = 1 / (1 + np.exp(-logits))
print(probs)

Github Repository

You can check details on how the model was fine-tuned and evaluated on the Github Repository

License

This model is licensed under OpenRAIL++

Citation

bibtex
@inproceedings{dementieva2024overview,
  title={Overview of the Multilingual Text Detoxification Task at PAN 2024},
  author={Dementieva, Daryna and Moskovskiy, Daniil and Babakov, Nikolay and Ayele, Abinew Ali and Rizwan, Naquee and Schneider, Frolian and Wang, Xintog and Yimam, Seid Muhie and Ustalov, Dmitry and Stakovskii, Elisei and Smirnova, Alisa and Elnagar, Ashraf and Mukherjee, Animesh and Panchenko, Alexander},
  booktitle={Working Notes of CLEF 2024 - Conference and Labs of the Evaluation Forum},
  editor={Guglielmo Faggioli and Nicola Ferro and Petra Galu{{s}}{{c}}{'a}kov{'a} and Alba Garc{'i}a Seco de Herrera},
  year={2024},
  organization={CEUR-WS.org}
}

@inproceedings{dementieva-etal-2024-toxicity,
  title = "Toxicity Classification in {U}krainian",
  author = "Dementieva, Daryna and Khylenko, Valeriia and Babakov, Nikolay and Groh, Georg",
  booktitle = "Proceedings of the 8th Workshop on Online Abuse and Harms (WOAH 2024)",
  month = jun,
  year = "2024",
  address = "Mexico City, Mexico",
  publisher = "Association for Computational Linguistics",
  url = "https://aclanthology.org/2024.woah-1.19/",
  doi = "10.18653/v1/2024.woah-1.19",
  pages = "244--255"
}

@inproceedings{DBLP:conf/ecir/BevendorffCCDEFFKMMPPRRSSSTUWZ24,
  author = {Janek Bevendorff and et al.},
  title = {Overview of {PAN} 2024: Multi-author Writing Style Analysis, Multilingual Text Detoxification, Oppositional Thinking Analysis, and Generative {AI} Authorship Verification - Extended Abstract},
  booktitle = {ECIR 2024, Glasgow, UK, March 24-28, 2024, Proceedings, Part {VI}},
  series = {Lecture Notes in Computer Science},
  volume = {14613},
  pages = {3--10},
  publisher = {Springer},
  year = {2024},
  doi = {10.1007/978-3-031-56072-9_1}
}