Downloads · 30 days
0
ahmedomuharram/piguard-onnx
piguard-onnx is a text classification model from ahmedomuharram. Use it when you need a label for a piece of text. It is set up for onnxruntime. The card lists the license as mit.
ONNX export of leolee99/PIGuard for prompt injection detection. FP32, opset 20.
Downloads · 30 days
0
Access
Public
Updated Apr 7, 2026
Repo size
1.5 GB
Likes
0
Public
Click a slice to open those files.
.onnx738 MB · 99%
From the Hugging Face model README
ONNX export of leolee99/PIGuard for prompt injection detection. FP32, opset 20.
import numpy as np
import onnxruntime
from tokenizers import Tokenizer
session = onnxruntime.InferenceSession("model.onnx")
tokenizer = Tokenizer.from_file("tokenizer.json")
tokenizer.enable_truncation(max_length=512)
tokenizer.enable_padding(pad_id=0, pad_token="[PAD]", length=512)
encoded = tokenizer.encode("your text here")
logits = session.run(None, {
"input_ids": np.array([encoded.ids], dtype=np.int64),
"attention_mask": np.array([encoded.attention_mask], dtype=np.int64),
})[0]
exp = np.exp(logits - logits.max(axis=1, keepdims=True))
probs = exp / exp.sum(axis=1, keepdims=True)
# probs[0][0] = benign, probs[0][1] = injection
0 — benign1 — injectionExported from leolee99/PIGuard (ACL 2025). See the original repo for training details, benchmarks, and citation.