
Clinical NLP Training Data: How to Prepare Medical Records Without Violating HIPAA
Building clinical NLP models requires high-quality annotated medical data — and HIPAA compliance at every step. This guide covers the complete data preparation pipeline for healthcare AI teams.
Clinical natural language processing is one of the highest-value applications of AI in healthcare. Models that can read clinical notes and extract structured information — diagnoses, medications, procedures, findings — can automate ICD coding, surface drug interactions, flag deterioration patterns, and accelerate clinical research. The technology exists. The bottleneck is almost always the training data.
Preparing clinical NLP training data is a compliance problem before it is a technical one. Medical records contain protected health information (PHI). Any data preparation workflow that involves cloud services, external tools, or third-party contractors must be built around HIPAA's requirements. Most existing tools were not designed with this constraint in mind.
This guide covers what clinical NLP models actually need, who should do the annotation, what the HIPAA-compliant pipeline looks like, and where existing tools fall short.
What Clinical NLP Models Do
Clinical NLP models are specialized models trained to perform specific language understanding tasks on clinical text. The main use cases:
ICD and CPT coding. Automated extraction of billing codes from clinical documentation. A model reads a discharge summary and suggests the ICD-10 diagnosis codes and CPT procedure codes that should be billed, reducing the manual burden on medical coders and improving coding consistency.
Clinical named entity recognition (NER). Identification and extraction of specific entity types in clinical text: diagnoses, medications (with dose, route, and frequency), procedures, lab results, anatomical locations, and clinical findings. This powers structured data extraction from unstructured clinical notes.
Medication NER. A specialized subtype of clinical NER focused on medication mentions. A well-trained medication NER model extracts not just drug names but also dose ("metoprolol 25mg"), frequency ("twice daily"), route ("oral"), and status ("discontinued").
Discharge summary classification. Classifying discharge summaries by primary diagnosis category, readmission risk, or care pathway for population health management.
Temporal reasoning. Understanding the sequence of clinical events: "the patient developed atrial fibrillation three days after surgery" requires understanding temporal relationships between entities. This is harder than simple entity extraction and requires annotated temporal reasoning examples in training data.
Each of these requires a different annotation schema. A dataset suitable for medication NER has different labels than a dataset suitable for ICD coding. Training data preparation must be scoped to specific clinical NLP tasks, not prepared generically.
What Training Data These Models Require
Clinical NLP models require annotated clinical text — documents where human reviewers have applied labels according to a consistent annotation schema. The annotation is the training signal.
For a clinical NER model, annotations are span-level labels: character offsets marking the start and end of each entity mention, plus the entity type. A single clinical note with 600 words might contain 40–60 entity annotations across diagnoses, medications, and procedures.
An annotated example looks like this in serialized form:
{
"text": "Patient was started on lisinopril 10mg daily for hypertension.",
"entities": [
{"start": 21, "end": 31, "label": "DRUG", "text": "lisinopril"},
{"start": 32, "end": 36, "label": "DOSE", "text": "10mg"},
{"start": 37, "end": 42, "label": "FREQUENCY", "text": "daily"},
{"start": 47, "end": 59, "label": "CONDITION", "text": "hypertension"}
]
}
For an ICD coding model, the annotation is document-level: the ICD-10 codes that apply to the document, with the text span that supports each code.
The minimum viable dataset sizes for clinical NLP:
- Clinical NER model (single entity type, e.g., medications): 2,000–5,000 annotated sentences
- Clinical NER model (full entity set): 10,000–30,000 annotated sentences
- ICD coding model: 5,000–20,000 annotated discharge summaries
- Document classification model: 3,000–10,000 labeled documents per class
These numbers assume a well-designed annotation schema and consistent annotation quality. Inconsistent annotations require more data to overcome the noise.
Who Should Label Clinical NLP Data
This is the question that derails most healthcare AI projects. The instinct is to have ML engineers or data scientists do the annotation. This is the wrong approach.
Clinical NLP annotation requires clinical knowledge. Deciding whether "shortness of breath" is a symptom annotation or a diagnosis annotation requires understanding clinical context. Annotating medication dosing requires reading "lisinopril 10mg twice daily" and correctly distinguishing the drug name from the dose from the frequency. Identifying whether a finding is affirmed or negated ("no evidence of pneumonia" should not create a positive "pneumonia" annotation) requires clinical reading comprehension.
The people who should be labeling clinical NLP data are clinicians: physicians, nurses, pharmacists, and medical coders — depending on the task. A medication NER model annotated by pharmacists will significantly outperform one annotated by non-clinicians.
The practical problem is that clinicians are not ML engineers. They do not know how to use Label Studio, Prodigy, or any tool that requires Docker setup, JSON configuration files, or command-line initialization. They are busy, and they will not invest hours learning annotation tooling before they can do any annotation.
This creates a hard requirement for the annotation interface: it must be operable by a domain expert with no technical background, with zero setup. A clinician should be able to open the application, see a clinical note, and start drawing annotation spans with a mouse, with the entity type labels visible as buttons — without any technical assistance.
The HIPAA-Compliant Pipeline
The full data preparation pipeline for clinical NLP training data has six stages. Every stage must run on-premise.
Stage 1: Data extraction. Clinical notes, discharge summaries, and imaging reports are extracted from the EHR system. This requires coordination with the EHR team and appropriate data access controls. Outputs are raw text or structured documents containing PHI.
Stage 2: PHI redaction. Every document undergoes automated PHI detection and redaction before any annotation begins. The 18 Safe Harbor identifiers are detected using clinical NER models trained for PHI detection. Detected instances are reviewed by a human reviewer (typically a data governance or compliance team member, not the clinical annotators). After review, redactions are applied and logged. Only de-identified documents proceed to annotation. The redaction log is retained indefinitely.
Stage 3: Annotation schema design. Before annotation begins, the annotation guidelines are written: what entity types exist, how to handle ambiguous cases, what the boundaries of each entity span should be, and how to handle negation and uncertainty. Good annotation guidelines reduce annotator disagreement and improve training data quality. This stage is done once but revised as edge cases emerge.
Stage 4: Clinical annotation. De-identified documents are distributed to clinical annotators. Annotators apply entity labels using the annotation interface. A subset of documents is annotated by two or more annotators independently, to calculate inter-annotator agreement. Agreement is measured using Cohen's kappa or F1 on overlapping spans. An agreement score below 0.7 kappa indicates annotation guideline problems that should be resolved before continuing.
Stage 5: Quality review. Annotations are reviewed for consistency. Documents with very low annotation density (possible annotator fatigue or document quality issues) and very high annotation density (possible over-annotation) are flagged. Systematic disagreements between annotators trigger guideline revisions.
Stage 6: JSONL export. Approved annotations are exported in the format required by the downstream training framework. For most clinical NLP frameworks, this is JSONL with entity spans. The export includes document-level metadata (document type, specialty, approximate date range) that can be used for stratified evaluation.
Where Existing Tools Fall Short
Label Studio is the most commonly mentioned open-source annotation tool for NLP. It has a clinical NER template and supports span-level annotation. The problem: Label Studio requires Docker for deployment, a server setup, and database configuration. A clinical annotator cannot set it up independently. In a hospital environment, getting Docker installed and a server provisioned can take weeks of IT approvals. And Label Studio runs as a web application — the annotation data is served over a network, raising questions about where it is stored and who has access.
Cloud annotation services (Scale AI, Surge AI, Appen) are explicitly off-limits for PHI. These services involve human annotators who are not healthcare employees, reviewing documents that would need to be PHI before redaction is complete. Even with redaction, sending clinical documents to a third-party annotation service raises data governance questions that most hospital legal teams will not approve.
Prodigy (from the spaCy team) is a strong annotation tool that runs locally, but it is a Python command-line application. Running prodigy ner.manual clinical_ner en_core_web_sm clinical_notes.jsonl is not a realistic expectation for a clinical annotator. It requires a configured Python environment, the Prodigy license installed, and familiarity with command-line tools.
The gap in the existing tooling is a local-first, no-setup annotation application that clinical annotators can operate directly. The annotation interface must be native (not browser-based, not Docker-based), must require no technical setup, and must include the redaction and export steps in the same workflow so that the compliance steps cannot be bypassed.
Getting Started
For a healthcare AI team starting a clinical NLP project, the sequence is:
- Define the specific NLP task (medication NER, ICD coding, etc.) before touching any data
- Write the annotation schema and guidelines with clinical input — not ML engineering input
- Process a pilot batch of 500 documents through the full pipeline: PHI redaction → annotation → quality review
- Calculate inter-annotator agreement on the pilot batch
- If agreement is below 0.7 kappa, revise the guidelines and repeat
- Scale to the full dataset only after the pilot validates the annotation quality
The temptation is to annotate thousands of documents and then worry about quality. The result is a large dataset of inconsistently annotated documents that trains a mediocre model. A smaller, high-quality dataset consistently outperforms a larger, noisy one.
Your data is the bottleneck — not your models.
Ertas Data Suite turns unstructured enterprise files into AI-ready datasets — on-premise, air-gapped, with full audit trail. One platform replaces 3–7 tools.
Related Reading
- PHI Redaction for AI Training: A Step-by-Step Guide for Healthcare ML Teams — Complete PHI detection and redaction workflow
- Why Vector RAG Fails on Clinical Data — and What to Use Instead — When fine-tuned clinical NLP outperforms RAG
- HIPAA-Compliant AI Training Data Guide — HIPAA framework and compliance requirements for healthcare AI
Turn unstructured data into AI-ready datasets — without it leaving the building.
On-premise data preparation with full audit trail. No data egress. No fragmented toolchains. EU AI Act Article 30 compliance built in.
Keep reading

Best HIPAA-Compliant RAG Pipeline for Healthcare: On-Premise Document Retrieval Without Data Egress
Healthcare organizations need RAG for clinical AI — but cloud-based retrieval pipelines violate HIPAA when they process PHI. Here is how to build a compliant RAG pipeline that runs entirely on your infrastructure.

No-Code Data Labeling for Healthcare Teams
Clinicians understand clinical data better than any ML engineer. Here's why clinical NLP models need clinician-labeled data, how HIPAA prevents cloud-based labeling, and how native desktop tools let clinicians label directly.

The Real Cost of Cloud Data Prep in Regulated Industries (2026)
Cloud data prep tools require compliance approvals that cost $50K–$150K and take 6–18 months. On-premise alternatives eliminate these costs entirely. Here's the TCO comparison regulated industries need.