yasserrmd commited on
Commit
fdfe983
·
verified ·
1 Parent(s): 5829f7f

ONNX FP16 export of openai/privacy-filter for browser inference

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ onnx/model_fp16.onnx.data filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: openai/privacy-filter
4
+ tags:
5
+ - token-classification
6
+ - pii-detection
7
+ - onnx
8
+ - browser
9
+ - privacy
10
+ - transformers.js
11
+ library_name: transformers
12
+ pipeline_tag: token-classification
13
+ ---
14
+
15
+ # Privacy Filter - ONNX (FP16)
16
+
17
+ FP16 ONNX export of [openai/privacy-filter](https://huggingface.co/openai/privacy-filter)
18
+ for in-browser inference via onnxruntime-web. Detects 8 categories of personally
19
+ identifiable information (PII) and returns BIOES token labels.
20
+
21
+ ## Files
22
+
23
+ - `onnx/model_fp16.onnx` - graph
24
+ - `onnx/model_fp16.onnx.data` - weights (external data, ~2.6 GB)
25
+ - `tokenizer.json`, `tokenizer_config.json`, `special_tokens_map.json` - tokenizer
26
+ - `config.json` - model config with the 33 BIOES label taxonomy
27
+ - `viterbi_calibration.json` - default operating-point biases for the Viterbi decoder
28
+
29
+ ## Label taxonomy (33 classes)
30
+
31
+ Background class `O` plus BIOES tags (`B-`, `I-`, `E-`, `S-`) for 8 span categories:
32
+
33
+ - `account_number`
34
+ - `private_address`
35
+ - `private_date`
36
+ - `private_email`
37
+ - `private_person`
38
+ - `private_phone`
39
+ - `private_url`
40
+ - `secret`
41
+
42
+ ## Usage (browser, onnxruntime-web)
43
+
44
+ ```javascript
45
+ import * as ort from 'onnxruntime-web';
46
+
47
+ const session = await ort.InferenceSession.create(
48
+ 'https://huggingface.co/YOUR_REPO/resolve/main/onnx/model_fp16.onnx',
49
+ { executionProviders: ['webgpu', 'wasm'] }
50
+ );
51
+
52
+ // Tokenize with @huggingface/tokenizers using tokenizer.json from this repo.
53
+ // Feed int64 input_ids and attention_mask. Output is logits [batch, seq, 33].
54
+ // Decode with a constrained BIOES Viterbi pass using viterbi_calibration.json.
55
+ ```
56
+
57
+ Full browser runner (tokenizer + ONNX + Viterbi decoder in JS) is in the
58
+ conversion project's `web/` folder.
59
+
60
+ ## Export notes
61
+
62
+ - Exported with `torch.onnx.export(dynamo=True)` from `transformers>=5.6.0.dev0`
63
+ - MoE blocks (128 experts top-4) rewritten to a dense-weighted-sum form for
64
+ ONNX compatibility while preserving reference math
65
+ - FP16 precision (original is BF16). Keeps int64 inputs/outputs
66
+ - Dynamic axes on batch and sequence length. Practical browser range: 256-4096
67
+ tokens depending on memory
68
+ - Parity vs reference PyTorch: 100% argmax agreement on seed prompts
69
+
70
+ ## License
71
+
72
+ Apache 2.0, same as the base model.
73
+
74
+ ## Acknowledgements
75
+
76
+ Base model by OpenAI. See the
77
+ [original model card](https://huggingface.co/openai/privacy-filter) for
78
+ training details, intended use, and limitations.
onnx/model_fp16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0daae3b14e399f45db0d39b9f73ee2512423a9b7317a72a8534482fec665f51f
3
+ size 1965782
onnx/model_fp16.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7d1002bc3d04553727fc5fa6b7059d93bc5372b3b7ca9d01a0ebfb2f9366327
3
+ size 2798967296