Instructions to use Mozilla/smart-pii-redactor-v1-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use Mozilla/smart-pii-redactor-v1-onnx with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('token-classification', 'Mozilla/smart-pii-redactor-v1-onnx');
smart-pii-redactor v1 (ONNX)
Token classifier (XLM-R MiniLM, 6 layers, 20k vocab) that finds identifiers in chat messages. Labels: PERSON, STREET_ADDRESS, DOB, ID_IN_CONTEXT, SECRET_IN_CONTEXT, USERNAME (replace); ORG, PRODUCT, LOCATION, DATE, PUBLIC_NAME (keep). Max 256 tokens per window; the caller splits longer text (stride 32).
Recommended: q4 (dtype: "q4", onnx/model_q4.onnx, 14.8 MB). It loads in older ONNX Runtime
builds too, and costs about 0.1 points of leak recall against fp32.
| File | transformers.js dtype |
Size | Test leak recall | Keep retention |
|---|---|---|---|---|
onnx/model_q4.onnx |
q4 (4-bit weights, recommended) |
14.8 MB | 0.9788 | 0.9497 |
onnx/model_quantized.onnx |
q8 (8-bit weights) |
20.1 MB | 0.9800 | 0.9510 |
onnx/model.onnx |
fp32 |
74.3 MB | 0.9800 | 0.9522 |
onnx/model_uint8.onnx |
uint8 (dynamic; fallback) |
18.8 MB | 0.9654 | 0.9530 |
q8 is stored as model_quantized.onnx, the name transformers.js expects for dtype: "q8". It needs a
recent ONNX Runtime (8-bit MatMulNBits) and does not load in onnxruntime-web 1.22. uint8 is only a
fallback and loses about 1.5 points of leak recall.
All quantized files keep the word embeddings as int8. Scores: v1 on the 10,569-message test set (the project's own test messages plus held-out public rows, 8 languages), model alone: spans of the fixed-format types the rules own (emails, phones, cards, IBANs, ...) are not scored.
Inputs: input_ids, attention_mask. Output: logits (batch, seq, 23).
Fine-tuned from nreimers/mMiniLMv2-L6-H384-distilled-from-XLMR-Large (MIT, Microsoft unilm).
Trained on smart-pii-redactor-data (385,669 messages); its card lists the sources and their licences.
- Downloads last month
- 251