Downloads · 30 days
20
1% of all-time downloads
bharathjanumpally/phi-span-detector-deberta-v3
phi-span-detector-deberta-v3 is a token classification model from bharathjanumpally. Use it when you need labels on individual words, such as names. It is set up for transformers. The card lists the license as apache-2.0.
phi-span-detector-deberta-v3 is a DeBERTa v3 token-classification model for detecting Protected Health Information (PHI) spans in clinical-note-like text and log-like text using BIO tagging.
Downloads · 30 days
20
1% of all-time downloads
All-time downloads
1.8K
Public
Parameters
184M
2.2 GB on disk
Likes
1
Public
Click a slice to open those files.
.pt1.5 GB · 50%
From the Hugging Face model README
phi-span-detector-deberta-v3 is a DeBERTa v3 token-classification model for detecting Protected Health Information (PHI) spans in clinical-note-like text and log-like text using BIO tagging.
It is designed for privacy tooling workflows such as:
Recommended pipeline:
Companion model:
bharathjanumpally/phi-leak-checker-deberta-v3
DebertaV2ForTokenClassificationmicrosoft/deberta-v3-baseThe model predicts the following entity families:
| Label | Meaning |
|---|---|
NAME | patient or person names |
DATE | visit dates, birth dates, service dates |
AGE | age mentions that may be identifying in context |
PHONE | phone and callback numbers |
EMAIL | email addresses |
ADDRESS | street or mailing addresses |
ID | MRN, account, encounter, record, or similar identifiers |
PROVIDER | clinician or provider names |
FACILITY | hospitals, clinics, centers, departments |
LOCATION | city, state, and other place references |
Token-level outputs use BIO labels from the model config:
O, B-*, and I-* across the ten PHI families above.
This model was trained on synthetic examples to keep the project openly shareable.
High-level training recipe:
This provides clean supervision without exposing real patient data, but it also means real-world formatting and writing styles may differ from training-time distributions.
The repository includes a full seqeval_report.txt. Key held-out results from that report are summarized below.
| Metric | Value |
|---|---|
| Micro precision | 0.6657 |
| Micro recall | 0.6394 |
| Micro F1 | 0.6523 |
| Macro precision | 0.6583 |
| Macro recall | 0.6224 |
| Macro F1 | 0.6362 |
| Weighted F1 | 0.6495 |
| Label | Precision | Recall | F1 | Support |
|---|---|---|---|---|
| ADDRESS | 0.6652 | 0.6481 | 0.6565 | 233 |
| AGE | 0.6758 | 0.3834 | 0.4893 | 386 |
| DATE | 0.6553 | 0.6492 | 0.6522 | 1297 |
| 0.6474 | 0.6455 | 0.6465 | 347 | |
| FACILITY | 0.6320 | 0.6494 | 0.6406 | 656 |
| ID | 0.6652 | 0.6519 | 0.6585 | 451 |
| LOCATION | 0.6600 | 0.6600 | 0.6600 | 350 |
| NAME | 0.7810 | 0.7802 | 0.7806 | 1001 |
| PHONE | 0.5358 | 0.5025 | 0.5186 | 595 |
| PROVIDER | 0.6652 | 0.6537 | 0.6594 | 231 |
NAMEPHONE and AGEAppropriate uses:
Not intended for:
PHONE and AGE.Recommended mitigations:
from transformers import pipeline
ner = pipeline(
"token-classification",
model="bharathjanumpally/phi-span-detector-deberta-v3",
aggregation_strategy="simple",
)
text = (
"Patient John Smith (MRN: 001-23-4567) visited "
"Boston Medical Center on 12/19/2025."
)
print(ner(text))
from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
model_id = "bharathjanumpally/phi-span-detector-deberta-v3"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForTokenClassification.from_pretrained(model_id)
ner = pipeline(
"token-classification",
model=model,
tokenizer=tokenizer,
aggregation_strategy="simple",
)
print(ner("Call Jane Doe at 617-555-0182 before 04/14/2025."))
from transformers import pipeline
ner = pipeline(
"token-classification",
model="bharathjanumpally/phi-span-detector-deberta-v3",
aggregation_strategy="simple",
)
text = (
"Patient John Smith (MRN: 001-23-4567) visited "
"Boston Medical Center on 12/19/2025."
)
spans = ner(text)
redacted = text
for item in sorted(spans, key=lambda x: x["start"], reverse=True):
label = item["entity_group"]
redacted = redacted[: item["start"]] + f"[{label}]" + redacted[item["end"] :]
print(spans)
print(redacted)
For downstream systems, a practical span schema is:
[
{"start": 8, "end": 18, "label": "NAME", "score": 0.97},
{"start": 25, "end": 36, "label": "ID", "score": 0.94},
{"start": 45, "end": 66, "label": "FACILITY", "score": 0.91},
{"start": 70, "end": 80, "label": "DATE", "score": 0.89}
]
This model was trained on synthetic data and is published for research and tooling purposes. Do not send real PHI to public demos or public inference endpoints. Use private infrastructure, access controls, and organization-approved evaluation workflows for real deployments.
@misc{janumpally_phi_span_detector_2025,
title = {PHI Span Detector (Synthetic)},
author = {Bharath Kumar Reddy Janumpally},
year = {2025},
publisher = {Hugging Face},
howpublished = {Model on Hugging Face}
}
If you use this model in a serious workflow, validate it against your own internal test cases and document the operating policy around false positives, false negatives, and escalation paths.