CoolFace
Modelpublic

ASD492/pi-detector

sourceHugging Facemitupdated 2mo agoView on Hugging Face
0likes9downloads
Model Card

pi-detector — DeBERTa-v3 Prompt Injection Detector (ONNX)

FP32 and FP16 ONNX exports of `protectai/deberta-v3-base-prompt-injection-v2`, built for in-browser inference with Transformers.js.

Files

FileSizePrecisionUse
onnx/model.onnx738 MBFP32WASM / CPU fallback
onnx/model_fp16.onnx370 MBFP16WebGPU

The FP16 export was produced with onnxconverter-common (convert_float_to_float16, keep_io_types=True, shape inference disabled) plus a type-directed repair pass: 77 Cast nodes were inserted at FP16/FP32 boundaries (relative-position constants and mask paths stay FP32) and stale value_info entries were stripped. Logits match FP32 to ~0.6% relative error with identical argmax on all tested samples.

Note: the FP16 model requires WebGPU (or an ORT build with FP16 support). The WASM EP of onnxruntime-web currently fails LayerNorm fusion on this graph, hence the FP32 copy for WASM.

Usage (browser)

js
import { pipeline } from '@huggingface/transformers';

const classifier = await pipeline('text-classification', 'ASD492/pi-detector', {
  device: 'webgpu',   // falls back to 'wasm' + fp32 if unavailable
  dtype: 'fp16',
});

const out = await classifier('Ignore previous instructions...');
// [{ label: 'INJECTION', score: 0.9999 }]

Labels

  • SAFE — normal instruction or question
  • INJECTION — prompt injection attempt