Instructions to use lethalantidote/phi-detector-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lethalantidote/phi-detector-model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="lethalantidote/phi-detector-model")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("lethalantidote/phi-detector-model") model = AutoModelForTokenClassification.from_pretrained("lethalantidote/phi-detector-model", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Publish quality-gated PHI token classifier
Browse files- README.md +33 -0
- config.json +46 -0
- model.safetensors +3 -0
- run_manifest.json +51 -0
- tokenizer.json +0 -0
- tokenizer_config.json +15 -0
README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: token-classification
|
| 5 |
+
base_model: emilyalsentzer/Bio_ClinicalBERT
|
| 6 |
+
tags:
|
| 7 |
+
- clinical
|
| 8 |
+
- phi
|
| 9 |
+
- ner
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Synthetic PHI Detector
|
| 13 |
+
|
| 14 |
+
This token-classification model was fine-tuned from `emilyalsentzer/Bio_ClinicalBERT` using
|
| 15 |
+
Synthetic Synthea-derived clinical templates. It recognizes three entity types
|
| 16 |
+
with the BIO labels stored in `config.json`.
|
| 17 |
+
|
| 18 |
+
Training examples: 5997
|
| 19 |
+
|
| 20 |
+
| Entity | Strict seqeval F1 |
|
| 21 |
+
|---|---:|
|
| 22 |
+
| MEDICAL_RECORD | 1.0000 |
|
| 23 |
+
| DIAGNOSIS | 1.0000 |
|
| 24 |
+
| MEDICATION | 1.0000 |
|
| 25 |
+
|
| 26 |
+
Overall strict seqeval F1: 1.0000
|
| 27 |
+
|
| 28 |
+
## Limitations
|
| 29 |
+
|
| 30 |
+
Synthetic templates do not represent every institution, document style, or
|
| 31 |
+
identifier format. False negatives and false positives are expected. This
|
| 32 |
+
model assists PHI detection and is not a compliance guarantee or substitute
|
| 33 |
+
for human review and layered detection controls.
|
config.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForTokenClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"eos_token_id": null,
|
| 11 |
+
"hidden_act": "gelu",
|
| 12 |
+
"hidden_dropout_prob": 0.1,
|
| 13 |
+
"hidden_size": 768,
|
| 14 |
+
"id2label": {
|
| 15 |
+
"0": "O",
|
| 16 |
+
"1": "B-MEDICAL_RECORD",
|
| 17 |
+
"2": "I-MEDICAL_RECORD",
|
| 18 |
+
"3": "B-DIAGNOSIS",
|
| 19 |
+
"4": "I-DIAGNOSIS",
|
| 20 |
+
"5": "B-MEDICATION",
|
| 21 |
+
"6": "I-MEDICATION"
|
| 22 |
+
},
|
| 23 |
+
"initializer_range": 0.02,
|
| 24 |
+
"intermediate_size": 3072,
|
| 25 |
+
"is_decoder": false,
|
| 26 |
+
"label2id": {
|
| 27 |
+
"B-DIAGNOSIS": 3,
|
| 28 |
+
"B-MEDICAL_RECORD": 1,
|
| 29 |
+
"B-MEDICATION": 5,
|
| 30 |
+
"I-DIAGNOSIS": 4,
|
| 31 |
+
"I-MEDICAL_RECORD": 2,
|
| 32 |
+
"I-MEDICATION": 6,
|
| 33 |
+
"O": 0
|
| 34 |
+
},
|
| 35 |
+
"layer_norm_eps": 1e-12,
|
| 36 |
+
"max_position_embeddings": 512,
|
| 37 |
+
"model_type": "bert",
|
| 38 |
+
"num_attention_heads": 12,
|
| 39 |
+
"num_hidden_layers": 12,
|
| 40 |
+
"pad_token_id": 0,
|
| 41 |
+
"tie_word_embeddings": true,
|
| 42 |
+
"transformers_version": "5.14.1",
|
| 43 |
+
"type_vocab_size": 2,
|
| 44 |
+
"use_cache": true,
|
| 45 |
+
"vocab_size": 28996
|
| 46 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7fc3730f96aca8d89a8483487be43546bad6b5f9f51364186d8de85c32fd4b74
|
| 3 |
+
size 430923588
|
run_manifest.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"base_model": "emilyalsentzer/Bio_ClinicalBERT",
|
| 3 |
+
"base_model_revision": "d5892b39a4adaed74b92212a44081509db72f87b",
|
| 4 |
+
"bio_labels": [
|
| 5 |
+
"O",
|
| 6 |
+
"B-MEDICAL_RECORD",
|
| 7 |
+
"I-MEDICAL_RECORD",
|
| 8 |
+
"B-DIAGNOSIS",
|
| 9 |
+
"I-DIAGNOSIS",
|
| 10 |
+
"B-MEDICATION",
|
| 11 |
+
"I-MEDICATION"
|
| 12 |
+
],
|
| 13 |
+
"code_fingerprint": "6ca8a25e9d2aa93d901e2f15d984e1d8b497b390b48195775a5f6d85fcc3e54c",
|
| 14 |
+
"dataset_manifest_sha256": "77443e9234a02f1b3b9eff317662f3a93c96bdff306e86eb1d5ecbdd508bd57d",
|
| 15 |
+
"dependency_versions": {
|
| 16 |
+
"python": "3.12.13",
|
| 17 |
+
"torch": "2.11.0+cu128",
|
| 18 |
+
"transformers": "5.14.1"
|
| 19 |
+
},
|
| 20 |
+
"metrics": {
|
| 21 |
+
"DIAGNOSIS_f1": 1.0,
|
| 22 |
+
"DIAGNOSIS_precision": 1.0,
|
| 23 |
+
"DIAGNOSIS_recall": 1.0,
|
| 24 |
+
"DIAGNOSIS_support": 940.0,
|
| 25 |
+
"MEDICAL_RECORD_f1": 1.0,
|
| 26 |
+
"MEDICAL_RECORD_precision": 1.0,
|
| 27 |
+
"MEDICAL_RECORD_recall": 1.0,
|
| 28 |
+
"MEDICAL_RECORD_support": 300.0,
|
| 29 |
+
"MEDICATION_f1": 1.0,
|
| 30 |
+
"MEDICATION_precision": 1.0,
|
| 31 |
+
"MEDICATION_recall": 1.0,
|
| 32 |
+
"MEDICATION_support": 702.0,
|
| 33 |
+
"loss": 0.00027296075131744146,
|
| 34 |
+
"overall_f1": 1.0,
|
| 35 |
+
"overall_precision": 1.0,
|
| 36 |
+
"overall_recall": 1.0,
|
| 37 |
+
"overall_support": 1942.0,
|
| 38 |
+
"runtime": 1.704,
|
| 39 |
+
"samples_per_second": 1139.665,
|
| 40 |
+
"steps_per_second": 35.798
|
| 41 |
+
},
|
| 42 |
+
"seed": 42,
|
| 43 |
+
"training_parameters": {
|
| 44 |
+
"epochs": 4.0,
|
| 45 |
+
"eval_batch_size": 32,
|
| 46 |
+
"learning_rate": 2e-05,
|
| 47 |
+
"max_length": 256,
|
| 48 |
+
"train_batch_size": 16,
|
| 49 |
+
"weight_decay": 0.01
|
| 50 |
+
}
|
| 51 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 9 |
+
"pad_token": "[PAD]",
|
| 10 |
+
"sep_token": "[SEP]",
|
| 11 |
+
"strip_accents": null,
|
| 12 |
+
"tokenize_chinese_chars": true,
|
| 13 |
+
"tokenizer_class": "BertTokenizer",
|
| 14 |
+
"unk_token": "[UNK]"
|
| 15 |
+
}
|