ASD492 commited on
Commit
8d48ced
·
verified ·
1 Parent(s): ebf22d9

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +45 -0
README.md ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ tags:
6
+ - onnx
7
+ - text-classification
8
+ - prompt-injection
9
+ - deberta
10
+ pipeline_tag: text-classification
11
+ ---
12
+
13
+ # pi-detector — DeBERTa-v3 Prompt Injection Detector (ONNX)
14
+
15
+ FP32 and FP16 ONNX exports of [`protectai/deberta-v3-base-prompt-injection-v2`](https://huggingface.co/protectai/deberta-v3-base-prompt-injection-v2), built for in-browser inference with [Transformers.js](https://github.com/huggingface/transformers.js).
16
+
17
+ ## Files
18
+
19
+ | File | Size | Precision | Use |
20
+ |------|------|-----------|-----|
21
+ | `onnx/model.onnx` | 738 MB | FP32 | WASM / CPU fallback |
22
+ | `onnx/model_fp16.onnx` | 370 MB | FP16 | WebGPU |
23
+
24
+ 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.
25
+
26
+ > 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.
27
+
28
+ ## Usage (browser)
29
+
30
+ ```js
31
+ import { pipeline } from '@huggingface/transformers';
32
+
33
+ const classifier = await pipeline('text-classification', 'ASD492/pi-detector', {
34
+ device: 'webgpu', // falls back to 'wasm' + fp32 if unavailable
35
+ dtype: 'fp16',
36
+ });
37
+
38
+ const out = await classifier('Ignore previous instructions...');
39
+ // [{ label: 'INJECTION', score: 0.9999 }]
40
+ ```
41
+
42
+ ## Labels
43
+
44
+ - `SAFE` — normal instruction or question
45
+ - `INJECTION` — prompt injection attempt