Fine-tuned
microsoft/deberta-v3-base for Named Entity Recognition targeting 27 PII entity types. Trained on the English subset of
ai4privacy/pii-masking-300k with a class-weighted
CrossEntropyLoss. Achieves
0.9557 macro-F1 on the validation set.
1from transformers import pipeline
2
3pipe = pipeline(
4 "token-classification",
5 model="bengid/pii-redaction-deberta-base",
6 aggregation_strategy="first",
7 device=0 # omit for CPU
8)
9
10text = "She lives at 742 Evergreen Terrace, Springfield, IL 62704."
11entities = pipe(text)
12print(entities)
Filtered subset of
ai4privacy/pii-masking-300k,
restricted to
English-language examples only (
language == "en").
The full dataset is multilingual; this model targets English text only.
Two-phase Fine-tuning (frozen backbone → unfrozen) from
microsoft/deberta-v3-base using a weighted token-classification trainer and stage-specific learning rates.
Evaluated on the English validation subset (3,973 examples) at the best checkpoint.
-
English only — trained exclusively on English text; performance on other languages is undefined.
-
Max 512 tokens — inherited from DeBERTa's positional embeddings. Longer documents should be chunked.
-
Name entities are harder — The model underperforms on GIVENNAME and LASTNAME entities:
Likely causes: performance correlates strongly with training support —
LASTNAME1/GIVENNAME1 (primary occurrences, ~900-1100 examples) score
significantly higher than LASTNAME2/3 (secondary/tertiary occurrences,
105-313 examples). Additionally, names are inherently context-dependent:
without surrounding cues like titles or formal structure, the model has
less signal to distinguish them from non-PII tokens — even the
best-supported name entities (LASTNAME1, GIVENNAME1) fall notably below
the macro F1 of 0.9557, suggesting names are a structurally harder
category regardless of support.
-
Not a redaction tool by itself — this model detects and labels PII spans; downstream redaction/masking logic must be implemented separately.
-
Subword labeling convention — following the HuggingFace token classification convention, only the first subword of each word was assigned its NER label during training; continuation subwords were assigned -100 (ignored by the loss). The practical consequence is that the model predicts O with high confidence on continuation subwords, which can cause partial detection of multi-subword entities (e.g. john@example.com returned as only john) when using aggregation_strategy="simple". Use aggregation_strategy="first" for inference, which is consistent with this training convention.
The model weights are released for research and non-commercial use,
consistent with the training data license
(
ai4privacy/pii-masking-300k).
Users should review the dataset license before commercial deployment.
If you use this model, please cite the base model architecture and the training dataset:
1@misc{he2021debertav3,
2 title={DeBERTaV3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharing},
3 author={Pengcheng He and Jianfeng Gao and Weizhu Chen},
4 year={2021},
5 eprint={2111.09543},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}
1@misc{ai4privacy2023pii,
2 title = {PII Masking 300k},
3 author = {Ai4Privacy},
4 year = {2023},
5 publisher = {Hugging Face},
6 doi = {10.57967/hf/1995},
7 url = {https://huggingface.co/datasets/ai4privacy/pii-masking-300k}
8}