CDT5058 commited on
Commit
446b42a
·
verified ·
1 Parent(s): 48d4e49

model card: v8 results (golden 0.955/0.958 full-value recall, precision tradeoff noted)

Browse files
Files changed (1) hide show
  1. README.md +78 -13
README.md CHANGED
@@ -19,13 +19,13 @@ pipeline_tag: token-classification
19
  # phi-redact — compact English PII/PHI redaction model
20
 
21
  **phi-redact** is an 11M-parameter BERT-mini token classifier for detecting PII
22
- and PHI in English text. It covers 29 entity types with BIOES labels and is
23
  designed for on-device deployment (ONNX, Core ML, LiteRT) where data must not
24
  leave the device.
25
 
26
  It was knowledge-distilled from a 66M-parameter DistilBERT teacher and trained
27
- on ~157k documents spanning clinical notes, government benefits text, student
28
- essays, and Wikipedia-style prose.
29
 
30
  > **Not a certified de-identification solution.** This model assists redaction
31
  > workflows. It is **not** certified under HIPAA Expert Determination or Safe
@@ -34,16 +34,71 @@ essays, and Wikipedia-style prose.
34
 
35
  ---
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  ## Model details
38
 
39
  | Property | Value |
40
  |---|---|
41
  | Architecture | BERT-mini (google/bert_uncased_L-4_H-256_A-4), 4L/256H/4A |
42
  | Parameters | 11.13M |
43
- | Labels | 121 BIOES tags (30 entity types × 4 positions + O) |
44
  | Max sequence length | 256 tokens |
45
  | Vocabulary | 30,522 WordPiece (bert-base-uncased) |
46
- | fp32 size | 44.5 MB |
 
47
  | fp16 size | 22.3 MB |
48
  | Est. 4-bit Core ML | ~5.6 MB |
49
  | Est. int8 LiteRT | ~11.2 MB |
@@ -52,17 +107,18 @@ essays, and Wikipedia-style prose.
52
 
53
  ---
54
 
55
- ## Entity types (30)
56
 
57
  `NAME_PATIENT` · `NAME_FAMILY` · `NAME_PROVIDER` · `DATE` · `ADDRESS` ·
58
  `PHONE` · `EMAIL` · `SSN` · `MRN` · `HEALTHPLAN` · `ACCOUNT` · `IDNUM` ·
59
  `LICENSE` · `EMPLOYER` · `PROFESSION` · `AGE` · `CITY` · `STATE` · `COUNTRY` ·
60
  `ZIP` · `URL` · `IP` · `DEVICE` · `ROUTING_NUMBER` · `IBAN` · `CREDITCARD` ·
61
- `HOSPITAL` · `FAX` · `PASSPORT` · `VIN`
62
 
63
- > **Note on TAX_ID:** included in the schema design but not in any commercial-safe
64
- > training source for v7 (ai4privacy excluded). TAX_ID predictions will be absent.
65
- > Fix queued for v8 (add EIN templates to `gen_synth.py`).
 
66
 
67
  ---
68
 
@@ -157,7 +213,9 @@ scoring harness, and v7's results: **0.812 full-value recall** (term recall
157
  0.615, precision 0.698, clean-case FP rate 0.120). Perfect 1.000 on
158
  BANK_ACCOUNT, CREDIT_CARD, DRIVERS_LICENSE, EMAIL, PHONE, ROUTING_NUMBER;
159
  weak on NAME (0.347) and ADDRESS (0.333). See the directory README for
160
- methodology and the taxonomy note.
 
 
161
 
162
  ---
163
 
@@ -176,6 +234,8 @@ data was used.
176
  | WikiANN train split (EN) | ~20k | CC-BY-SA 3.0 | Wikipedia person, location, org |
177
  | WNUT-17 train split | ~3.4k | CC-BY 4.0 | Emerging entities in social media |
178
  | Nemotron-PII train split (nvidia) | 50k | CC-BY 4.0 | 30 PII/PHI types in synthetic documents |
 
 
179
 
