
CPU runtime on Databricks on AWS, 8 m5d.2xlarge workers, batch size 32. Source: Healthcare NLP de-identification benchmarks.
Clinical de-identification pipeline design is the choice of which PHI detectors a pipeline runs, rule-based annotators, clinical NER models, or zero-shot models, and on what hardware. This benchmark compares three designs across nine John Snow Labs Healthcare NLP de-identification pipelines: rule-augmented NER, hybrid NER plus zero-shot, and zero-shot first. On 478,527 clinical text rows on Databricks on AWS, the Optimized pipeline finished in 26 minutes on CPU, against 9.4 hours for the Large pipeline.
What are the three clinical de-identification pipeline architectures?
Every pipeline in this post combines up to three kinds of PHI detector: rule-based annotators (contextual parsers, regex matchers, and text matchers for dates, phone numbers, IDs, emails, and other structured identifiers), clinical NER models, and a zero-shot NER model or chunker. The mix sets the precision you get, the recall you get on PHI that rules can’t enumerate, and the hardware the pipeline needs to run at production speed.
Once PHI is found, Healthcare NLP either masks it, replacing the value with an entity tag or masking characters, or obfuscates it, replacing the value with a realistic fake one.

All patient data shown is synthetically generated for illustration.
Rule-augmented NER
Clinical NER models run alongside rule-based annotators for structured identifiers. Rules give deterministic, auditable matches on explicitly defined PHI types, with little variance from one dataset to the next. Each added rule and merge stage adds latency, and rules miss PHI that depends on context. The Optimized pipeline follows this design: 19 rule-based annotators and 4 NER models, with no zero-shot stage. It suits audit workflows where you need to explain why each span was removed.
Hybrid pipelines
Hybrid pipelines run fewer NER stages and add a zero-shot model for PHI patterns that are hard to enumerate or label exhaustively, such as long or ambiguous spans. Recall improves across institutions and note styles. A zero-shot stage needs more compute than an NER stage, and throughput becomes sensitive to batch size and hardware. Four pipelines here are hybrid: benchmark_medium and benchmark_large (19 rules, 3 NER models, 1 zero-shot model) and their v2 versions (21 rules, 2 NER models, a zero-shot chunker). The original Medium and Large pipelines use PretrainedZeroShotNER, which tags tokens and needs a NerConverter to turn the tags into chunks. The v2 and zero-shot pipelines use PretrainedZeroShotNERChunker, added in Healthcare NLP 6.2.2, which returns PHI spans directly from the document without token alignment.
Zero-shot first
A pretrained zero-shot model detects PHI spans without task-specific fine-tuning, optionally behind lightweight rule filters. You need less labeled clinical data, and the model finds PHI categories that no rule or NER label covers. Production throughput requires a GPU. The zeroshot_medium and zeroshot_large pipelines run PretrainedZeroShotNERChunker with 21 rule-based annotators, the same set as the v2 pipelines; the single-stage versions run the chunker alone, without a tokenizer or any NER model.

