ppuzio commited on
Commit
3615219
·
verified ·
1 Parent(s): df08a46

Add hybrid PII scripts: nergal.py and frozen scrub_pii.py

Browse files
Files changed (1) hide show
  1. README.md +13 -4
README.md CHANGED
@@ -77,12 +77,21 @@ Union with unchanged rules. Character scores are on gold vs masked characters.
77
 
78
  ## Load
79
 
 
 
80
  ```python
81
- from transformers import AutoModelForTokenClassification, AutoTokenizer
82
- tok = AutoTokenizer.from_pretrained("SlayerLab/NERGAL")
83
- model = AutoModelForTokenClassification.from_pretrained("SlayerLab/NERGAL")
 
 
 
 
 
 
 
84
  ```
85
 
86
- Reproducing the table needs the windowed BIO decoder and regex union (`hybrid.json`: threshold 0.95, gap ids `250002`/`250003`). Vanilla token classification will not match.
87
 
88
  Base weights: [`FacebookAI/xlm-roberta-large`](https://huggingface.co/FacebookAI/xlm-roberta-large) revision `c23d21b0620b635a76227c604d44e43a9f0ee389` (MIT).
 
77
 
78
  ## Load
79
 
80
+ This repo is the PII island: frozen `scrub_pii.py` plus `nergal.py`. `pipeline("token-classification")` will not match. Regex runs on the original text, the model adds spans at 0.95, then the two are unioned and replaced with `[Telefon]` / `[PII]`.
81
+
82
  ```python
83
+ from pathlib import Path
84
+ from huggingface_hub import snapshot_download
85
+
86
+ root = Path(snapshot_download("SlayerLab/NERGAL"))
87
+ import sys
88
+ sys.path.insert(0, str(root))
89
+ from nergal import Nergal
90
+
91
+ nergal = Nergal.from_pretrained(root, local_files_only=True)
92
+ masked, counts = nergal.scrub(text)
93
  ```
94
 
95
+ `hybrid.json` records threshold 0.95 and gap ids `250002` / `250003`.
96
 
97
  Base weights: [`FacebookAI/xlm-roberta-large`](https://huggingface.co/FacebookAI/xlm-roberta-large) revision `c23d21b0620b635a76227c604d44e43a9f0ee389` (MIT).