Manuscript Offprint

arXiv:2611.12709

A local language model layered with rule-based and neural detectors for clinical text de-identification: an open-source toolkit and evaluation

Valentin Burkin

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Objectives: To measure whether a locally hosted large language model (LLM), stacked with deterministic and clinical named-entity recognition (NER) detectors, finds more protected health information (PHI) than open tools, and at what precision.

Materials and Methods: DeidSharp, an open-source .NET toolkit, combines the findings of pluggable detectors (patterns, a clinical NER model, a local 26B mixture-of-experts LLM) and fails closed on any detector error. Configurations fixed on tuning halves were compared, under a prespecified protocol, with deid, Philter, the Stanford/Penn de-identifier, OpenAI Privacy Filter and GLiNER on reporting halves of PhysioNet's nursing notes (889 spans) and semi-synthetic MIMIC-IV-Note discharge summaries (29,023 spans), and on synthetic ASQ-PHI queries, with paired patient-level bootstrap intervals.

Results: In the nursing notes, against Stanford/Penn, the recall-first stack found 98.9% of PHI (+2.8, 95% CI 1.4 to 4.4) at 9.3 points lower precision; the precision-first stack, without NER, found 96.5%, matching Stanford/Penn, at 19.6 points higher precision (83.2%). In the discharge summaries, both stacks led Stanford/Penn by more than 20 points (recall-first 95.3%, +21.5, 20.5 to 22.4), almost entirely on generated untyped names; on typed labels all three exceeded 99%. All four prespecified comparisons held. No configuration beat deid significantly on its home corpus; Philter found more discharge-summary spans than the recall-first stack at 23 points lower precision.

Discussion: The LLM was the main detector and NER added place names; asked to verify its own findings, the LLM discarded a quarter of true PHI.

Conclusion: A local LLM layered with deterministic detectors offers recall-first and precision-first operating points without sending text off-site.

Keywords: data anonymization; confidentiality; large language models; natural language processing; electronic health records

Lay summary

Doctors' and nurses' notes contain names, dates, places and numbers that identify patients. Before notes can be shared for research, those details must be removed, and doing it by hand does not scale. This work presents a free, open-source tool that combines several automatic methods: fixed rules for numbers and dates, a model trained on clinical notes, and a general-purpose language model that runs on one graphics card inside the hospital, so no text leaves the site. If any part of the tool fails, it returns nothing rather than a partly cleaned note. The test plan was fixed in advance, and the tool was tested on two collections of hospital notes whose identifiers had been replaced with realistic fakes, and on a public set of synthetic queries. With the language model, the tool found 94% to 99% of the identifying details: as many as or more than an openly available clinical model, and as many as an older rule-based tool on that tool's own notes. Finding more identifiers usually meant removing more ordinary text as well. All code and results are public, so others can repeat the measurements.

References (41)