Components per pipeline, from each pipeline’s Models Hub page.
Choosing a design
Consider a hypothetical 900-bed academic medical center that de-identifies 50,000 discharge summaries a month for a multi-site research data warehouse. It needs a turnaround under 2 hours and audit-defensible precision on PHI such as medical record numbers and dates of service. A rule-augmented pipeline such as Optimized suits the deterministic, audit-driven part of that workflow. A hybrid pipeline suits the long-tail, context-dependent PHI that a fixed rule set won’t catch. The results below show how each design performs on CPU and GPU.
What datasets were used to benchmark these pipelines?
Datasets 1 and 2 measure accuracy, Dataset 3 measures runtime on long documents, and Dataset 4 measures runtime at cloud scale on Databricks.
Expert annotated notes
Dataset 1 is the ground truth from the peer-reviewed study Can Zero-Shot Commercial APIs Deliver Regulatory-Grade Clinical Text De-Identification? (Kocaman et al., Text2Story workshop at ECIR 2025): 48 clinical notes annotated by medical experts. In that study, John Snow Labs’ medical language models reached 96% F1 on PHI detection, against 91% for Azure, 83% for AWS, and 79% for GPT-4o.
The notes were pre-annotated by a deep learning model in John Snow Labs’ Generative AI Lab (then called Annotation Lab), then refined over several rounds of expert review against a written annotation guideline. Annotators labeled six PHI categories: NAME, DATE, LOCATION, AGE, CONTACT, and IDNUM. Names, contact details, and ID numbers are direct identifiers; dates, locations, and ages are quasi-identifiers that can re-identify a patient in combination. Both groups are PHI under HIPAA and personal data under GDPR (Regulation (EU) 2016/679). Six categories are the scope of this benchmark; PII coverage is not the same as HIPAA or GDPR coverage, and John Snow Labs’ production de-identification covers 23+ named PHI entity types, including all 18 HIPAA Safe Harbor categories. The ground truth file is public.
Surrogate clinical documents
Dataset 2 is 238 privately curated clinical documents built from synthetic and surrogate text, with no real patient records. The documents follow the structure of real clinical notes and contain more PHI per document, which makes them a stress test for error patterns and edge cases that a 48-note set can’t cover. Annotations use the categories NAME, DATE, LOCATION, AGE, CONTACT, and ID.
Long clinical documents
Dataset 3 is 1,000 clinical documents averaging 503 tokens each, close to the length of real clinical reports. It is used for end-to-end runtime only.
Aggregated Databricks corpus
Dataset 4 merges 1,100 clinical notes, more than 360,000 medical NER reports, and more than 110,000 clinical notes with masked PII into 478,527 rows. The rows average 152.71 characters and 24.46 tokens, for 11.7 million tokens in total. The mix of short rows and heterogeneous sources tests throughput across writing styles and document formats.
How were the nine pipelines tested?
All nine pipelines ran on identical inputs, with no preprocessing, normalization, caching, or reuse of intermediate results, so differences in runtime and accuracy come from pipeline architecture and execution.
Compute environments
The GPU environment was an NVIDIA A100 running Apache Spark with 48 partitions, a production-grade setup for clinical NLP inference at high throughput. The CPU environment was a Google Colab High-RAM CPU instance running Apache Spark with 32 partitions, which models offline batch processing on a limited budget.
Procedure and scoring
Each pipeline processed all 1,000 Dataset 3 documents once on each environment, with token counts and sentence boundaries preserved. Accuracy is token-level precision, recall, and F1 against the Dataset 1 expert annotations (the primary reference, “Paper” in the table below) and the Dataset 2 surrogate annotations (the secondary reference, “Surrogate”).
Pipelines tested
- clinical_deidentification_docwise_benchmark_optimized
- clinical_deidentification_docwise_benchmark_medium
- clinical_deidentification_docwise_benchmark_medium_v2
- clinical_deidentification_docwise_zeroshot_medium
- clinical_deidentification_docwise_SingleStage_zeroshot_medium
- clinical_deidentification_docwise_benchmark_large
- clinical_deidentification_docwise_benchmark_large_v2
- clinical_deidentification_docwise_zeroshot_large
- clinical_deidentification_docwise_SingleStage_zeroshot_large
How do the pipelines compare on accuracy and runtime?
Pipeline names drop the clinical_deidentification_docwise_ prefix. Wall times are for all 1,000 Dataset 3 documents.
| Pipeline | GPU wall time | CPU wall time | Paper precision | Paper recall | Paper F1 | Surrogate precision | Surrogate recall | Surrogate F1 | Components |
|---|---|---|---|---|---|---|---|---|---|
| benchmark_optimized | 5 min 15 sec | 8 min 55 sec | 0.93 | 0.93 | 0.93 | 0.92 | 0.96 | 0.94 | 19 rules, 4 NER |
| benchmark_medium | 4 min 38 sec | 32 min 57 sec | 0.90 | 0.97 | 0.93 | 0.87 | 0.96 | 0.91 | 19 rules, 3 NER, 1 zero-shot (medium) |
| benchmark_medium_v2 | 3 min 42 sec | 37 min 56 sec | 0.91 | 0.96 | 0.93 | 0.86 | 0.93 | 0.90 | 21 rules, 2 NER, zero-shot chunker |
| zeroshot_medium | 26.7 sec | 27 min | 0.92 | 0.94 | 0.93 | 0.86 | 0.90 | 0.88 | 21 rules, zero-shot chunker (medium) |
| SingleStage_zeroshot_medium | 33.1 sec | 26 min 41 sec | 0.92 | 0.91 | 0.92 | 0.87 | 0.88 | 0.88 | Zero-shot chunker (medium) |
| benchmark_large | 4 min 51 sec | 2 h 10 min | 0.90 | 0.97 | 0.94 | 0.88 | 0.96 | 0.92 | 19 rules, 3 NER, 1 zero-shot (large) |
| benchmark_large_v2 | 3 min 46 sec | 1 h 32 min | 0.92 | 0.98 | 0.95 | 0.87 | 0.94 | 0.91 | 21 rules, 2 NER, zero-shot chunker |
| zeroshot_large | 43.8 sec | 1 h 18 min | 0.93 | 0.97 | 0.95 | 0.87 | 0.93 | 0.90 | 21 rules, zero-shot chunker (large) |
| SingleStage_zeroshot_large | 41.1 sec | 1 h 15 min | 0.93 | 0.95 | 0.94 | 0.88 | 0.92 | 0.90 | Zero-shot chunker (large) |
Accuracy is close across all nine pipelines: paper F1 runs from 0.92 to 0.95 and surrogate F1 from 0.88 to 0.94. benchmark_large_v2 and zeroshot_large reach the highest paper F1 (0.95). The Optimized pipeline has the highest surrogate F1 (0.94) and the fastest CPU time (8 min 55 sec).
Runtime separates them. On the A100, the four zero-shot pipelines finish in 26.7 to 43.8 seconds, while the five pipelines with 2 to 4 NER models take 3 min 42 sec to 5 min 15 sec. On CPU the order reverses: zeroshot_medium takes 27 minutes against 8 min 55 sec for Optimized, and all four large pipelines take more than an hour.
Model scale moves recall and CPU time together. The large zero-shot pipelines score higher paper recall than their medium versions (0.97 against 0.94, and 0.95 against 0.91 for the single-stage pair) and take 2.8 to 2.9 times as long on CPU.
How much does GPU acceleration speed up de-identification at scale?
To test the designs at cloud scale, the Large, Medium, and Optimized pipelines processed all 478,527 rows of Dataset 4 on Databricks on AWS.
Cluster and versions
The CPU cluster had 8 m5d.2xlarge workers (8 cores and 32 GB each). The GPU cluster had 8 g4dn.2xlarge workers (1 NVIDIA T4 and 32 GB each). Software: Spark NLP 6.2.2, Healthcare NLP 6.2.1, and Databricks Runtime 16.4 LTS with Apache Spark 3.5.2.
The Large and Medium pipelines differ only in the size of their zero-shot model: both run 3 NER models plus a PretrainedZeroShotNER model, large or medium. The Optimized pipeline replaces the zero-shot model with a fourth NER model.
Runtime results
| Pipeline | Hardware | Batch size | Runtime |
|---|---|---|---|
| clinical_deidentification_docwise_benchmark_large | CPU | 32 | 9 h 23 min 54 sec |
| clinical_deidentification_docwise_benchmark_medium | CPU | 32 | 3 h 7 min 19 sec |
| clinical_deidentification_docwise_benchmark_optimized | CPU | 32 | 26 min 6 sec |
| clinical_deidentification_docwise_benchmark_medium | GPU | 8 | 1 h 2 min 35 sec |
Removing the zero-shot stage cut CPU runtime 21.6 times against Large and 7.2 times against Medium. The zero-shot model’s size alone accounts for the 3-times gap between Large and Medium. A T4 GPU cut the Medium pipeline from 3.1 hours to 1.0 hour, at a quarter of the CPU batch size, and the Optimized pipeline on CPU still ran 2.4 times faster than Medium on GPU.
Accuracy stays within 0.01 F1. In the 1,000-document test above, Optimized scored 0.93 paper F1 against 0.93 for Medium and 0.94 for Large, and 0.94 surrogate F1 against 0.91 and 0.92. If rules and NER models meet your recall target, this workload doesn’t need a GPU.
How do batch size and model size change zero-shot runtime?
Zero-shot NER uses a pretrained language model to find entity types it was not fine-tuned on, which extends PHI detection to new domains and languages. Two zero-shot NER models, zeroshot_ner_deid_subentity_merged_medium and zeroshot_ner_deid_subentity_merged_large, ran on the same Dataset 4 rows and Databricks clusters in a four-stage pipeline: DocumentAssembler, InternalDocumentSplitter, Tokenizer, and PretrainedZeroShotNER.

