InterGenEHR: An Interactive Framework for Natural Language-Conditioned Generation of Longitudinal Patient Trajectories
Organizations: Department of Electrical and Computer Engineering, Duke University, Durham, NC · Department of Biomedical Engineering, Duke University, Durham, NC · Department of Emergency Medicine, Emory University, Atlanta, GA · Department of Pediatrics, Duke University, Durham, NC ·
Abstract
Objective: To develop and validate InterGenEHR, an interactive framework for natural language-conditioned generation of synthetic tabular electronic health records (EHRs) and longitudinal trajectories for scenario-based evaluation of machine learning models. Methods: An optional large language model (LLM) parser converts clinical requests into structured constraints. Conditional variational autoencoders and diffusion models generate single-time-point records, while diffusion models generate longitudinal trajectories. We evaluate parsing, distributional fidelity, imputation, clinical-constraint adherence, mortality prediction, and clinical plausibility using a multi-institutional cohort of 874 patients receiving venovenous extracorporeal membrane oxygenation (VV-ECMO). Results: Gemma 3 4B with few-shot prompting achieves the highest parsing performance with a low spurious slot rate. IGE-TabDDPM and IGE-PMVAE perform well in single-time-point generation; IGE-CSDI, IGE-FGTI, and IGE-MTSCI lead on different longitudinal fidelity metrics. Across five random seeds and three classifiers, synthetic cohorts retain predictive utility for mortality prediction on real test data. Clinician ratings support trajectory plausibility and alignment with requested scenarios. Conclusion: InterGenEHR supports clinician-specified generation of EHR trajectories with statistical fidelity and downstream predictive utility in the evaluated VV-ECMO cohort. Extension to other clinical settings requires further validation. Significance: The framework supports scenario-based evaluation of machine learning models in data-sparse critical care settings.
Figures & tables
| Overall | Duke | Emory | |
| n | 874 | 691 | 183 |
| Age, mean (SD) | 47.8 (14.6) | 48.4 (14.8) | 45.4 (13.7) |
| Gender, n (%) | |||
| Female, n (%) | 381 (43.6) | 304 (44.0) | 77 (42.1) |
| Male, n (%) | 493 (56.4) | 387 (56.0) | 106 (57.9) |
| Race, n (%) | |||
| Method | MAMD | RMSPE | MAPE |
|---|---|---|---|
| VAE | |||
| CTGAN | |||
| EHRDiff | |||
| TabDiff | |||
| IGE-PMVAE | |||
| IGE-VAEAC |
| Metric | IGE-CSDI | IGE-FGTI | IGE-MTSCI |
|---|---|---|---|
| KS Statistic | |||
| TV Distance | |||
| Detection Score | |||
| Detection Accuracy | |||
| DPCM | |||
| DCSM |
| Method | MAMD | RMSPE | MAPE |
|---|---|---|---|
| VAE | |||
| EHRDiff | |||
| TabDiff | |||
| IGE-PMVAE | |||
| IGE-VAEAC | |||
| IGE-TabDDPM |
| Method | MSE | NLL |
|---|---|---|
| VAE | 1.4482 0.0072 | 4.6786 0.0023 |
| EHRDiff | 1.4143 0.0064 | 0.7072 0.0032 |
| TabDiff | 1.2859 0.0063 | 0.6429 0.0032 |
| IGE-PMVAE | 0.4227 0.0054 | 0.8118 0.0051 |
| IGE-VAEAC | 0.2918 0.0050 | 1.2065 0.0045 |
| IGE-TabDDPM | 0.8960 0.0075 | 0.9223 0.0042 |
| Method | MSE | NLL |
|---|---|---|
| IGE-CSDI | ||
| IGE-FGTI | ||
| IGE-MTSCI |
| Method | pH MAE | Base Excess MAE | SpO 2 MAE |
|---|---|---|---|
| VAE | 0.0934 | 1.2532 | 2.1890 |
| CTGAN | 0.1125 | 4.0484 | 3.1240 |
| EHRDiff | 0.0949 | 1.5325 | 2.6732 |
| TabDiff | 0.0928 | 1.4892 | 2.3519 |
| IGE -PMVAE | 0.1069 | 1.6659 | 2.4445 |
| IGE -VAEAC | 0.1026 | 1.6991 | 3.1950 |
| Conditioned Variable | pH MAE | Base Excess MAE | SpO 2 MAE |
|---|---|---|---|
| IGE -PMVAE (pH) | 0 | 1.6423 | 2.2905 |
| IGE -PMVAE (Base Excess) | 0.1002 | 0 | 2.3124 |
| IGE -PMVAE (SpO 2 ) | 0.0946 | 1.5431 | 0 |
| IGE -VAEAC (pH) | 0 | 0.9386 | 3.6624 |
| IGE -VAEAC (Base Excess) | 0.0989 | 0 | 3.7803 |
| IGE -VAEAC (SpO 2 ) | 0.0967 | 0.9563 | 0 |
| Evaluation item | Score | Exact pairwise agreement | Pairwise difference |
|---|---|---|---|
| Q1 Clinical plausibility | 51.7% | 91.7% | |
| Q2 Internal physiological consistency | 43.3% | 86.7% | |
| Q3 Requested-scenario representation | 53.3% | 93.3% | |
| Q4 Physiological possibility | 38.3% | 93.3% | |
| Q5 Agreement with the requested scenario | 46.7% | 91.7% |
| Training data | AUROC | AUPRC | Accuracy | Precision | Recall | F1 |
|---|---|---|---|---|---|---|
| IGE-PMVAE | ||||||
| IGE-TabDDPM | ||||||
| IGE-VAEAC | ||||||
| IGE-CSDI | ||||||
| IGE-FGTI | ||||||
| IGE-MTSCI |
Appendix figures & tables18 assets
Supplementary material from the paper’s appendix.
Appendix
| Hyperparameter | Setting |
|---|---|
| Encoder | MLP, |
| Decoder | Symmetric MLP decoder |
| Latent dimension | 32 |
| Optimizer | Adam |
| Learning rate | |
| Weight decay |
| Hyperparameter | Setting |
|---|---|
| Embedding dimension | 128 |
| Generator dimensions | |
| Discriminator dimensions | |
| PAC size | 10 |
| Optimizer | Adam, , |
| Learning rate | for generator and discriminator |
| Hyperparameter | Setting |
|---|---|
| Denoiser | MLP, four hidden layers of width 256 |
| Time embedding | 128 |
| Optimizer | AdamW |
| Learning rate | |
| Weight decay | 0 |
| Batch size | 256 |
| Hyperparameter | Setting |
|---|---|
| Denoiser | UniModMLP with two encoder and decoder layers |
| Optimizer | AdamW |
| Learning rate | |
| Weight decay | 0 |
| Batch size | 4,096 |
| Training length | 8,000 optimization steps |
| Hyperparameter | Setting |
|---|---|
| VAE backbone | VAE architecture in Table XI |
| Partial encoder | |
| Latent dimension | 32 |
| Optimizer | Adam |
| VAE learning rate | |
| VAE weight decay |
| Hyperparameter | Setting |
|---|---|
| Network width | 256 |
| Network depth | 10 |
| Latent dimension | 64 |
| Optimizer | Adam |
| Learning rate | |
| Weight decay | 0 |
| Hyperparameter | Setting |
|---|---|
| Denoiser | MLP, hidden dimensions |
| Time embedding | 128 |
| Optimizer | AdamW |
| Learning rate | |
| Weight decay | 0 |
| Batch size | 4,096 |
| Hyperparameter | Setting |
|---|---|
| Residual layers | 4 |
| Channels | 64 |
| Attention heads | 8 |
| Time embedding | 128 |
| Feature embedding | 16 |
| Optimizer | Adam |
| Hyperparameter | Setting |
|---|---|
| Residual layers | 4 |
| Channels | 128 |
| Frequency-encoder layers | 4 |
| Attention heads | 8 |
| Time embedding | 128 |
| Feature embedding | 16 |
| Hyperparameter | Setting |
|---|---|
| Residual layers | 4 |
| Channels | 64 |
| Attention heads | 8 |
| Time embedding | 128 |
| Feature embedding | 16 |
| Optimizer | Adam |
| Variable | Unit | Variable | Unit |
|---|---|---|---|
| Alanine Aminotransferase (ALT) | U/L | Mean Arterial Pressure (Arterial Line) | mmHg |
| Ammonia | mol/L | Methemoglobin | % |
| Aspartate Aminotransferase (AST) | U/L | O 2 Flow Rate | L/min |
| Base Excess | mmol/L | Partial Pressure of Carbon Dioxide (PaCO 2 ) | mmHg |
| Total Bilirubin | mg/dL | Partial Pressure of Oxygen (PaO 2 ) | mmHg |
| Bicarbonate (HCO ) | mmol/L | Procalcitonin | ng/mL |
| Prompt | Model | Parse | Schema | Slot | Spurious | Ambig. |
|---|---|---|---|---|---|---|
| (%) | (%) | F1 | (%) | (%) | ||
| Direct Zero-Shot | Gemma3 4B | 100 | 100 | 0.74 | 5.2 | 0.0 |
| MedGemma 4B | 100 | 96.7 | 0.60 | 10.3 | 0.0 | |
| MedAlpaca 7B | 85.0 | 47.5 | 0.23 | 17.3 | 0.0 | |
| Mistral 7B | 91.7 | 0.0 | 0.00 | 0.0 | 0.0 | |
| Qwen3 4B | 100 | 100 | 0.77 | 13.5 | 5.0 |
| Method | MSE | NLL |
|---|---|---|
| VAE | 1.4482 | 4.6786 |
| EHRDiff | 1.5661 | 0.7830 |
| TabDiff | 1.4331 | 0.7166 |
| IGE -PMVAE | 0.4566 | 0.7651 |
| IGE -VAEAC | 0.3058 | 1.2141 |
| IGE -TabDDPM | 0.8091 | 0.8330 |
| Classifier | Training data | AUROC | AUPRC | Accuracy | Precision | Recall | F1 |
|---|---|---|---|---|---|---|---|
| LR | Real | ||||||
| LR | IGE -PMVAE | ||||||
| LR | IGE -VAEAC | ||||||
| LR | IGE -TabDDPM | ||||||
| LR | EHRDiff | ||||||
| LR | TabDiff |
| Item | Evaluation question | Response |
|---|---|---|
| Q1 | Does this trajectory represent a clinically plausible VV-ECMO patient? | 1 (completely implausible) to 5 (completely plausible) |
| Q2 | Are the physiological trends internally consistent? | 1 (completely inconsistent) to 5 (completely consistent) |
| Q3 | Would you consider this trajectory representative of the requested scenario? | 1 (completely unrepresentative) to 5 (completely representative) |
| Q4 | All values appear physiologically possible? | 1 (completely impossible) to 5 (completely possible) |
| Q5 | How well does the generated trajectory match this requested scenario? | 1 (does not match at all) to 5 (perfectly matches) |
| ID | Scenario | Clinician request |
|---|---|---|
| 1 | Severe ARDS | Generate a 48-hour synthetic ICU trajectory for an adult with severe ARDS on VV-ECMO. Include ventilation, ECMO support, oxygenation, hemodynamics, blood gases, and routine labs. Maintain physiologic consistency; use realistic intermittent lab timing and compatible arterial-line and cuff-pressure measurements. |
| 2 | Refractory hypoxemic respiratory failure | Generate a 72-hour synthetic ICU trajectory for an adult on VV-ECMO with refractory hypoxemic respiratory failure. Include ECMO, ventilation, hemodynamics, blood gases, and routine labs. Model a clinically coherent course without forcing simple linear trends or incompatible measurements. |
| 3 | Respiratory acidosis | Generate a 24-hour synthetic ICU trajectory for an adult on VV-ECMO with respiratory acidosis. Include ECMO and ventilator management, blood gases, hemodynamics, and relevant labs. Ensure plausible relationships among variables, intermittent lab collection, and physiologically possible values. |
| 4 | Metabolic acidosis | Generate a 72-hour synthetic ICU trajectory for an adult on VV-ECMO with metabolic acidosis during critical illness. Include hemodynamics, blood gases, ECMO and ventilator support, and relevant labs. Avoid impossible values and unexplained shifts between severe dysfunction and normal results. |
| 5 | Recovery and possible ECMO removal | Generate a 72-hour synthetic ICU trajectory for an adult on VV-ECMO being evaluated for recovery and possible liberation from ECMO. Include ventilation, ECMO settings, oxygenation, hemodynamics, and routine labs. Model a nuanced, physiologically plausible course without assuming uniform improvement. |
| 6 | Suspected hemolysis | Generate a 72-hour synthetic ICU trajectory for an adult on VV-ECMO with suspected hemolysis. Include ECMO and ventilator support, respiratory and hemodynamic monitoring, blood gases, and relevant hematologic and chemistry labs. Create a plausible pattern without forcing linear laboratory trends. |
| ID | Parsed scenario name | Parsed conditioning description |
|---|---|---|
| 1 | Gradual ECMO-assisted oxygenation | SaO 2 : over 0–48 h. |
| 2 | Refractory hypoxemia with ECMO | SaO 2 : over 0–96 h; arterial-line MAP 50–80 mmHg and cuff MAP 40–70 mmHg over 0–24 h; pulse 120 bpm; end-tidal CO 2 40–60 mmHg. |
| 3 | Worsening respiratory acidosis | PaCO 2 : mmHg and pH: over 0–24 h. |
| 4 | Progressive metabolic acidosis with stable oxygenation | Base excess: mmol/L and lactic acid: mmol/L over 0–96 h. Both are labeled as increasing in the saved JSON. |
| 5 | ECMO recovery and weaning | SaO 2 : over 0–72 h; arterial-line MAP 25–40 mmHg over 0–24 h; cuff MAP 25–40 mmHg over 24–48 h; O 2 flow: L/min over 24–72 h; arterial-line MAP: mmHg over 72–96 h. |
| ID | Parsed scenario name | Parsed conditioning description |
|---|---|---|
| 6 | Hemolysis with increasing lactate dehydrogenase and decreasing hemoglobin | Lactate dehydrogenase: U/L and hemoglobin: g/dL over 0–96 h. |
| 7 | ECMO deterioration | O 2 flow: L/min, arterial-line MAP 40–80 mmHg, and unassisted respiratory rate 10–30 breaths/min over 0–12 h. |
| 8 | ECMO improvement over 48 hours | End-tidal CO 2 : mmHg over 0–48 h, labeled as increasing in the saved JSON; arterial-line MAP 40–60 mmHg over 0–48 h; O 2 flow: L/min over 0–48 h. |
| 9 | ECMO support for acute kidney injury | Creatinine: mg/dL over 0–96 h; base excess to mmol/L; HCO 10–25 mmol/L; SaO 2 fixed at over 0–24 h. |
| 10 | ECMO-related complications | Platelet count: L over 0–96 h. |
Synthetic Data Generation
Synthetic data generation creates artificial examples, simulations, and datasets to train, test, or protect machine-learning systems.
See all 667 papers