Downloads · 30 days
2
5% of all-time downloads
lbux/cga-deberta-onnx-int8
cga-deberta-onnx-int8 is a machine learning model from lbux. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
2
5% of all-time downloads
All-time downloads
37
Public
Repo size
126 MB
Likes
0
Public
Click a slice to open those files.
.onnx126 MB · 96%
From the Hugging Face model README
pip install torch transformers optimum onnxruntime
import torch
from optimum.onnxruntime import ORTModelForSequenceClassification
from transformers import AutoTokenizer
model_path = "models/cga_deberta_onnx_int8"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = ORTModelForSequenceClassification.from_pretrained(
model_path,
file_name="model_quantized.onnx"
)
def predict(text: str) -> float:
inputs = tokenizer(
text,
return_tensors="pt",
padding=True,
truncation=True
)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=-1)
toxicity_score = probs[0][1].item()
return toxicity_score
# Example
print(predict("This is an example sentence."))