CPU: 8 m5d.2xlarge workers. GPU: 8 g4dn.2xlarge workers with one NVIDIA T4 each. The 26 times speedup compares CPU and GPU at the same batch size of 32.
| Model | Hardware | Batch size | Runtime |
|---|---|---|---|
| zeroshot_ner_deid_subentity_merged_medium | CPU | 32 | 2 h 47 min 24 sec |
| zeroshot_ner_deid_subentity_merged_medium | GPU | 32 | 6 min 26 sec |
| zeroshot_ner_deid_subentity_merged_medium | GPU | 8 | 12 min 3 sec |
| zeroshot_ner_deid_subentity_merged_large | GPU | 8 | 30 min 23 sec |
The Medium model is compute-bound on CPU. At the same batch size of 32, the GPU cluster cut its runtime from 2.8 hours to 6.4 minutes, 26 times faster. Raising the GPU batch size from 8 to 32 cut runtime from 12 minutes to 6.4, provided the batch fits in GPU memory. At batch size 8, the Large model took 30.4 minutes, 2.5 times the Medium model’s 12. Choose the model size from your accuracy target, then tune the batch size to the GPU.
What determines de-identification performance at production scale?
Clinical de-identification at scale is a systems engineering problem. Model accuracy is necessary, and the runtime you get depends on how the pipeline’s components, Spark execution settings, and hardware fit together. The benchmarks above support four conclusions:
- On CPU, the zero-shot stage dominates runtime. Removing it took the Databricks run from 9.4 hours to 26 minutes, with paper F1 within 0.01 of the Large pipeline.
- A GPU helps most where a zero-shot model runs: 26 times faster for the standalone Medium zero-shot model, 3 times for the Medium pipeline. Medium on GPU still finished after Optimized on CPU.
- Batch size and partition count need tuning per cluster. On GPU, moving from batch size 8 to 32 nearly halved runtime. In an earlier partition benchmark on 1,000 clinical texts with Healthcare NLP 5.2.0, one de-identification pipeline on an 8-worker Databricks cluster took 4 min 53 sec at 4 partitions, 1 min 26 sec at 32, and 1 min 55 sec at 1,024.
- Zero-shot pipelines reach 0.92 to 0.95 paper F1 and finish 1,000 documents in under 45 seconds on an A100, and they take 26 to 78 minutes on CPU. Plan GPU capacity before you choose them.
The same technology runs at production scale: at Providence, John Snow Labs’ de-identification pipeline de-identified 2 billion patient notes at over 99% PHI detection, validated by three months of external red-teaming and manual review of more than 35,000 notes.
All nine pipelines are on the John Snow Labs Models Hub, linked above, and load as pretrained pipelines in Healthcare NLP inside your own environment. To run them on your notes, see the de-identification page for licensing and deployment options.
Frequently asked questions
What is clinical de-identification pipeline design?
It is the choice of which PHI detectors a de-identification pipeline runs, and on what hardware. The detectors are rule-based annotators for structured identifiers such as dates, phone numbers, and IDs, clinical NER models, and zero-shot NER models or chunkers. In this benchmark, that choice moved CPU runtime on 478,527 rows from 9.4 hours to 26 minutes, with paper F1 within 0.01.
What’s the difference between rule-augmented, hybrid, and zero-shot de-identification pipelines?
Rule-augmented pipelines run clinical NER models with rule-based annotators; the Optimized pipeline uses 19 rules and 4 NER models and gives deterministic, auditable matches. Hybrid pipelines use 2 or 3 NER models plus a zero-shot model or chunker to catch PHI that rules can’t enumerate. Zero-shot pipelines rely on a zero-shot chunker, alone or with 21 rule-based annotators, and finish 1,000 documents in under 45 seconds on an A100 but take 26 to 78 minutes on CPU.
Which clinical de-identification pipeline is fastest on CPU?
clinical_deidentification_docwise_benchmark_optimized. It processed 1,000 clinical documents in 8 min 55 sec on a Google Colab High-RAM CPU and 478,527 rows in 26 min 6 sec on 8 Databricks m5d.2xlarge workers. It runs 19 rule-based annotators and 4 NER models, with no zero-shot stage.
Do I need a GPU for clinical de-identification?
Not for pipelines built from rules and NER models: the Optimized pipeline on CPU finished 478,527 rows 2.4 times faster than the Medium pipeline on a T4 GPU cluster. Zero-shot pipelines do need one: zeroshot_medium took 26.7 seconds for 1,000 documents on an A100 and 27 minutes on CPU.
How accurate are the Healthcare NLP de-identification pipelines?
Token-level F1 ranges from 0.92 to 0.95 on 48 expert annotated clinical notes and from 0.88 to 0.94 on 238 surrogate clinical documents. benchmark_large_v2 and zeroshot_large score the highest F1 on the expert annotated notes (0.95), and the Optimized pipeline scores the highest on the surrogate set (0.94).
How do batch size and model size change zero-shot NER runtime?
For zeroshot_ner_deid_subentity_merged_medium on 478,527 rows and 8 T4 GPU workers, raising the batch size from 8 to 32 cut runtime from 12 min 3 sec to 6 min 26 sec, as long as the batch fits in GPU memory. At batch size 8, the large model took 30 min 23 sec, 2.5 times the medium model. Inside the de-identification pipelines, the large zero-shot versions reach 0.95 to 0.97 paper recall against 0.91 to 0.94 for medium and take 2.8 to 2.9 times as long on CPU.
How does John Snow Labs de-identification compare with cloud APIs and GPT-4o?
On the same 48 expert annotated notes used in this post, the peer-reviewed study by Kocaman et al. (Text2Story workshop at ECIR 2025) measured 96% F1 for John Snow Labs’ medical language models, 91% for Azure, 83% for AWS, and 79% for GPT-4o. The paper and its ground truth file are public, so you can reproduce the comparison.
How many PHI categories does a HIPAA or GDPR compliant de-identification pipeline need to cover?
The 18 HIPAA Safe Harbor identifier categories are the floor for US data, and GDPR adds the Article 9 special categories. John Snow Labs’ de-identification covers 23+ named PHI entity types, including all 18 Safe Harbor categories, with separate labels for patients and doctors, medical record numbers, health plan numbers, and professions. This benchmark scores six of them: NAME, DATE, LOCATION, AGE, CONTACT, and IDNUM (ID on the surrogate set).
References and further reading
- Can Zero-Shot Commercial APIs Deliver Regulatory-Grade Clinical Text De-Identification? Kocaman, Santas, Gul, Butgul, and Talby, Text2Story workshop at ECIR 2025. The source of Dataset 1 and the cloud API comparison.
- Deidentification benchmarks, Healthcare NLP documentation. The full tables behind this post, including pipeline components and the partition benchmark.
- Simpler & More Accurate Deidentification in Spark NLP for Healthcare. De-identification models and pipeline components.
- Effortless PHI De-Identification: Running De-identification and Obfuscation in Healthcare NLP. De-identification annotators and masking and obfuscation modes.
- Pretrained Zero-Shot Models for Clinical Entity Recognition. Zero-shot NER for clinical text, annotation requirements, and inference.
- Advanced NLP Techniques: Identifying Named Entities in Medical Text with Zero-Shot Learning. Span-level entity detection with zero-shot learning.
- Spark NLP General Concepts. Spark NLP pipelines, annotators, and execution.
- PII coverage is not HIPAA or GDPR coverage: what clinical de-identification requires. PHI entity coverage and the Providence deployment.
- Webinar: State-of-the-art medical data de-identification and obfuscation.
- Webinar: Consistent linking, tokenization, and obfuscation for regulatory-grade de-identification of longitudinal medical data.
More from the John Snow Labs research team: peer-reviewed papers and the technical blog.




























