Downloads · 30 days
3
7% of all-time downloads
ziadosama/personal-pii-en-bert
personal-pii-en-bert is a machine learning model from ziadosama. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Self-contained NER model that detects PII in Belgian medical documents written in English. Fine-tuned obi/deidberti2b2 (INT8-quantized ONNX) plus a deterministic regex/checksum layer. Trained on 100% synthetic data —…
Downloads · 30 days
3
7% of all-time downloads
All-time downloads
44
Public
Repo size
540 MB
Likes
0
Public
Click a slice to open those files.
.onnx540 MB · 100%
From the Hugging Face model README
Self-contained NER model that detects PII in Belgian medical documents written
in English. Fine-tuned obi/deid_bert_i2b2 (INT8-quantized ONNX) plus a
deterministic regex/checksum layer. Trained on 100% synthetic data — no real
patient records anywhere in its provenance.
pip install onnxruntime transformers
from infer import detect_pii
detect_pii("Patient X, National Registration No. 85.09.12-984.19, Rue de la Loi 16, 5000 Namur")
# -> [{"start": .., "end": .., "label": "INSZ", "text": ".."}, ...]
CLI smoke test: python infer.py (runs a built-in demo) or python infer.py "your text".
| Source | Labels |
|---|---|
| Model (INT8 ONNX) | NAME, DATE, ADDRESS, AGE, PHONE, ORGANIZATION |
Regex + mod-97 checksum (english_regex.py) | INSZ, RIZIV, IBAN, BTW_EENHEID, EMAIL, URL |
The model was trained on the 6 model-owned labels only; the national identifiers
(INSZ/RIZIV), IBAN, VAT, email and URL are handled by the regex layer at
inference and merged in. Both halves are required — the ONNX alone will not
detect INSZ/RIZIV/EMAIL/URL. infer.py merges them (regex-owned labels take
priority on overlap).
model_int8.onnx fine-tuned model, INT8 dynamic-quantized (108 MB)
config.json label map (id -> B-/I- tag) + model config
tokenizer.json fast tokenizer (self-contained)
tokenizer_config.json
english_regex.py the regex/checksum layer (INSZ/RIZIV/IBAN/BTW/EMAIL/URL)
infer.py tokenise (sliding window 512/stride 128) -> ONNX -> BIO
decode -> merge with regex -> spans
To use the fp32 model instead, drop model_fp32.onnx in this folder and set
PII_ONNX=model_fp32.onnx.
INT8 vs fp32: size 431 MB -> 108 MB (-74.8%), ~1.4x faster, strict F1 0.9986 -> 0.9985 (negligible). In-distribution F1 ~0.99; out-of-distribution (hand-authored stress docs) ~0.83 — the documented, expected ceiling.
+32XXXXXXXXX phone can lose the final digit; a URL can include a trailing
period). These slightly under-/over-shoot the span, not the detection.