Views
No views yet
BioBERT-v1.1 (based on BERT-large, pre-trained on biomedical corpora like PubMed abstracts and PMC full-text articles).BertForTokenClassification). A linear classification head is placed on top of the last hidden state of every input token.NAME (Patient/Doctor Names)AGE (Specific Age/Year)DATE (Admission, Discharge, Test Dates)ID (Medical Record Numbers, Social Security Numbers)1from transformers import AutoTokenizer, AutoModelForTokenClassification
2from transformers import pipeline
3
4# Load model and tokenizer
5model_name = "YourOrg/clinical-ner-deid-biobert-v2"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForTokenClassification.from_pretrained(model_name)
8
9# Create the NER pipeline
10ner_pipeline = pipeline(
11 "ner",
12 model=model,
13 tokenizer=tokenizer,
14 aggregation_strategy="simple"
15)
16
17clinical_note = "Patient Alex Johnson, aged 65, was admitted on 2024-11-15 with MRN 98765432."
18
19results = ner_pipeline(clinical_note)
20
21print("--- Detected PHI Entities ---")
22for result in results:
23 entity_type = result['entity_group']
24 word = result['word']
25 print(f"Type: {entity_type:<5} | Value: {word}")
26
27# Output structure allows for easy PHI redaction/replacement