gravitee-io/detoxify-onnx

🤗 Hugging Face 来源text-classificationapache-2.0278M 参数1.1 GBsafetensors✓ 5 个校验和今天更新
一条命令提交

在你的模型文件夹旁边运行它。它会制作种子、将文件与 Hugging Face 比对,然后提交。你只需开始做种,并粘贴你账户中的密钥。它只读取你的文件,绝不修改。如果愿意,可以先阅读脚本。

curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo gravitee-io/detoxify-onnx ./model-folder
需要做种者 →

Detoxify ONNX 🚀

This project provides an ONNX-exported and quantized version of the Detoxify multilingual model, optimized for runtime inference.
It enables faster and lighter toxicity detection using ONNX Runtime.

🧪 ONNX Evaluation Results

Original Model (using Detoxify lib and ONNX):

Threshold Accuracy Precision Recall F1 AUC-ROC
0.2 0.8408 0.4899 0.8659 0.6257 0.9345
0.4 0.8723 0.5628 0.7577 0.6459 0.9345
0.5 0.8845 0.6073 0.7041 0.6521 0.9345
0.7 0.8954 0.6951 0.5691 0.6258 0.9345
0.9 0.8941 0.8501 0.3780 0.5234 0.9345

Time for 1 threshold evaluation =~ 3 min 30s

Quantized model:

Threshold Accuracy Precision Recall F1 AUC-ROC
0.2 0.8581 0.5249 0.8154 0.6387 0.9306
0.4 0.8809 0.6001 0.6748 0.6353 0.9306
0.5 0.8880 0.6408 0.6179 0.6291 0.9306
0.7 0.8969 0.7467 0.4984 0.5978 0.9306
0.9 0.8869 0.8878 0.3024 0.4512 0.9306

Time for 1 threshold evaluation =~ 2 min 41s

🤗 Usage

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/detoxify-onnx", file_name="model.quant.onnx")
tokenizer = AutoTokenizer.from_pretrained("gravitee-io/detoxify-onnx")

# Tokenize input
text = "Your comment 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 find the full source code, CLI tools, and evaluation scripts in the official GitHub repository.