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

A local language model stacked with rule and neural detectors finds more clinical PHI

Valentin Burkin · arXiv · 2026-11-9

- **Problem** Trained de-identifiers generalize unevenly across note collections, and the most capable LLMs are hosted services that data use agreements often bar from receiving clinical notes.
- **Method** DeidSharp runs a local 26B LLM in parallel with pattern and clinical NER detectors. It replaces the union of their spans, so recall comes first, and it stops the run if any detector fails.
- **Results** On nursing notes, the recall-first stack found 98.9% of PHI against 96.06% for Stanford/Penn, a gain of +2.8 points, at 9.3 points lower precision.

![Figure 2: Paired differences in span recall (left) and precision (right), in percentage points with paired 95% bootstrap intervals, between the two prespecifie…](https://refivu.com/papers/fdc65999-433c-47b0-9041-21262993a56a/figures/figure-9696f098eff1a58d92ae81d0ef356f39.png?thumb=512)

**Figure 2** :Paired differences in span recall (left) and precision (right), in percentage points with paired 95% bootstrap intervals, between the two prespecified stacks and the Stanford/Penn de-identifier or deid with its corpus-specific lists, on the reporting halves. The dashed line is the non-inferiority margin, which applies to the precision-first stack against Stanford/Penn. Scales differ between panels. Philter, which found more discharge-summary spans than both stacks (paired recall−4.1and−5.4points) at 23 to 27 points lower precision, is compared in the text. Supplementary Figure S1 shows every stack and tool on an absolute scale.

[Original paper](https://arxiv.org/abs/2611.12709v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Valentin Burkin · A local language model layered with rule-based and neural detectors for clinical text de-identification: an open-source toolkit and evaluation · Original paper figure · Extracted the figure area from page 9 of the original PDF.

## Why automated de-identification gets stuck

A note shared for research has to lose every identifier on the Safe Harbor list, or an equivalent standard. Hand removal is too slow for large collections, so automation has been studied for about two decades. Early tools were rule and dictionary systems such as deid and Philter, and later ones are neural models trained on annotated notes.

Their results shift with the corpus, and the way matches are counted changes the score too.

The weakness is generalization: a model trained on i2b2 recovered 39% of the names in the nursing notes. A dictionary tool found 97% on the same notes. The trained de-identifiers' own authors recommend checking them locally before anyone relies on them. Second, the most capable general models are hosted services. Data use agreements and institutional policy often bar sending notes to them.

LLMs have already been applied to de-identification through hosted APIs, local models and fine-tuned models. Zhou et al. combined RoBERTa with a local LLM that checks and widens its spans. Gold standards themselves miss PHI, so some studies evaluate without gold labels. Few studies compare rule tools, trained models and LLM layers on one scorer, with paired uncertainty.

It also asks what that costs in precision.

## How the detector union addresses the gap

DeidSharp runs its detectors in parallel and replaces the union of every span they report. A span that one detector misses can still be caught by another, so the union favors recall on purpose. The stack combines known identifiers, patterns, a clinical NER sidecar and a local LLM, with a gazetteer only when no LLM runs.

The clinical NER detector wraps a Presidio analyzer that runs the obi/deid\_roberta\_i2b2 RoBERTa model, trained on the i2b2 2014 corpus. The authors disabled Presidio's spaCy NER and its URL and US-license recognizers, because they produced most of the false positives. Each text the model lists is located in the note as whole words, and any text it invented or reworded is dropped.

In the ablation, the LLM alone found 95.6% of PHI at 87.6% precision. The clinical NER model alone found 87.0% at 58.3% precision. Their union reached 98.7%, and the NER model's contribution was mostly places, recovering 19 of the 23 the LLM missed. Pattern detectors added no measurable recall next to the LLM.

Detectors return spans and categories only, so logs and errors never quote PHI. If any detector fails, the run stops instead of reading the failure as nothing found. A deterministic leak guard would refuse output that still holds a known identifier, but this study didn't exercise it. The optional second opinion may drop only clinical NER spans that are not locations or organizations.

## How one note moves through the pipeline

A note enters the stack, and several detector families run on it in parallel, with the record's known identifiers joining when a record exists. Detectors hand back only spans and categories, so the covered text never appears in logs or errors. The clinical NER detector runs a Presidio analyzer with the obi/deid\_roberta\_i2b2 RoBERTa model, which was trained on the i2b2 2014 corpus.

The authors switched off Presidio's spaCy NER and its URL and US-license recognizers, because they produced most of the false positives on the tuning half.

The LLM detector cuts the note into chunks of 2,000 characters that overlap by 200, and it sends each chunk to a local model through Ollama. Each returned text is located in the note as whole words, so text the model invented or reworded gets dropped.

Rule filters then keep what Safe Harbor permits keeping, dropping ages under 90, a bare year, time or weekday, and identifiers of three digits or fewer. The same age rule wraps every stack, because NER models also tag every age. The optional second opinion gets a 16,384-token context window, so it can read long notes, and it keeps a span whenever it is unsure.

It can veto only spans that no known-identifier, pattern or LLM detector reported, and it never touches a location or organization.

The union of all spans is replaced, so recall comes first, and a failed detector stops the run instead of counting as nothing found. Spans are merged and replaced with tags or surrogates, and then a deterministic leak guard checks for surviving identifiers. The authors fixed five stacks on the nursing notes' tuning half, and the stacks with the LLM omit the gazetteer.

The leak guard wasn't exercised in this evaluation, because the corpora supply no structured record.

## Corpora, scoring and the prespecified protocol

The nursing notes give the authors 2,434 ICU notes from 163 patients, with the gold standard shipped alongside the deid software. Their reporting half holds 889 gold spans, and deid's default lists were built from these same notes. Discharge-summary placeholders that matched no rule, 41% on the tuning half, got a first name or surname.

The discharge summaries come from 1,000 patients, with one summary each. Their reporting half holds 29,023 gold spans. A fixed hash draws the corpus, so any credentialed user can rebuild it exactly. ASQ-PHI adds 1,051 synthetic search queries, 219 of them hard negatives without PHI, and its reporting counts 2,976 gold spans. Each credentialed corpus was split by patient, so one half guided development and the other gave the published numbers.

Span recall counts a gold span as found when any prediction overlaps it, regardless of the label that prediction carries. Intervals come from 1,000 percentile bootstraps over patients with a fixed seed, and a patient's notes are resampled together.

The authors committed the final run's data, stacks, baselines, measures and four statements before running any reporting half. They picked Stanford/Penn as the model baseline because it had the highest span recall on both tuning halves and on ASQ-PHI. Statement B lets the precision-first stack lose at most 2 points of recall, a margin the authors chose without formal derivation.

Each of the four statements is read from its own 95% interval, with no adjustment for multiplicity.

## Final-run results on the reporting halves

The precision-first stack had no NER sidecar, and its recall difference from Stanford/Penn was +0.45, with an interval from −1.45 to 2.54. That same stack had 19.62 points more precision, so it kept recall level while gaining precision.

That margin came from untyped names, 12,632 spans or 44% of gold, where Stanford/Penn found 40.7%. The recall-first stack found 89.2% of those names and the precision-first stack found 86.6%. On the typed labels, they found 99.3%, 99.96% and 99.7%, so the lead traces to the generated names.

The four prespecified statements compared each stack with the Stanford/Penn de-identifier on the same reporting halves. The recall-first stack's nursing lead was +2.81 points, with an interval from 1.38 to 4.37. On the discharge summaries, the precision-first stack's precision was +0.96 points above Stanford/Penn, with an interval from 0.73 to 1.19.

On one 16 GB GPU, the precision-first stack found 96.5% of PHI and removed 0.15% of the other text. Without an LLM, the stack found 88% of the nursing notes' PHI at 43% precision.

## Which detector carries recall in the development ablations

On the nursing notes' tuning half, the LLM alone caught 95.6% of PHI, with 87.6% precision. The clinical NER model alone reached 87.0% recall, but its precision fell to 58.3%. Their union reached 98.7%, and the authors say the two models fail differently. Most of the NER model's contribution was places, recovering 19 of the 23 places the LLM missed.

The second opinion raised precision by 18.7 points when it judged every span from the clinical model. It rejected real hospital and unit names, so the authors barred it from locations and organizations. Barred from places, it cost 2 spans (-0.24, -0.57 to 0.00) and added 11.9 points of precision. When it judged the LLM's own findings, it discarded 24.6 points of recall for only 3.3 points more precision, so the authors call a model a poor judge of its own findings.

All forty fictional examples gave 10 points more precision than four examples, at the same speed. A zero-shot prompt found as much PHI, with 35 spans missed in the nursing notes, so the examples bought precision rather than recall. A third family, Ministral 3 14B, gained +70.9 points of recall zero-shot against Gemma's +70.1, at far lower precision.

A Census gazetteer added about 3 points of recall without an LLM, but it added only 2 or 3 spans next to one.

The authors didn't test deid's hospital list next to an LLM, although that list added 11 points on deid's home corpus. The ablations show that the LLM carries most of the recall, and the prompt and model family mainly set precision.

## Comparisons outside the prespecified statements

The recall-first stack gained +0.07 points over Stanford/Penn, with an interval from 0.00 to 0.17. The precision-first stack kept 1.86 more points of precision, with an interval from 1.39 to 2.39.

On the nursing notes, deid with its corpus-specific lists served as the home-corpus baseline. No configuration found significantly more PHI than deid with those lists. The recall-first stack's lead of 1.57 points had an interval starting at zero, from 0.00 to 3.27. The precision-first stack's recall differed from deid's by −0.79 points, with an interval from −2.80 to 1.27.

That same stack had 10.6 points more precision than deid, with an interval from 6.8 to 14.9. Without deid's lists, the recall-first and balanced stacks found more PHI, by 2.81 and 2.14 points.

On discharge summaries, every stack with the LLM found more spans than deid in any configuration. The recall-first stack led deid by 3.20 points, with an interval from 2.74 to 3.68, at equal precision. Much of that lead comes from the generator's fictional hospitals and cities, which deid's lists rarely match. Without those names, the leads shrink to about 1.5 and 0.2 points.

Philter touched 99.4% of the discharge gold spans, more than the stacks did. It covered 83.3% of PHI characters, against 96.0 to 97.1% for the stacks.

## What limits how far these results travel

The corpora limit how far these numbers travel, since both credentialed ones come from a single hospital via MIMIC. Both corpora hold surrogates instead of original PHI, so real notes could behave differently. The discharge summaries are semi-synthetic, so MIMIC's own de-identification defines their gold standard. Untyped names make up 44% of the reporting half's gold spans, and the label rests on a sample of 100.

By the rule of three, up to 3% of those untyped names may stand for something else.

The reporting halves were measured during development, so they don't serve as a clean held-out test. The final run's protocol is self-attested, and the authors wrote it knowing earlier results. A known gazetteer fault affects only the stack without an LLM, and the authors left it unfixed. The known-identifier detector and the leak guard weren't evaluated, because the corpora supply no structured record.

Only two other model families were tried, and only on tuning halves. The authors didn't evaluate a Stanford/Penn successor that adds ages. Baseline spans were scored unmerged, unlike the merged spans of DeidSharp's stacks, which slightly affects GLiNER's precision. No stack replaces local validation and governance.

## Paper info

- **Authors**: Valentin Burkin
- **Venue**: arXiv · Preprint
- **First published**: 2026-11-9
- **Added**: 2026-11-11
- **Updated**: 2026-11-9
- **Version**: v1
- **arXiv**: 2611.12709
- **Category**: cs.CL · cs.CY · cs.SE
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2611.12709v1) · [PDF ↗](https://arxiv.org/pdf/2611.12709v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## 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.

## Quote from the paper

Valentin Burkin (2026). A local language model layered with rule-based and neural detectors for clinical text de-identification: an open-source toolkit and evaluation. arXiv:2611.12709v1. https://arxiv.org/abs/2611.12709v1

**BibTeX**

```
@misc{burkin2026local,
  title = {{A local language model layered with rule-based and neural detectors for clinical text de-identification: an open-source toolkit and evaluation}},
  author = {Valentin Burkin},
  year = {2026},
  eprint = {2611.12709},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.12709v1}
}
```

## Other paper commentary

- [Language Defaults Before Content: A Causal Layer Map of Multilingual Generation](https://refivu.com/en/papers/de0d97bc-3b9a-4e13-a9a8-8a9207115066-language-defaults-before-content-a-causal-layer-map.md)
- [Translating KV Caches Between Hybrid-Attention Language Models: MLA Latents, Linear-Attention States and Sparse-Attention Indexers](https://refivu.com/en/papers/5eb33cd3-9543-41d1-88c1-8ec06cec0762-translating-kv-caches-between-hybrid-attention-language.md)
- [BridgeKV: Large-Model Prefill and Small-Model Decoding for LLM Inference via KV Cache Translation](https://refivu.com/en/papers/4b4f7e07-6cb4-4329-8ba4-eb2bfc4e07de-bridgekv-large-model-prefill-and-small-model-decoding.md)
- [Competing Influence in LLM Populations: Budget Timing and Baseline Drift](https://refivu.com/en/papers/0c46aeac-7fe7-4f4c-9eb7-13d04ed0b581-competing-influence-in-llm-populations-budget-timing-and.md)
- [VeilTune: Secure Fine-Tuning of Private LoRA Adapters on Public Pretrained Language Models](https://refivu.com/en/papers/1ac3c6eb-7952-4bcf-b058-eb348429161e-veiltune-secure-fine-tuning-of-private-lora-adapters.md)
- [Weight-Space Programming of Policies and Their Verification via Model Checking](https://refivu.com/en/papers/812e0c2d-92df-41d6-8419-2738a51f42de-weight-space-programming-of-policies-and-their-verification.md)
- [Hidden Tails: Certifying Tail-Risk Claims under Selective Labels](https://refivu.com/en/papers/75cb6ab3-f9c1-4466-b415-44269638d62a-hidden-tails-certifying-tail-risk-claims-under-selective.md)
- [Agnostic Marginal-Nonuniform Learning](https://refivu.com/en/papers/016f1038-e984-4177-99de-fa3e2feb1567-agnostic-marginal-nonuniform-learning.md)
- [A Lattice-Based HMM Approach to Aruz Scansion of Ottoman Poetry](https://refivu.com/en/papers/81004ad8-5641-430f-b487-3d295b983eee-a-lattice-based-hmm-approach-to-aruz-scansion.md)
- [Graph-Guided Bayesian Factor Analysis: A Fast Integrated EFA-CFA Approach for High-Dimensional Data](https://refivu.com/en/papers/5d2d391c-7613-40f5-b05b-d69ca40d0041-graph-guided-bayesian-factor-analysis-a-fast-integrated.md)
- [WanderBench: Can World Models Explore Dynamic Worlds from Video?](https://refivu.com/en/papers/7abb23d2-6e66-4d6d-975e-edf2604d3c4d-wanderbench-can-world-models-explore-dynamic-worlds-from.md)
- [Adaptive Quantization Preserves Fast Rates for TD Learning over Rate-Limited Channels](https://refivu.com/en/papers/d58bc294-7861-4c11-8973-582df8ea5981-adaptive-quantization-preserves-fast-rates-for-td-learning.md)

## Terms in this paper

- [percentile bootstrap](https://refivu.com/en/terms/e1689106c4f6-percentile-bootstrap)
- [QWEN](https://refivu.com/en/terms/101872bfebe4-qwen)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/fdc65999-433c-47b0-9041-21262993a56a-a-local-language-model-layered-with-rule-based)