180
  **Excluded:** ai4privacy/pii-masking-400k (non-commercial license — not used in
181
  training or evaluation). MultiNERD (CC-BY-NC-SA 4.0 — evaluation only, not in
@@ -198,6 +258,8 @@ distill-alpha 0.7, device A100 SXM4-40GB (~6h)
198
 
199
  Knowledge distillation loss = 0.7 × KL(teacher logits ∥ student logits) + 0.3 × cross-entropy.
200
 
 
 
201
  ---
202
 
203
  ## How to use
@@ -214,7 +276,7 @@ text = "Patient Maria Garcia, DOB 1985-03-22, MRN 4471829, called 415-555-0189."
214
 
215
  enc = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
216
  with torch.no_grad():
217
- logits = model(**enc).logits # [1, seq, 117]
218
 
219
  pred_ids = logits.argmax(-1)[0].tolist() # [seq]
220
  id2label = model.config.id2label
@@ -258,6 +320,9 @@ regardless of model confidence.
258
  with lower confidence or disable the entity type if not needed.
259
  - **URL in informal prose** (recall=0.318 on student essays vs 0.828 on formal
260
  text). Check URL recall on your specific document type.
 
 
 
261
  - **Trained on synthetic data.** Real-world typos, OCR noise, and unusual
262
  formatting will degrade performance relative to the benchmarks above.
263
  - **Not a certified de-identification system.** Does not satisfy HIPAA Expert
@@ -274,4 +339,4 @@ legal counsel for commercial deployment.
274
 
275
  ---
276
 
277
- *Card generated 2026-09-25 · Repo: CDT5058/phi-redact*
 
19
  # phi-redact — compact English PII/PHI redaction model
20
 
21
  **phi-redact** is an 11M-parameter BERT-mini token classifier for detecting PII
22
+ and PHI in English text. It covers 32 entity types with BIOES labels and is
23
  designed for on-device deployment (ONNX, Core ML, LiteRT) where data must not
24
  leave the device.
25
 
26
  It was knowledge-distilled from a 66M-parameter DistilBERT teacher and trained
27
+ on ~205k documents (v8 mix) spanning clinical notes, government benefits text,
28
+ student essays, general PII text, and Wikipedia-style prose.
29
 
30
  > **Not a certified de-identification solution.** This model assists redaction
31
  > workflows. It is **not** certified under HIPAA Expert Determination or Safe
 
34
 
35
  ---
36
 
37
+ ## Current version: v8 (2026-10-20)
38
+
39
+ The repo root is **v8**. v7 remains available under versioned names:
40
+ `phi-redact-v7-int8.onnx`, `phi-redact-v7.onnx`, `phi-redact-v7.mlpackage`,
41
+ `phi-redact-v7-fp32.mlpackage`, `phi-redact-v7.tflite`,
42
+ `model-v7.safetensors`, `config-v7.json`, `tags-v7.json`.
43
+
44
+ **What changed in v8**
45
+
46
+ - Two new neural entity types: `GOVERNMENT_ID` and `TAX_ID` (129 BIOES tags,
47
+ 32 entity types). The deterministic rules layer also gained EIN,
48
+ ABA-checksum routing, passport, bank-account, drivers-license, and
49
+ government-ID patterns.
50
+ - Training mix rebuilt (~205k documents) around an extended synthetic
51
+ generator — conversational name introductions, address components as
52
+ spans, boosted structured-ID types — plus the Gravitee PII dataset
53
+ (Apache-2.0; PERSON→NAME_PATIENT, LOCATION→ADDRESS, US_* identifier
54
+ mappings). ai4privacy remains excluded (non-commercial license).
55
+ - Fresh DistilBERT teacher → BERT-mini student distillation run; same
56
+ architecture and parameter count as v7.
57
+
58
+ **Golden 164-case synthetic redaction eval** (rules + neural merge, the
59
+ production configuration; the `evals/synthetic-164/` set):
60
+
61
+ | Metric | v7 | v8 INT8 (shipped artifact) |
62
+ |---|---|---|
63
+ | Full-value recall | 0.885 | **0.958** |
64
+ | Term recall | 0.651 | 0.760 |
65
+ | Precision | 0.749 | 0.695 |
66
+ | Strict span F1 | 0.435 | 0.617 |
67
+ | Clean-case FP rate | 0.120 | 0.440 |
68
+
69
+ The PyTorch checkpoint scores 0.955 full-value recall under the Colab gate
70
+ harness (`evaluate_golden.py`); the INT8 ONNX scores 0.958 under the SDK
71
+ scorer (`score_phi.py`) — same test set, two harnesses, small scorer
72
+ differences. INT8 quantization costs no recall here.
73
+
74
+ **The tradeoff, plainly:** v8 was optimized for recall — a missed
75
+ identifier is a leak; an over-redaction is an annoyance. The cost is
76
+ precision: on clean (no-PII) texts, 44% now pick up at least one flagged
77
+ span vs 12% for v7, typically person/place-like tokens from the broader
78
+ training mix. If your workflow is precision-sensitive, v7 remains
79
+ available above, or raise the neural threshold (0.8 gives clean-case FP
80
+ 0.320 at 0.932 full-value recall on this set).
81
+
82
+ **Standard benchmarks, v8 student (model only, strict span scoring):**
83
+ Learning Agency micro-F1 0.711 (NAME F1 0.746); FewNERD name F1 0.787
84
+ (recall 0.847); MultiNERD name F1 0.895 (recall 0.942); WikiANN name F1
85
+ 0.774 (recall 0.844); govsynth 1.000. The v7 tables below are unchanged
86
+ and remain the Desert Ant comparison baseline; v8 has not been run on
87
+ the Nemotron-PII benchmark yet.
88
+
89
+ ---
90
+
91
  ## Model details
92
 
93
  | Property | Value |
94
  |---|---|
95
  | Architecture | BERT-mini (google/bert_uncased_L-4_H-256_A-4), 4L/256H/4A |
96
  | Parameters | 11.13M |
97
+ | Labels | 129 BIOES tags (32 entity types × 4 positions + O) |
98
  | Max sequence length | 256 tokens |
99
  | Vocabulary | 30,522 WordPiece (bert-base-uncased) |
100
+ | fp32 size | 44.6 MB |
101
+ | ONNX int8 size | 11.3 MB (`phi-redact-v8-int8.onnx`) |
102
  | fp16 size | 22.3 MB |
103
  | Est. 4-bit Core ML | ~5.6 MB |
104
  | Est. int8 LiteRT | ~11.2 MB |
 
107
 
108
  ---
109
 
110
+ ## Entity types (32)
111
 
112
  `NAME_PATIENT` · `NAME_FAMILY` · `NAME_PROVIDER` · `DATE` · `ADDRESS` ·
113
  `PHONE` · `EMAIL` · `SSN` · `MRN` · `HEALTHPLAN` · `ACCOUNT` · `IDNUM` ·
114
  `LICENSE` · `EMPLOYER` · `PROFESSION` · `AGE` · `CITY` · `STATE` · `COUNTRY` ·
115
  `ZIP` · `URL` · `IP` · `DEVICE` · `ROUTING_NUMBER` · `IBAN` · `CREDITCARD` ·
116
+ `HOSPITAL` · `FAX` · `PASSPORT` · `VIN` · `TAX_ID` · `GOVERNMENT_ID`
117
 
118
+ > **v8 note:** `TAX_ID` and `GOVERNMENT_ID` were added in v8 (synthetic EIN /
119
+ > USCIS / A-number templates plus the Gravitee US_ITIN mapping). Dashed and
120
+ > segmented government-ID formats (e.g. Medicare-style `1EG4-TE5-MK73`) are
121
+ > still missed — a known gap.
122
 
123
  ---
124
 
 
213
  0.615, precision 0.698, clean-case FP rate 0.120). Perfect 1.000 on
