Instructions to use OperKH/twitter-xlmr-toxicity-classifier-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use OperKH/twitter-xlmr-toxicity-classifier-ONNX with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-classification', 'OperKH/twitter-xlmr-toxicity-classifier-ONNX');
twitter-xlmr-toxicity-classifier (ONNX)
ONNX export of textdetox/twitter-xlmr-toxicity-classifier, a binary toxicity classifier for 15 languages (Twitter-XLM-RoBERTa large fine-tuned on textdetox/multilingual_toxicity_dataset), for use with Transformers.js and ONNX Runtime. The original repository has PyTorch weights only.
Files
| File | Precision | Transformers.js dtype |
Size |
|---|---|---|---|
onnx/model_quantized.onnx |
int8 (dynamic, per-channel) | q8 |
537 MB |
onnx/model.onnx + onnx/model.onnx_data |
fp32 | fp32 |
2.1 GB |
The weights are those of the original model; nothing was retrained. Changes to config.json:
id2label/label2idwere added following the original model card (0=neutral,1=toxic); the original config has no label namestransformers.js_config.use_external_data_formattells Transformers.js that the fp32 model keeps its weights in a separate.onnx_datafile (ONNX protobuf is capped at 2 GB)
Usage
import { pipeline } from '@huggingface/transformers';
const classifier = await pipeline('text-classification', 'OperKH/twitter-xlmr-toxicity-classifier-ONNX', { dtype: 'q8' });
await classifier('You are amazing!', { top_k: null });
// [{ label: 'neutral', score: 0.999 }, { label: 'toxic', score: 0.001 }]
Use dtype: 'fp32' for the unquantized model.
The scores bunch up close to 0 and 1, so useful decision thresholds tend to be near the ends (for example 0.98 rather than 0.5); pick one on your own data.
Conversion
- Export: 🤗 Optimum
main_export, tasktext-classification, opset 17 - Quantization: ONNX Runtime
quantize_dynamic,QInt8weights, per-channel, MatMul nodes only
On a private sample of ~1,600 Russian/Ukrainian chat messages the int8 model scored the same as the fp32 export (ROC-AUC 0.981 for both), at about a quarter of the size and 2.4× the speed on CPU.
License and credits
Same license as the original model: OpenRAIL++, including its use restrictions. All credit for the model goes to its authors, who prepared it for the TextDetox 2025 Shared Task; please cite their work (see the original model card).
- Downloads last month
- -
Model tree for OperKH/twitter-xlmr-toxicity-classifier-ONNX
Base model
cardiffnlp/twitter-xlm-roberta-large-2022