NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Deidentifying Medical Documents with Local, Privacy-Preserving Large Language Models: The LLM-Anonymizer

Isabella C. Wiest, Marie-Elisabeth Leßmann, F M Wolf, Dyke Ferber, Marko van Treeck, Jiefu Zhu, Matthias P. Ebert, C. Benedikt Westphalen, Martin Wermke, Jakob Nikolas KatherNEJM 2025

Abstract

Medical research utilizing real-world clinical data is often hindered by stringent privacy requirements. While de-identifying medical free text is notoriously difficult due to unstructured formats and diverse documentation styles, Large Language Models (LLMs) offer a promising solution. This study introduces the LLM-Anonymizer, an open-source pipeline designed to extract and redact patient-related information using locally deployable LLMs. Benchmarking eight models on a dataset of 100 real-world clinical letters, we found that Llama-3 70B achieved a 98.05% success rate in removing personal identifying information (PII). Our results demonstrate that local LLMs can effectively secure clinical data on-premise, facilitating safer data sharing for medical research.

Introduction

The "privacy paradox" in healthcare refers to the tension between the need for large-scale clinical data to drive medical innovation and the legal and ethical necessity of protecting patient confidentiality. Clinical notes—unstructured "free text" written by practitioners—contain a wealth of information but are often saturated with personally identifiable information (PII).

To comply with regulations like GDPR or HIPAA, this data must be de-identified before it can be shared or analyzed. Historically, institutions faced a choice between manual redaction, which is slow and error-prone, or rule-based systems that struggle with the nuances of medical language. While cloud-based LLMs like GPT-4 show high proficiency in these tasks, the risk of sending sensitive patient data to external servers is a non-starter for most healthcare institutions. The LLM-Anonymizer addresses this by bringing state-of-the-art performance to local, hospital-owned hardware.

The LLM-Anonymizer Pipeline

The researchers developed a four-stage automated pipeline to handle the end-to-end de-identification process:

  1. Preprocessing: The system ingests various file formats (PDF, DOCX, TXT), converting them into raw text. To accommodate model context limits, the text is partitioned into 4,000-character segments.
  2. Information Extraction: Utilizing the llama.cpp framework, the pipeline runs quantized versions of LLMs. A key technical innovation is the use of grammar-based sampling, which constrains the LLM to output data in a strictly defined JSON format, ensuring the extracted PII can be processed programmatically.
  3. Data Anonymization: The system performs exact string matching between the extracted PII and the original text to redact sensitive information.
  4. Evaluation: A built-in module compares the redacted output against a human-annotated "ground truth" to calculate precision, recall, and false negative rates.

Methodology

The study benchmarked eight locally deployable models: Llama-3 (8B and 70B), Llama-2 (7B and 70B), Mistral 7B, Phi-3-mini, and German-specific "Sauerkraut" variants of Llama-2.

The evaluation dataset consisted of 100 real-world clinical letters from the University Hospital Dresden, spanning two decades (2004–2023). These documents included complex structures such as laboratory tables, radiology findings, and endoscopic reports. A medical professional manually annotated these letters to establish a gold standard for PII identification.

Results and Key Insights

The benchmark results highlight a significant performance gap between model generations and sizes. Llama-3 70B emerged as the superior model, achieving a 98.05% success rate in PII character removal.

Performance Metrics

  • Accuracy: Llama-3 70B missed only 1.95% of PII (False Negative Rate) and had a minimal over-redaction rate of 0.85%.
  • Perfect Redaction: The model managed to completely de-identify 81 out of 100 letters with zero missed PII.
  • Consistency: The model demonstrated high reliability across multiple runs (p=0.7039), suggesting that low temperature settings and structured output effectively mitigate the "hallucination" risks typically associated with LLMs.
  • Scaling: There was a marked improvement in performance when moving from 7B/8B models to 70B models. However, Llama-3 8B showed impressive capabilities, punching significantly above its weight class compared to older architectures.

The "House Number" Challenge

An interesting qualitative finding was the difficulty models faced with house numbers. Unlike names or dates, house numbers are often isolated digits. The models occasionally confused these with clinical lab values (e.g., potassium levels). This highlights a critical trade-off: aggressive redaction ensures privacy but may inadvertently strip away vital clinical data, while conservative redaction risks leaving PII exposed.

Discussion and Limitations

The study confirms that local, zero-shot LLMs can perform on par with proprietary cloud models for medical de-identification. This is a significant milestone for hospitals that lack the resources for manual redaction but are bound by strict data residency requirements.

However, several limitations remain. The current pipeline focuses on a subset of PII (names, DOB, address, ID); to achieve full HIPAA compliance, the system must be expanded to include all 18 protected health identifiers. Additionally, while the 100-letter dataset is high-quality, larger multi-center studies are required to validate the model's generalizability across different medical specialties.

Conclusion

The LLM-Anonymizer represents a significant step forward in making clinical data accessible for research without compromising patient privacy. By providing an open-source, user-friendly interface that runs on local hardware, the researchers have lowered the barrier to entry for secure data processing in healthcare. The full pipeline and code are available on GitHub for the research community to adapt and extend.

Summary updated

BibTeX
@inproceedings{wiest2025deidentifying,
  author = {Isabella C. Wiest and Marie-Elisabeth Leßmann and F M Wolf and Dyke Ferber and Marko van Treeck and Jiefu Zhu and Matthias P. Ebert and C. Benedikt Westphalen and Martin Wermke and Jakob Nikolas Kather},
  title = {{Deidentifying Medical Documents with Local, Privacy-Preserving Large Language Models: The LLM-Anonymizer}},
  booktitle = {NEJM},
  year = {2025},
  doi = {10.1056/aidbp2400537},
}

Loading related content...

Figure