214
  BANK_ACCOUNT, CREDIT_CARD, DRIVERS_LICENSE, EMAIL, PHONE, ROUTING_NUMBER;
215
  weak on NAME (0.347) and ADDRESS (0.333). See the directory README for
216
+ methodology and the taxonomy note. (Re-measured 2026-10-19 with the shipped
217
+ SDK — fixed marker ids and the current rules — v7 scores 0.885 full-value
218
+ recall on this set; the 0.812 above is the original 2026-10-02 measurement.)
219
 
220
  ---
221
 
 
234
  | WikiANN train split (EN) | ~20k | CC-BY-SA 3.0 | Wikipedia person, location, org |
235
  | WNUT-17 train split | ~3.4k | CC-BY 4.0 | Emerging entities in social media |
236
  | Nemotron-PII train split (nvidia) | 50k | CC-BY 4.0 | 30 PII/PHI types in synthetic documents |
237
+ | Synthetic notes, v8 generator (gen_synth_v8.py) | 20k | Synthetic (ours) | Adds GOVERNMENT_ID, conversational name intros, address components |
238
+ | Gravitee PII (gravitee-io/pii-detection-dataset) | 25k sampled of 175k | Apache-2.0 | PERSON, LOCATION, US identifier types |
239
 
240
  **Excluded:** ai4privacy/pii-masking-400k (non-commercial license — not used in
241
  training or evaluation). MultiNERD (CC-BY-NC-SA 4.0 — evaluation only, not in
 
258
 
259
  Knowledge distillation loss = 0.7 × KL(teacher logits ∥ student logits) + 0.3 × cross-entropy.
260
 
261
+ v8 (2026-10) used the same procedure on the expanded 205k-document mix.
262
+
263
  ---
264
 
265
  ## How to use
 
276
 
277
  enc = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
278
  with torch.no_grad():
279
+ logits = model(**enc).logits # [1, seq, 129]
280
 
281
  pred_ids = logits.argmax(-1)[0].tolist() # [seq]
282
  id2label = model.config.id2label
 
320
  with lower confidence or disable the entity type if not needed.
321
  - **URL in informal prose** (recall=0.318 on student essays vs 0.828 on formal
322
  text). Check URL recall on your specific document type.
323
+ - **Over-redaction on clean text (v8).** Clean-case FP rate 0.440 on the
324
+ synthetic golden set (v7: 0.120). v8 trades precision for recall; see the
325
+ v8 section above before choosing it for precision-sensitive workflows.
326
  - **Trained on synthetic data.** Real-world typos, OCR noise, and unusual
327
  formatting will degrade performance relative to the benchmarks above.
328
  - **Not a certified de-identification system.** Does not satisfy HIPAA Expert
 
339
 
340
  ---
341
 
342
+ *Card generated 2026-09-25 · Updated 2026-10-20 for v8 · Repo: CDT5058/phi-redact*