--- license: cc-by-4.0 language: - en task_categories: - token-classification task_ids: - named-entity-recognition tags: - medical - clinical-nlp - ner - information-extraction - synthetic - icd10 - clinical-ips pretty_name: SynthIPS size_categories: - n<1K configs: - config_name: documents data_files: data/documents/*.parquet default: true - config_name: chunks data_files: data/chunks/*.parquet - config_name: patient_summary data_files: data/patient_summary/*.parquet --- # SynthIPS — Synthetic IPS NER Validation Dataset A validation dataset of **10 synthetic patients** across **29 clinical encounters**, annotated for the three core entity types of the **International Patient Summary (IPS)** standard: **Condition**, **Medication**, and **Lab**. The [International Patient Summary (IPS)](https://www.hl7.org/fhir/uv/ips/) is an HL7 FHIR standard for a minimal, specialty-agnostic health record designed for cross-border and cross-system care continuity. SynthIPS is built around its three primary clinical sections — problems, medications, and lab results — and provides realistic clinical documents with ground-truth annotations aligned to IPS entity types, ICD-10 condition codes, ATC medication codes, and LOINC lab identifiers. Documents include structured blocks (problem lists, medication tables, lab grids) alongside free-text narrative sections and deliberate distractor spans (negated / ruled-out entities), reflecting the mixed layout of real clinical encounter documents. | Stat | Value | |------|-------| | Patients | 10 | | Encounters | 29 | | GT spans | 171 (86 Condition · 85 Medication) | | Distractor spans | 14 | | Structured lab analytes | 446 (35 unique, 100% LOINC coverage) | | Text segments | 815 (111 contain GT entities) | | Encounter types | initial\_consult · follow\_up · specialist\_letter · acute\_visit · lab\_review | | Patient profiles | minimal · typical · complex (controls entity density) | --- ## Configs All configs share `doc_id` (e.g. `"patient_01/encounter_01"`) and `patient_id` as join keys. | Config | Rows | Primary use | |--------|------|-------------| | `documents` *(default)* | 29 | Full archive — document text, PDF, all GT annotations | | `chunks` | 815 | NER evaluation — one row per document segment with inline entity annotations | | `patient_summary` | 10 | Patient-level overview — aggregated GT spans, labs, encounter list | ### How configs relate ``` patient_summary ── patient_id ──► documents ◄── doc_id ──► chunks (source of truth) ``` **Lab data** lives in `documents.structured_entities` (filter to `block == "lab_grid"`). --- ## Quick start ```python from datasets import load_dataset import json # ── Chunk-level NER (recommended starting point) ───────────────────────── chunks = load_dataset("betterInnovation/SynthIPS", "chunks", split="test") for chunk in chunks: entities = json.loads(chunk["gt_entities"]) if not entities: continue for e in entities: span = chunk["markdown_text"][e["start"]:e["end"]] print(chunk["segment_type"], f"p{chunk['page_number']}", e["label"], repr(span), "|", e["kg_id"]) # ── Full-document NER (join chunks → documents for full text) ───────────── docs = load_dataset("betterInnovation/SynthIPS", "documents", split="test") doc = docs[0] gt_spans = json.loads(doc["gt_spans"]) for e in gt_spans: span = doc["markdown_text"][e["start"]:e["end"]] print(e["surface"], "→", e["label"], "|", e["canonical"]) # ── Lab data ────────────────────────────────────────────────────────────── labs = [e for e in json.loads(doc["structured_entities"]) if e["block"] == "lab_grid"] for lab in labs: print(lab["analyte"], lab["value"], lab["unit"], lab["flag"], lab["loinc"]) # ── PDF bytes (rendered natively in HF Data Viewer) ─────────────────────── # doc["pdf_bytes"] → {"bytes": b"...", "path": None} (~70 KB, 3 pages each) # ── Patient summary ─────────────────────────────────────────────────────── patients = load_dataset("betterInnovation/SynthIPS", "patient_summary", split="test") for p in patients: print(p["patient_id"], p["profile"], p["n_encounters"], "encounters") print(" encounter types:", list(p["encounter_kinds"])) # native Arrow list ``` --- ## Column reference ### `documents` config — 29 rows One row per encounter. The default config. PDF renders natively in the HF Data Viewer. | Column | Type | Description | |--------|------|-------------| | `doc_id` | string | `"patient_01/encounter_01"` — join key | | `patient_id` | string | `"patient_01"` — join key | | `pdf_bytes` | Pdf | Raw PDF (~70 KB, 3 pages). Renders as page viewer in HF Data Viewer. | | `markdown_text` | string | Full document text as markdown — header, problem list, medication table, lab grid, narrative, signatures. `start`/`end` offsets in `gt_spans` point here. | | `patient_name` | string | | | `patient_profile` | string | `minimal / typical / complex` | | `patient_sex` | string | `"M"` / `"F"` | | `patient_dob` | string | ISO date | | `anchor_icd10` | string | Primary ICD-10 codes | | `clinical_hook` | string | One-line clinical summary | | `encounter_id` | string | `"encounter_01"` | | `encounter_kind` | string | `initial_consult / follow_up / specialist_letter / acute_visit / lab_review` | | `encounter_title` | string | Full encounter title | | `encounter_date` | string | ISO date | | `provider_name` | string | | | `provider_role` | string | | | `provider_facility` | string | | | `gt_spans` | string (JSON) | GT entity spans — `start`/`end` into `markdown_text` | | `distractor_spans` | string (JSON) | Trap spans (negated / family history / hypothetical) — should NOT be extracted | | `structured_entities` | string (JSON) | Structured block entities (lab grid, problem list, medications) with LOINC/ICD-10/ATC codes | ### `chunks` config — 815 rows One row per document segment. `markdown_text` here is the segment's own slice of the full document text. Join on `doc_id → documents` for complete document context. | Column | Type | Description | |--------|------|-------------| | `doc_id` | string | Join key → `documents` | | `patient_id` | string | | | `markdown_text` | string | This segment's text. `start`/`end` in `gt_entities` are offsets into this field. | | `encounter_id` | string | | | `encounter_kind` | string | | | `patient_profile` | string | | | `chunk_id` | string | Segment identifier within the encounter | | `page_number` | int | Document page (1-indexed) | | `chunk_order` | int | Reading order within the encounter | | `segment_type` | string | `"text"` or `"table"` | | `gt_entities` | string (JSON) | GT entities in this segment — `start`/`end` into `markdown_text` | | `distractor_entities` | string (JSON) | Distractor spans in this segment | ### `patient_summary` config — 10 rows One row per patient. Cross-encounter data pre-aggregated. | Column | Type | Description | |--------|------|-------------| | `patient_id` | string | | | `patient_name` | string | | | `sex` | string | `"M"` / `"F"` | | `dob` | string | ISO date | | `profile` | string | `minimal / typical / complex` | | `anchor_icd10` | string | Primary diagnoses | | `clinical_hook` | string | One-line clinical summary | | `n_encounters` | int | | | `encounter_ids` | list[string] | Native Arrow list — no `json.loads` needed | | `encounter_kinds` | list[string] | Native Arrow list | | `all_gt_spans` | string (JSON) | All GT spans across all encounters — filter by `label` for Condition / Medication | | `all_distractors` | string (JSON) | All distractor spans | | `all_labs` | string (JSON) | All structured lab analytes across all encounters | --- ## Entity span schema Applies to `gt_spans` / `distractor_spans` (documents) and `gt_entities` / `distractor_entities` (chunks). | Field | Type | Description | |-------|------|-------------| | `surface` | str | Exact mention text as it appears in the document (may be abbreviation: `"HTN"`, `"T2DM"`) | | `label` | str | IPS type: `Condition` or `Medication` | | `start` | int | Start char offset into `markdown_text` (document-level in `documents`, segment-level in `chunks`) | | `end` | int | End char offset into `markdown_text` | | `kg_id` | str | ICD-10 code (Condition) or ATC code (Medication) | | `canonical` | str | Normalised entity name — use for normalisation scoring | | `section_kind` | str | Source section: `hpi` · `social_history` · `clinical_observation` · `assessment` | **Offset guarantee:** `markdown_text[start:end]` matches `surface` after whitespace normalisation. Line-wrapping may insert `\n` between words — normalise with `re.sub(r'\s+', ' ', span)` before comparing. **Distractors** share the same schema. They are contextually plausible entities that appear in the narrative but are *not* part of the patient's confirmed record (negated diagnoses, family history mentions, hypothetical treatments). A model that extracts them is producing false positives. --- ## Usage guide ### 1 · Chunk-level NER (primary track) ```python import json from datasets import load_dataset from nervaluate import Evaluator chunks = load_dataset("betterInnovation/SynthIPS", "chunks", split="test") all_gold, all_preds = [], [] for chunk in chunks: gold = [ {"label": e["label"], "start": e["start"], "end": e["end"]} for e in json.loads(chunk["gt_entities"]) ] preds = your_model(chunk["markdown_text"]) # same format all_gold.append(gold) all_preds.append(preds) evaluator = Evaluator(all_gold, all_preds, tags=["Condition", "Medication"]) results, _ = evaluator.evaluate() ``` ### 2 · Full-document NER ```python docs = load_dataset("betterInnovation/SynthIPS", "documents", split="test") for doc in docs: gold = [ {"label": e["label"], "start": e["start"], "end": e["end"]} for e in json.loads(doc["gt_spans"]) ] preds = your_model(doc["markdown_text"]) # ... accumulate and evaluate ``` ### 3 · Distractor robustness (false-positive rate) ```python from rapidfuzz import fuzz def fires_on(pred_surface, distractor_surface, threshold=85): return fuzz.token_set_ratio(pred_surface.lower(), distractor_surface.lower()) >= threshold for doc in docs: distractors = json.loads(doc["distractor_spans"]) preds = your_model(doc["markdown_text"]) fp = sum( 1 for d in distractors if any(fires_on(p["text"], d["surface"]) for p in preds) ) fp_rate = fp / len(distractors) if distractors else 0 ``` ### 4 · Lab analyte extraction ```python for doc in docs: labs = [e for e in json.loads(doc["structured_entities"]) if e["block"] == "lab_grid"] # Each lab: analyte, value, unit, flag, loinc # Score: precision/recall at analyte-name level against model output on markdown_text ``` ### 5 · Entity normalisation scoring Compare model output against `canonical` (normalised name) and `kg_id` (ICD-10 / ATC code). --- ## The 10 patients | ID | Name | Sex | DoB | Profile | Primary conditions | |----|------|-----|-----|---------|-------------------| | patient\_01 | Donald Wilson | M | 1957-01-14 | typical | T2DM, hypertension, dyslipidaemia | | patient\_02 | Kimberly Hernandez | F | 2000-01-31 | minimal | Asthma, allergic rhinitis | | patient\_03 | Charles Lopez | M | 1943-07-09 | complex | Heart failure, arrhythmia, T2DM | | patient\_04 | Jennifer Martin | F | 1978-11-23 | typical | MDD, GAD | | patient\_05 | Patricia Moore | F | 1965-06-19 | typical | Knee OA, chronic low back pain, dyslipidaemia | | patient\_06 | Karen Thomas | F | 1972-06-14 | minimal | Primary hypothyroidism | | patient\_07 | William Johnson | M | 1947-07-17 | complex | COPD, hypertension, smoking | | patient\_08 | Thomas Lee | M | 1955-11-14 | complex | Diabetic nephropathy CKD3, prior MI, angina | | patient\_09 | Emily Hernandez | F | 1989-11-23 | typical | GERD, anxiety | | patient\_10 | Karen Wilson | F | 1964-03-29 | typical | Osteoporosis, RA, hypothyroidism | **Profile** controls entity density: `minimal` (1–3 problems/meds) · `typical` (3–6) · `complex` (6–12). --- ## Design notes ### IPS entity types SynthIPS covers the three primary sections of the **IPS standard**: | IPS section | Label in dataset | Identifier | |-------------|-----------------|------------| | Problems (conditions, diagnoses) | `Condition` | ICD-10 via `kg_id` | | Medications | `Medication` | ATC code via `kg_id` | | Results (lab analytes) | `Lab` | LOINC code via `loinc` field in `structured_entities` | Entity names in `canonical` follow the IPS-preferred normalised form. Abbreviations and synonyms (e.g. `"HTN"`, `"T2DM"`) are preserved in `surface` exactly as they appear in the document. ### Document structure Each encounter document contains several distinct sections: institution header, patient demographics, structured problem list, medication table, structured lab grid, and free-text narrative sections (HPI, social history, clinical examination, assessment & plan). This mixed structure — combining tabular and narrative content — reflects the layout of real clinical encounter documents and is a deliberate challenge for NER models. `markdown_text` preserves this structure as formatted markdown. All `start`/`end` offsets in entity spans point into `markdown_text`. ### Distractor design Each encounter includes 0–1 deliberate trap spans: clinically plausible entities that appear in the narrative but are negated, belong to family history, are ruled out, or are hypothetical. Examples: *"no evidence of X"*, *"father had X"*, *"we will consider X if..."*. These measure whether a model extracts *only* confirmed, patient-present entities. ### Reproducibility Every encounter document is deterministic given its `layout_seed`. Re-running the composer with the same source files produces byte-identical documents and GT annotations. --- ## Citation ```bibtex @dataset{synthips2026, title = {SynthIPS: Synthetic IPS NER Validation Dataset}, author = {Better Care}, year = {2026}, url = {https://huggingface.co/datasets/betterInnovation/SynthIPS}, license = {CC BY 4.0} } ``` --- ## License [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) — free to use, share, and adapt with attribution.