Text Classification
Transformers
ONNX
xlm-roberta
toxicity
toxic detection
text-embeddings-inference
Instructions to use hoan/multilingual-toxic-xlm-roberta-dynamic-quantized with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hoan/multilingual-toxic-xlm-roberta-dynamic-quantized with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="hoan/multilingual-toxic-xlm-roberta-dynamic-quantized")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("hoan/multilingual-toxic-xlm-roberta-dynamic-quantized") model = AutoModelForSequenceClassification.from_pretrained("hoan/multilingual-toxic-xlm-roberta-dynamic-quantized") - Notebooks
- Google Colab
- Kaggle
This ONNX model is a dynamic quantized for the original model: https://huggingface.co/unitary/multilingual-toxic-xlm-roberta
Usage
Using pipeline from the optimum library
from optimum.pipelines import pipeline as pipeline_onnx
quantized_pipeline = pipeline_onnx(
"text-classification",
model="hoan/multilingual-toxic-xlm-roberta-dynamic-quantized",
accelerator="ort",
top_k=None,
function_to_apply="sigmoid"
)
text = """Artificial intelligence (AI), frequently depicted in mainstream media as a harbinger of both groundbreaking innovation and understandable concern, has seamlessly permeated and embedded itself within a multitude of diverse sectors that constitute the intricate tapestry of our contemporary society. This relentless integration spans a wide spectrum, extending from the realms of healthcare, where AI is catalyzing transformative breakthroughs in disease diagnosis, treatment planning, and medical research, to the intricate domain of finance, where algorithms are reshaping the landscape of investment strategies, risk assessment, and market predictions."""
result = quantized_pipeline(text)
The result is:
[[{'label': 'LABEL_0', 'score': 0.0004449746338650584},
{'label': 'LABEL_7', 'score': 0.00035187375033274293},
{'label': 'LABEL_8', 'score': 0.00024698078050278127},
{'label': 'LABEL_4', 'score': 0.00019323475135024637},
{'label': 'LABEL_14', 'score': 0.00015645574603695422},
{'label': 'LABEL_10', 'score': 0.0001484356907894835},
{'label': 'LABEL_2', 'score': 0.0001337601279374212},
{'label': 'LABEL_13', 'score': 0.00011757002357626334},
{'label': 'LABEL_3', 'score': 9.490883530816063e-05},
{'label': 'LABEL_12', 'score': 9.136357402894646e-05},
{'label': 'LABEL_15', 'score': 5.817503551952541e-05},
{'label': 'LABEL_9', 'score': 5.3772881074110046e-05},
{'label': 'LABEL_11', 'score': 3.9219678001245484e-05},
{'label': 'LABEL_5', 'score': 3.468171780696139e-05},
{'label': 'LABEL_6', 'score': 2.4815808501443826e-05},
{'label': 'LABEL_1', 'score': 2.0749821487697773e-05}]]
The mapping for the labels is:
{'LABEL_0': 'toxicity',
'LABEL_1': 'severe_toxicity',
'LABEL_2': 'obscene',
'LABEL_3': 'identity_attack',
'LABEL_4': 'insult',
'LABEL_5': 'threat',
'LABEL_6': 'sexual_explicit',
'LABEL_7': 'male',
'LABEL_8': 'female',
'LABEL_9': 'homosexual_gay_or_lesbian',
'LABEL_10': 'christian',
'LABEL_11': 'jewish',
'LABEL_12': 'muslim',
'LABEL_13': 'black',
'LABEL_14': 'white',
'LABEL_15': 'psychiatric_or_mental_illness'}
- Downloads last month
- 11