stanford deidentifier base

ProviderStanfordAIMI
Categorytoken-classification
Licensemit
Downloads2.2M
Stars0

Overview

The Stanford Deidentifier Base is a specialized token-classification model designed to automate the removal of Personally Identifiable Information (PII) from unstructured text. Unlike general-purpose LLMs, this model is architected for high-precision NER (Named Entity Recognition) specifically focused on privacy compliance. It is ideal for developers building healthcare applications or data pipelines where HIPAA or GDPR standards are required before moving data into analytics layers. Integration is straightforward for those using the Hugging Face ecosystem, offering a lightweight alternative to calling expensive proprietary APIs for simple redaction tasks. It provides a reliable baseline for scrubbing sensitive identifiers while maintaining the structural integrity of the source text.

Highlights

  • Specialized token-classification for high-precision PII redaction
  • Optimized for healthcare and privacy-compliant data pipelines
  • Lightweight MIT-licensed model for easy local deployment
  • Seamless integration with standard NLP transformer libraries

Usage

Install
# Install Hugging Face transformers
pip install transformers torch
SDK Usage
# Load model with transformers
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("StanfordAIMI/stanford-deidentifier-base")
tokenizer = AutoTokenizer.from_pretrained("StanfordAIMI/stanford-deidentifier-base")

Hugging Face Download

We recommend downloading the model via the Hugging Face CLI or Hub SDK.

Guidance:Before downloading, install huggingface_hub with:

Guidance
pip install -U huggingface_hub

CLI Download

Download the full repository

Download the full repository
huggingface-cli download StanfordAIMI/stanford-deidentifier-base

Download a single file to a local folder (e.g. config.json into ./dir)

Download a single file to a local folder (e.g. config.json into ./dir)
huggingface-cli download StanfordAIMI/stanford-deidentifier-base config.json --local-dir ./dir

See the official docs for more CLI options

SDK Download

SDK Download
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('StanfordAIMI/stanford-deidentifier-base')

Git Download

Make sure git-lfs is installed first

Git Download
git lfs install
git clone https://huggingface.co/StanfordAIMI/stanford-deidentifier-base

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/StanfordAIMI/stanford-deidentifier-base

Model files are hosted on the Hugging Face Hub — download directly via HF CLI / SDK / Git, not through this site.

PyTorch / Transformers Usage

Install Transformers

Install Transformers
pip install -U transformers torch

Load the model and run inference

Load the model and run inference
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('StanfordAIMI/stanford-deidentifier-base')
tokenizer = AutoTokenizer.from_pretrained('StanfordAIMI/stanford-deidentifier-base')

Full Documentation

来源: HuggingFace

---
widget:

  • text: "PROCEDURE: Chest xray. COMPARISON: last seen on 1/1/2020 and also record dated of March 1st, 2019. FINDINGS: patchy airspace opacities. IMPRESSION: The results of the chest xray of January 1 2020 are the most concerning ones. The patient was transmitted to another service of UH Medical Center under the responsability of Dr. Perez. We used the system MedClinical data transmitter and sent the data on 2/1/2020, under the ID 5874233. We received the confirmation of Dr Perez. He is reachable at 567-493-1234."

  • text: "Dr. Curt Langlotz chose to schedule a meeting on 06/23."

tags:
  • token-classification

  • sequence-tagger-model

  • pytorch

  • transformers

  • pubmedbert

  • uncased

  • radiology

  • biomedical

  • bdf-toolbox

datasets:
  • radreports

language:
- en
license: mit
---
Stanford de-identifier was trained on a variety of radiology and biomedical documents with the goal of automatising the de-identification process while reaching satisfactory accuracy for use in production. Manuscript in-proceedings.

These model weights are the recommended ones among all available deidentifier weights.

Associated github repo: https://github.com/MIDRC/Stanford_Penn_Deidentifier

Acknowledgement

This work was supported in part by the Medical Imaging and Data Resource Center (MIDRC), which is funded by the National Institute of Biomedical Imaging and Bioengineering (NIBIB) of the National Institutes of Health under contract 75N92020D00021 and through The Advanced Research Projects Agency for Health (ARPA-H)

Citation

bibtex
@article{10.1093/jamia/ocac219,
    author = {Chambon, Pierre J and Wu, Christopher and Steinkamp, Jackson M and Adleberg, Jason and Cook, Tessa S and Langlotz, Curtis P},
    title = "{Automated deidentification of radiology reports combining transformer and “hide in plain sight” rule-based methods}",
    journal = {Journal of the American Medical Informatics Association},
    year = {2022},
    month = {11},
    abstract = "{To develop an automated deidentification pipeline for radiology reports that detect protected health information (PHI) entities and replaces them with realistic surrogates “hiding in plain sight.”In this retrospective study, 999 chest X-ray and CT reports collected between November 2019 and November 2020 were annotated for PHI at the token level and combined with 3001 X-rays and 2193 medical notes previously labeled, forming a large multi-institutional and cross-domain dataset of 6193 documents. Two radiology test sets, from a known and a new institution, as well as i2b2 2006 and 2014 test sets, served as an evaluation set to estimate model performance and to compare it with previously released deidentification tools. Several PHI detection models were developed based on different training datasets, fine-tuning approaches and data augmentation techniques, and a synthetic PHI generation algorithm. These models were compared using metrics such as precision, recall and F1 score, as well as paired samples Wilcoxon tests.Our best PHI detection model achieves 97.9 F1 score on radiology reports from a known institution, 99.6 from a new institution, 99.5 on i2b2 2006, and 98.9 on i2b2 2014. On reports from a known institution, it achieves 99.1 recall of detecting the core of each PHI span.Our model outperforms all deidentifiers it was compared to on all test sets as well as human labelers on i2b2 2014 data. It enables accurate and automatic deidentification of radiology reports.A transformer-based deidentification pipeline can achieve state-of-the-art performance for deidentifying radiology reports and other medical documents.}",
    issn = {1527-974X},
    doi = {10.1093/jamia/ocac219},
    url = {https://doi.org/10.1093/jamia/ocac219},
    note = {ocac219},
    eprint = {https://academic.oup.com/jamia/advance-article-pdf/doi/10.1093/jamia/ocac219/47220191/ocac219.pdf},
}
Join our Telegram