UnsolvedMedical / scripts /generate_dataset_card.py
przemekch's picture
Release UnsolvedMedical v3.0.0 (20,000 problems, 5-source provenance with 1,184 live NCT trials, paper-native PICO, and 500-problem AI benchmark)
84602b6 verified
Raw History Blame Contribute Delete
13.4 kB
#!/usr/bin/env python3
"""
Generate README.md (Hugging Face Dataset Card with YAML frontmatter) and DATASET_CARD.md
for UnsolvedMed (ulamai/UnsolvedMedical) v2.0.0 (20,000 open problems, with v1.0 10k and v1.5 15k milestones).
"""
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def main() -> None:
stats = json.loads((ROOT / "statistics.json").read_text(encoding="utf-8"))
cats_meta = json.loads((ROOT / "categories.json").read_text(encoding="utf-8"))
version = stats.get("version", "2.0.0")
pub_cnt = stats["published_open_problems"]
gold_cnt = stats["gold_seed_problems"]
arch_cnt = stats["archived_and_withheld_records"]
tot_cnt = stats["total_records"]
cat_rows = []
for c in cats_meta:
cid = c["id"]
slug = c["slug"]
name = c["display_name"]
v1_c = c.get("target_v1_records", 0)
v15_c = c.get("target_v1_5_records", int(v1_c * 1.5))
cnt = stats["by_primary_category"].get(slug, 0)
g_cnt = stats["gold_seed_by_primary_category"].get(slug, 0)
share = (cnt / pub_cnt) * 100
cat_rows.append(f"| {cid} | **{name}** (`{slug}`) | {v1_c:,} | {v15_c:,} | **{cnt:,}** | {share:.1f}% | {g_cnt:,} |")
cat_table = "\n".join(cat_rows)
qtype_rows = []
for qt, cnt in sorted(stats["by_question_type"].items(), key=lambda x: (-x[1], x[0])):
share = (cnt / pub_cnt) * 100
qtype_rows.append(f"| `{qt}` | {cnt:,} | {share:.1f}% |")
qtype_table = "\n".join(qtype_rows)
pub_class_rows = []
for pc, cnt in sorted(stats["by_publication_class_all"].items(), key=lambda x: (-x[1], x[0])):
in_curr = "Yes (`published = true`)" if pc in stats["by_publication_class_current"] else "No — Audit/Calibration (`published = false`)"
pub_class_rows.append(f"| `{pc}` | {cnt:,} | {in_curr} |")
pub_class_table = "\n".join(pub_class_rows)
nct_cnt = stats.get("clinical_trials_gov_sources", 1184)
lit_cnt = stats.get("peer_reviewed_literature_sources", 27191)
anc_cnt = stats.get("institutional_status_anchor_sources", 800)
src_per_prob = stats.get("total_sources_per_published_problem", 5)
card_body = f"""# UnsolvedMedical (`ulamai/UnsolvedMedical`) — v{version}
> [!IMPORTANT]
> **MEDICAL DISCLAIMER — NOT CLINICAL OR PATIENT ADVICE:**
> **UnsolvedMed (`ulamai/UnsolvedMedical`) is a scientific research dataset of unresolved medical, clinical, translational, and population-health research questions. It is NOT medical advice, a clinical decision support tool, a diagnostic device, a prescribing guide, or a substitute for professional healthcare judgment.** Nothing in this dataset should be used to diagnose, treat, cure, or prevent any disease in an individual patient, or to alter any patient's medication or care plan.
---
## 1. Dataset Summary
**UnsolvedMed (`ulamai/UnsolvedMedical`) v{version}** is a curated, provenance-rich, status-verified benchmark and research repository of **{pub_cnt:,} open and partially resolved medical problems** (`UMED-000001` to `UMED-{pub_cnt:06d}`, `published = true`), accompanied by a stratified **{gold_cnt:,}-problem Gold Seed** (`UMED-000001` to `UMED-{gold_cnt:06d}`, `is_gold_seed = true`), a **500-problem executable AI benchmark (`eval/benchmark_v3.jsonl`)**, and **{arch_cnt:,} archived/withheld calibration and style-pack audit records** (`UMED-{pub_cnt + 1:06d}` to `UMED-{tot_cnt:06d}`, `published = false`), totaling **{tot_cnt:,} canonical records**.
Modeled as the medical sibling to [`ulamai/UnsolvedMath`](https://huggingface.co/datasets/ulamai/UnsolvedMath), UnsolvedMed v{version} adapts open-problem curation to the epistemology of empirical medicine across **400 clinical sub-domains** (20 per primary category) and **20 controlled question types**:
- **Paper-Native PICO & Condition-Coherent Outcomes:** Every published problem extracts paper-verified condition/subtype, intervention/exposure/biomarker, comparator, and domain-coherent primary, safety, and patient-reported outcomes across **100 natural clinical research question formulations** (`5 structural variants × 20 question types`), paired with a concise 1-sentence core PICO `clean_statement` and patient-accessible `plain_language_statement`.
- **5-Source Provenance with Live ClinicalTrials.gov (`NCT0...`) Linkage:** Every published problem is backed by **5 distinct sources**: **3 semantically co-cited peer-reviewed medical literature papers** (`problem_origin`, `openness_support`, and `partial_result` with real DOIs/PMIDs), **1 sub-domain-matched Tier A/B/C/D institutional consensus, guideline, or priority-setting status anchor** (`status_review`), and **1 live registered clinical trial (`NCT0...`)** harvested from the ClinicalTrials.gov API v2 (`ongoing_research`).
- **Compact & Self-Contained (`< 400 MB`):** Zero raw documents or verbatim source excerpts are stored; all fields (`statement`, `clean_statement`, `plain_language_statement`, `background`, `why_open`, `known_partial_results`, `competing_hypotheses_or_interpretations`, `what_would_settle_it`) are synthesized in our canonical UnsolvedMed format.
### Release Highlights (v{version})
| Metric | v1.0.0 | v1.5.0 | v2.0.0 | **v{version} (Current)** |
| :--- | :--- | :--- | :--- | :--- |
| **Published Open / Partially-Resolved Problems (`problems.json`)** | 10,000 | 15,000 | 20,000 | **{pub_cnt:,}** (`UMED-000001` – `UMED-{pub_cnt:06d}`) |
| **Stratified Gold Seed Problems (`data/gold/problems.jsonl`)** | 1,000 | 1,500 | 2,000 | **{gold_cnt:,}** (`UMED-000001` – `UMED-{gold_cnt:06d}`, 10.0% per category) |
| **Executable AI Benchmark (`eval/benchmark_v3.jsonl`)** | — | — | — | **500** stratified Gold-Seed problems + 4 reference baselines |
| **Archived & Withheld Calibration Records (`published = false`)** | 100 | 100 | 100 | **{arch_cnt:,}** (`UMED-{pub_cnt + 1:06d}` – `UMED-{tot_cnt:06d}`) |
| **Total Canonical Records (`dataset.json`)** | 10,100 | 15,100 | 20,100 | **{tot_cnt:,}** |
| **Clinical Sub-Domains & Question Formulations** | 200 / 20 | 400 / 20 | 400 / 20 | **400 sub-domains / 100 natural question templates** |
| **Peer-Reviewed Literature Papers per Published Problem** | 3 | 3 | 3 | **3 semantically co-cited papers** (`problem_origin`, `openness_support`, `partial_result`) |
| **Live ClinicalTrials.gov (`NCT0...`) Registry Linkage** | — | — | — | **1,184 active/registered `NCT0...` trials** (`ongoing_research`) |
| **Total Sources per Published Problem** | 4 | 4 | 4 | **{src_per_prob}** (3 peer-reviewed papers + 1 Tier A–D status anchor + 1 `NCT0...` trial) |
| **Registered Provenance Sources (`source_registry.json`)** | 23,071 | 28,532 | 30,289 | **{stats['total_registered_sources']:,}** ({lit_cnt:,} papers + {anc_cnt:,} status anchors + {nct_cnt:,} NCT trials) |
| **Explicit Problem Relations (`relations/relations.jsonl`)** | 5,015 | 7,515 | 10,015 | **{stats['total_relations']:,}** |
| **Immutable Status Events (`history/status_events.jsonl`)** | 10,100 | 15,100 | 20,100 | **{stats['total_status_events']:,}** |
| **Publication Gates Enforced** | 18 / 18 | 18 / 18 | 18 / 18 | **18 / 18 (0 validation errors)** |
---
## 2. Primary Medical Categories & Allocation Across v1.0, v1.5, and v{version}
| # | Primary Category | v1.0 (10k) | v1.5 (15k) | **v{version} ({pub_cnt:,})** | Share | Gold Seed (`v{version}`) |
| :---: | :--- | ---: | ---: | ---: | ---: | ---: |
{cat_table}
| **Total** | **All 20 Primary Medical Categories (400 Sub-Domains)** | **10,000** | **15,000** | **{pub_cnt:,}** | **100.0%** | **{gold_cnt:,}** |
---
## 3. Distribution by Question Type & Publication Class
### 3.1 Question Types ({pub_cnt:,} Published Records)
| Question Type | Count | Share |
| :--- | ---: | ---: |
{qtype_table}
### 3.2 Publication Classes (All {tot_cnt:,} Records)
| Publication Class | Count | Default Release Inclusion |
| :--- | ---: | :--- |
{pub_class_table}
---
## 4. UnsolvedMedical-Bench v3.0 (AI Medical Research Evaluation Suite)
`eval/benchmark_v3.jsonl` provides a stratified **500-problem evaluation benchmark** (25 Gold-Seed problems per primary medical category across all 20 question types) scored by `scripts/evaluate_ai_benchmark.py` across 4 tasks:
1. **Task 1 — Confirmatory Study Design Selection (`StudyMode F1`):** Predict the optimal settlement study modes (`what_would_settle_it.preferred_study_modes`).
2. **Task 2 — Epistemic Evidence-Gap Root-Cause Diagnosis (`Gap F1`):** Identify the primary reason the clinical question remains unsettled (`why_open.primary_reasons`).
3. **Task 3 — Structured PICO & Endpoint Protocol Specification (`PICO Score`):** Reconstruct the target intervention, comparator, primary endpoint, and follow-up horizon.
4. **Task 4 — Competing Mechanistic / Clinical Hypothesis Discrimination (`Hyp Acc`):** Discriminate the genuine competing clinical interpretation from domain-matched distractors.
| Reference Baseline (`eval/benchmark_summary.json`) | Composite Score | StudyMode F1 | Gap F1 | PICO Score | Hyp Acc |
| :--- | ---: | ---: | ---: | ---: | ---: |
| `uninformed_rct_majority_baseline` | **20.50** | 32.00 | 0.00 | 25.02 | 23.25 |
| `lexical_clinical_heuristic_baseline` | **41.58** | 37.68 | 13.84 | 60.62 | 58.30 |
| `domain_neighbor_retrieval_baseline` | **61.16** | 58.40 | 52.40 | 51.79 | 87.95 |
| `oracle_reference_upper_bound` | **100.00** | 100.00 | 100.00 | 100.00 | 100.00 |
---
## 5. Repository Layout & Compatibility
UnsolvedMed matches the compact, clean repository structure of `ulamai/UnsolvedMath`:
- **Root UnsolvedMath-compatible JSONs:**
- `problems.json` — {pub_cnt:,} published open/partially-resolved medical problems (`published = true`)
- `dataset.json` — All {tot_cnt:,} canonical records (including 100 calibration/archived/withheld records)
- `research_results.json` — Structured literature and status assessments for all {tot_cnt:,} records
- `source_registry.json` — {stats['total_registered_sources']:,} provenance sources (papers, guidelines, and `NCT0...` trials) with DOIs, PMIDs, tiers, and license metadata
- `statement_audit.json` — Statement quality, rights, and safety review records
- `statistics.json`, `categories.json`, `difficulty_levels.json`, `sets.json`
- **Parquet, Benchmark & Canonical Tables:**
- `releases/unsolvedmed_current.parquet` (v{version}: {pub_cnt:,} published records) & `releases/unsolvedmed_v1_5_current.parquet` (v1.5: 15,000 published records)
- `eval/benchmark_v3.jsonl` & `eval/benchmark_summary.json` (500-problem AI medical research benchmark & reference baselines)
- `data/gold/problems.jsonl` ({gold_cnt:,} Gold Seed records)
- `relations/relations.jsonl` ({stats['total_relations']:,} problem relations)
- `history/status_events.jsonl` ({stats['total_status_events']:,} status events)
- `schemas/*.schema.json`, `ontology/*.yaml`, `taxonomy/*.yaml`, `prompts/*.md`, `docs/*.md`
---
## 6. Quickstart Usage
```python
import json
import pyarrow.parquet as pq
# Load v{version} (20,000 problems) via Parquet
table = pq.read_table("releases/unsolvedmed_current.parquet")
print("Published problems in Parquet:", table.num_rows)
# Load Gold Seed ({gold_cnt:,} clinician + methodologist verified records)
with open("data/gold/problems.jsonl", "r", encoding="utf-8") as f:
gold_seed = [json.loads(line) for line in f]
print("Gold Seed records:", len(gold_seed))
print("Sample question:", gold_seed[0]["id"], "->", gold_seed[0]["statement"])
print("Clean PICO statement:", gold_seed[0]["clean_statement"])
print("Active registered trials:", gold_seed[0]["status_assessment"]["active_research"])
```
---
## 7. Licensing, Provenance & Responsible Release
- **Dataset Metadata, Taxonomy & Newly Authored Canonical Paraphrases:** Licensed under **CC BY 4.0** (`LICENSE`).
- **Source Reuse Policy:** All canonical titles, statements, backgrounds, and evidence-gap syntheses are newly written in house style. Zero raw documents or verbatim source excerpts are redistributed.
- **Safety & Ethics:** Every published record passed Gate 17 (Ethics, Safety, and Non-Harm), ensuring zero patient-identifiable data, zero individualized clinical advice framing, and zero actionable dual-use biological hazard details.
"""
yaml_frontmatter = f"""---
annotations_creators:
- expert-generated
- machine-generated
language:
- en
license: cc-by-4.0
multilinguality:
- monolingual
pretty_name: UnsolvedMedical ({pub_cnt:,} Open Medical, Clinical, Translational, and Public-Health Problems)
size_categories:
- 10K<n<100K
source_datasets:
- original
tags:
- medicine
- clinical-research
- evidence-based-medicine
- clinical-trials
- open-problems
- biomedical
- healthcare
- benchmark
- unsolved-problems
task_categories:
- question-answering
- text-classification
- feature-extraction
configs:
- config_name: default
data_files:
- split: train
path: releases/unsolvedmed_current.parquet
- config_name: v1.5
data_files:
- split: train
path: releases/unsolvedmed_v1_5_current.parquet
---
"""
(ROOT / "README.md").write_text(yaml_frontmatter + card_body, encoding="utf-8")
(ROOT / "DATASET_CARD.md").write_text(card_body, encoding="utf-8")
print(f"Generated README.md and DATASET_CARD.md for v{version} successfully.")
if __name__ == "__main__":
main()