Toward a digital twin of the ICU patient: Forecasting and treatment response in a generative event model

arXiv cs.LG Papers

Summary

论文提出 TWICE,一个在 ICU 电子健康记录上训练的 79M 参数生成事件模型,用于模拟患者未来并评估治疗反应,在 19 项临床预测任务上无任务特定训练即达到与 144 个监督模型配置相当的性能(AUROC 0.836 vs 0.834),被视为迈向 ICU 患者数字孪生的一步。

arXiv:2611.27028v1 Announce Type: new Abstract: A digital twin of a patient in intensive care would forecast the patient's course and what a treatment would change. Generative event models, trained to continue a patient's electronic health record (EHR), have been proposed as a path toward such twins. We trained TWICE, a 79M-parameter decoder-only transformer, on the ICU records of one academic health system (127,332 training patients and 1.57 billion tokens). We evaluated it on clinical prediction tasks, generation fidelity, individual trajectories and counterfactual validation. Reading 19 clinical outcomes off 50 simulated futures, with no task-specific training, TWICE matched the best of 144 supervised configurations on held-out patients (mean AUROC 0.836 vs. 0.834). It led on events that change care within a day and trailed on death. With the training data fixed, more and longer simulated futures were worth more than a 6.8-fold larger model. Its generated records matched real ones closely and were as specific to each patient as its own variability allowed. Its predicted risk rose as events approached. Pre-specified controls showed that it reproduced the side effects of drugs and was barely moved by an inert drug. On the values that treatments are given to correct, however, an opposite treatment moved its forecasts like the right one. TWICE forecasts ICU events about as well as task-specific models, and we see it as a step toward a digital twin of the ICU patient.
Original Article
View Cached Full Text

Cached at: 11/23/26, 09:23 AM

# Toward a digital twin of the ICU patient: Forecasting and treatment response in a generative event model
Source: [https://arxiv.org/html/2611.27028](https://arxiv.org/html/2611.27028)
Zhuoyang LyuAffiliation:Department of Biomedical Informatics, Harvard Medical School, Boston, MA, USA Affiliation:Division of General Internal Medicine and Primary Care, Department of Medicine, Brigham and Women’s Hospital, Boston, MA, USAYiming LiAffiliation:Division of General Internal Medicine and Primary Care, Department of Medicine, Brigham and Women’s Hospital, Boston, MA, USAAffiliation:Department of Medicine, Harvard Medical School, Boston, MA, USAPeter C\. HouAffiliation:Division of Emergency Critical Care Medicine, Department of Emergency Medicine, Brigham and Women’s Hospital, Boston, MA, USAAffiliation:Department of Emergency Medicine, Harvard Medical School, Boston, MA, USAPengyu HongAffiliation:Department of Computer Science, Brandeis University, Waltham, MA, USA \*Corresponding authors:zhuoyang\_lyu@hms\.harvard\.edu,lzhou@bwh\.harvard\.eduLi ZhouAffiliation:Department of Biomedical Informatics, Harvard Medical School, Boston, MA, USA Affiliation:Division of General Internal Medicine and Primary Care, Department of Medicine, Brigham and Women’s Hospital, Boston, MA, USAAffiliation:Department of Medicine, Harvard Medical School, Boston, MA, USA

###### Abstract

A digital twin of a patient in intensive care would forecast the patient’s course and what a treatment would change\. Generative event models, trained to continue a patient’s electronic health record \(EHR\), have been proposed as a path toward such twins\. We trained TWICE, a 79M\-parameter decoder\-only transformer, on the ICU records of one academic health system \(127,332 training patients and 1\.57 billion tokens\)\. We evaluated it on clinical prediction tasks, generation fidelity, individual trajectories and counterfactual validation\. Reading 19 clinical outcomes off 50 simulated futures, with no task\-specific training, TWICE matched the best of 144 supervised configurations on held\-out patients \(mean AUROC 0\.836 vs\. 0\.834\)\. It led on events that change care within a day and trailed on death\. With the training data fixed, more and longer simulated futures were worth more than a 6\.8\-fold larger model\. Its generated records matched real ones closely and were as specific to each patient as its own variability allowed\. Its predicted risk rose as events approached\. Pre\-specified controls showed that it reproduced the side effects of drugs and was barely moved by an inert drug\. On the values that treatments are given to correct, however, an opposite treatment moved its forecasts like the right one\. TWICE forecasts ICU events about as well as task\-specific models, and we see it as a step toward a digital twin of the ICU patient\.

## 1Introduction

A digital twin is a virtual model, kept up to date with data from a real system, that predicts the system’s behaviour and informs decisions about it\[[66](https://arxiv.org/html/2611.27028#bib.bib66)\]\. In medicine, the system is a patient and the decisions concern their care\. In the intensive care unit \(ICU\), the electronic health record \(EHR\) documents this care as a time\-stamped sequence of observations and interventions, such as vital signs, laboratory results, drug orders and ventilator settings\. Generative event models trained directly on such sequences learn to predict each event from those before it, and their predictions for a patient can be updated with every new entry in the EHR\[[75](https://arxiv.org/html/2611.27028#bib.bib75),[93](https://arxiv.org/html/2611.27028#bib.bib93),[80](https://arxiv.org/html/2611.27028#bib.bib80)\]\. Prior work has used such models to sample many possible futures for a patient and estimate the risk of an outcome from how often it occurs among them\[[75](https://arxiv.org/html/2611.27028#bib.bib75),[76](https://arxiv.org/html/2611.27028#bib.bib76),[93](https://arxiv.org/html/2611.27028#bib.bib93)\]\. These zero\-shot estimates were competitive with supervised models\[[76](https://arxiv.org/html/2611.27028#bib.bib76),[93](https://arxiv.org/html/2611.27028#bib.bib93)\]\. Recent work has written a treatment into the record before sampling to simulate what it would change\[[71](https://arxiv.org/html/2611.27028#bib.bib71),[56](https://arxiv.org/html/2611.27028#bib.bib56),[78](https://arxiv.org/html/2611.27028#bib.bib78)\]\. Generative models of patient trajectories have been proposed as a path toward digital twins\[[57](https://arxiv.org/html/2611.27028#bib.bib57),[71](https://arxiv.org/html/2611.27028#bib.bib71),[56](https://arxiv.org/html/2611.27028#bib.bib56)\]\.

Two gaps remain between these models and a twin at the ICU bedside\. First, care in the ICU responds to events that unfold over hours, such as a fall in blood pressure, a rise in oxygen need, or the start or end of ventilation\. Such events have been predicted by supervised models\[[30](https://arxiv.org/html/2611.27028#bib.bib30),[100](https://arxiv.org/html/2611.27028#bib.bib100),[88](https://arxiv.org/html/2611.27028#bib.bib88)\], by probes of generative event models\[[51](https://arxiv.org/html/2611.27028#bib.bib51),[14](https://arxiv.org/html/2611.27028#bib.bib14)\]and by ICU forecasters\[[57](https://arxiv.org/html/2611.27028#bib.bib57),[13](https://arxiv.org/html/2611.27028#bib.bib13)\]\. Whether simulated futures forecast them as well as supervised models do has been less studied\. Second, whether they respond correctly when a treatment is written into the record has rarely been tested against controls\. Without controls, a model can appear to respond correctly because it has learned which patients receive a treatment rather than what the treatment does\.

We trained TWICE, a 79M\-parameter decoder, on the ICU records of one academic health system \(127,332 training patients and 1\.57 billion training tokens\), and evaluated it in four ways\. The first two come from prior work on generative event models\. Zero\-shot clinical prediction\[[75](https://arxiv.org/html/2611.27028#bib.bib75),[69](https://arxiv.org/html/2611.27028#bib.bib69),[93](https://arxiv.org/html/2611.27028#bib.bib93)\]is scored on 19 ICU tasks at 24 h into a stay\. Most of these tasks predict an event within the next day\. Generation fidelity\[[93](https://arxiv.org/html/2611.27028#bib.bib93),[69](https://arxiv.org/html/2611.27028#bib.bib69),[80](https://arxiv.org/html/2611.27028#bib.bib80)\]compares generated records with real ones\. The other two reflect how a twin would be used\. Individual trajectories test whether the model follows one patient through a stay\[[76](https://arxiv.org/html/2611.27028#bib.bib76),[80](https://arxiv.org/html/2611.27028#bib.bib80)\]\. Counterfactual validation uses pre\-specified controls to test whether the model responds correctly when a treatment is written into the record\[[71](https://arxiv.org/html/2611.27028#bib.bib71),[56](https://arxiv.org/html/2611.27028#bib.bib56),[78](https://arxiv.org/html/2611.27028#bib.bib78)\]\. We make four contributions\.

- •*Zero\-shot prediction of ICU events\.*With no task\-specific training, TWICE matches the strongest of 144 supervised configurations on 19 ICU tasks on held\-out patients \(mean AUROC 0\.836 for TWICE and 0\.834 for the best supervised configuration\)\. It scores higher on events that change care within a day and lower on death and oxygen weaning \(§[6\.1](https://arxiv.org/html/2611.27028#S6.SS1)\)\.
- •*The readout as a lever\.*In matched ablations with the training data fixed, four to five times more readout compute \(more and longer simulated futures\) improved AUROC more than a 6\.8\-fold larger model\. Futures that stop at the token budget are censored informatively, so the token budget is part of the estimator \(§[6\.2](https://arxiv.org/html/2611.27028#S6.SS2)\)\.
- •*Generation fidelity and individual trajectories\.*Compared at the next token and over the next 24 h, generated records match real ones closely\. A patient’s real future overlaps a generated one about as much as two generated futures overlap each other\. Patients whose event comes sooner receive a higher predicted risk \(§[6\.3](https://arxiv.org/html/2611.27028#S6.SS3), §[6\.4](https://arxiv.org/html/2611.27028#S6.SS4)\)\.
- •*Counterfactual validation with controls\.*Pre\-specified positive, negative and opposite\-drug controls show that TWICE has learned drug side effects\. On a treatment’s target, however, the opposite drug moved the forecast like the right one, as expected if an order is read as a sign of illness \(§[6\.5](https://arxiv.org/html/2611.27028#S6.SS5)\)\. We propose these controls as a general test of counterfactual responses in generative event models\.

## 2Related work

#### Generative event models\.

Foresight extracted medical concepts such as disorders and procedures from clinical notes and placed them on a timeline\. It was trained to predict each patient’s next concept\[[44](https://arxiv.org/html/2611.27028#bib.bib44)\]\. ETHOS turned each MIMIC\-IV patient’s record into a sequence of tokens\. From simulated futures it estimated in\-hospital and ICU death, ICU readmission and ICU length of stay\[[75](https://arxiv.org/html/2611.27028#bib.bib75)\]\. ARES used ETHOS to estimate the risks of hospital admission, ICU admission and a prolonged stay, and to update them as the record grows\[[76](https://arxiv.org/html/2611.27028#bib.bib76)\]\. Delphi\-2M was trained on the records of 0\.4 million UK Biobank participants\. From a person’s past diagnoses it predicts which of more than 1,000 diseases comes next and when\[[80](https://arxiv.org/html/2611.27028#bib.bib80)\]\. CEHR\-XGPT uses one model in three ways\. It provides patient features for downstream classifiers, predicts outcomes zero\-shot and generates synthetic patient records\[[69](https://arxiv.org/html/2611.27028#bib.bib69)\]\. CoMET \(Curiosity\) was trained on 118 million patients from Epic Cosmos, which pools records from 310 health systems\. Its authors fitted scaling laws for compute, data and model size\. More simulated futures improved its estimates, and it generally matched or beat supervised models on 78 tasks\[[93](https://arxiv.org/html/2611.27028#bib.bib93)\]\. A simulator trained on more than 200 million records from one Japanese hospital generated each patient’s next seven days\. The event rates, laboratory values and timing in these futures closely matched those in the patients’ real futures\[[5](https://arxiv.org/html/2611.27028#bib.bib5)\]\. DT\-Transformer adapted Delphi\-2M’s architecture and trained it on 1\.7 million patients at Mass General Brigham, the health system our data come from\. It predicts the next diagnosis across 896 disease categories\[[103](https://arxiv.org/html/2611.27028#bib.bib103)\]\. These models are judged mainly by zero\-shot prediction of clinical outcomes\[[75](https://arxiv.org/html/2611.27028#bib.bib75),[76](https://arxiv.org/html/2611.27028#bib.bib76),[69](https://arxiv.org/html/2611.27028#bib.bib69),[93](https://arxiv.org/html/2611.27028#bib.bib93),[5](https://arxiv.org/html/2611.27028#bib.bib5)\], by next\-event prediction\[[80](https://arxiv.org/html/2611.27028#bib.bib80),[103](https://arxiv.org/html/2611.27028#bib.bib103)\], and by how closely generated records match real ones\. CoMET and the simulator compare how often generated events occur, alone and together, with the patients’ real futures\[[93](https://arxiv.org/html/2611.27028#bib.bib93),[5](https://arxiv.org/html/2611.27028#bib.bib5)\]\. CEHR\-XGPT and Delphi\-2M train models on synthetic records and test them on real ones\[[69](https://arxiv.org/html/2611.27028#bib.bib69),[80](https://arxiv.org/html/2611.27028#bib.bib80)\]\. Representation models such as CLMBR, MOTOR and APOLLO, the last trained on Mass General Brigham records, are probed or fine\-tuned rather than simulated\[[84](https://arxiv.org/html/2611.27028#bib.bib84),[85](https://arxiv.org/html/2611.27028#bib.bib85),[101](https://arxiv.org/html/2611.27028#bib.bib101)\], and EHRSHOT benchmarks them\[[95](https://arxiv.org/html/2611.27028#bib.bib95)\]\. In the ICU, DT\-GPT forecasts laboratory and vital\-sign values with a language model\[[57](https://arxiv.org/html/2611.27028#bib.bib57)\], and ICareFM predicts when physiological thresholds will be crossed\[[13](https://arxiv.org/html/2611.27028#bib.bib13)\]\.

#### ICU prediction and baselines\.

Supervised models have predicted ICU mortality, decompensation, length of stay and organ failure on public ICU databases\[[30](https://arxiv.org/html/2611.27028#bib.bib30),[100](https://arxiv.org/html/2611.27028#bib.bib100)\]\. YAIB ran shared tasks across five such databases and found that the choice of dataset, cohort and preprocessing often affected performance more than the choice of model\[[88](https://arxiv.org/html/2611.27028#bib.bib88)\]\. We therefore compare every model on the same cohort, splits and labels\.[Lee et al\. \[51\]](https://arxiv.org/html/2611.27028#bib.bib51)and[Burkhart et al\. \[14\]](https://arxiv.org/html/2611.27028#bib.bib14)trained generative event models on ICU hospitalizations and fitted probes on the model’s state at 24 h to predict events later in the stay\. Burkhart et al\. predicted 12 such events, including invasive ventilation and vasopressor use, and trained one model across three health systems by federated learning\. On tabular data, a large benchmark found that tree\-based models still outperformed deep learning on datasets of about 10,000 samples\[[28](https://arxiv.org/html/2611.27028#bib.bib28)\]\. MEDS\-Tab summarises MEDS event data over time windows into tables and trains XGBoost on them as a baseline for any MEDS dataset\[[68](https://arxiv.org/html/2611.27028#bib.bib68)\]\. Our strongest supervised baseline is of this kind \(§[5](https://arxiv.org/html/2611.27028#S5)\)\.

#### Scaling, inputs and inference compute\.

[Kaplan et al\. \[40\]](https://arxiv.org/html/2611.27028#bib.bib40)found that the loss of language models falls as a power law in model size, data and compute\.[Hoffmann et al\. \[34\]](https://arxiv.org/html/2611.27028#bib.bib34)found that model size and training data should grow in proportion\. Their Chinchilla model was trained on about 20 tokens per parameter\.[Muennighoff et al\. \[65\]](https://arxiv.org/html/2611.27028#bib.bib65)studied training when unique data run out\. Up to four epochs of repeated data were nearly as good as new data, and further repetition added less and less\.[Xue et al\. \[98\]](https://arxiv.org/html/2611.27028#bib.bib98)found that repeated data lead to overfitting\. Of the regularisers they tested, only dropout clearly reduced it\.[Wornow et al\. \[96\]](https://arxiv.org/html/2611.27028#bib.bib96)studied context length in EHR models\. They trained four architectures with contexts of 512 to 16,384 tokens\. Performance tended to rise with longer context, except for Hyena, and a Mamba model with 16,384 tokens surpassed the previous best on 9 of 14 EHRSHOT tasks\. How numeric values are tokenised is an open question\. In a benchmark of 156 models, pairing each code with its value decile in one token improved probes for all eight outcome families\[[51](https://arxiv.org/html/2611.27028#bib.bib51)\]\. Continuous value tokens shortened the median sequence by a third and kept clinical task performance comparable to binned values\[[59](https://arxiv.org/html/2611.27028#bib.bib59)\]\.[Snell et al\. \[82\]](https://arxiv.org/html/2611.27028#bib.bib82)spent compute at inference rather than on model size\. At the same total compute, a smaller language model outperformed a 14 times larger one on problems it could already sometimes solve\. For generative event models,[McCann et al\. \[59\]](https://arxiv.org/html/2611.27028#bib.bib59)also explained why estimates improve with more simulated futures and derived a scaling law for the gain from a larger simulation budget\. SCOPE and REACH read outcome probabilities from the next\-token distribution instead of counting outcomes in simulated futures\. They matched the accuracy of 100 futures with 2\.5 to 3\.4 times fewer generated tokens\[[83](https://arxiv.org/html/2611.27028#bib.bib83)\]\.

#### Interventions in generative models\.

Writing a treatment into the record and sampling forward from a generative model is a form of Monte Carlo g\-computation\[[77](https://arxiv.org/html/2611.27028#bib.bib77)\]\. Causal sequence models have estimated treatment effects with neural networks\. G\-Net implemented g\-computation with a recurrent network\[[52](https://arxiv.org/html/2611.27028#bib.bib52)\], and the Causal Transformer predicts outcomes under a planned course of treatment\[[62](https://arxiv.org/html/2611.27028#bib.bib62)\]\. Generative event models have done the same\. EHR\-MPC planned sepsis treatment by model predictive control\[[71](https://arxiv.org/html/2611.27028#bib.bib71)\]\. HealthFormer compared simulated treatment effects outside the ICU with 41 published trial results\[[56](https://arxiv.org/html/2611.27028#bib.bib56)\]\. FlatASCEND inserted drugs into MIMIC\-IV timelines and found most drug effects in the expected direction, though a null control failed\[[78](https://arxiv.org/html/2611.27028#bib.bib78)\]\. Estimates of this kind assume that the record captures why each treatment was given\. When it does not, a treatment can read as a sign of the illness it was given for\. A vasopressor, for example, is started when blood pressure is low and not recovering\. A model trained on such records may then predict lower blood pressure after a vasopressor is written in\. This bias is known as confounding by indication\[[49](https://arxiv.org/html/2611.27028#bib.bib49)\]\. Negative controls can detect it\[[53](https://arxiv.org/html/2611.27028#bib.bib53)\]\. Target trial emulation designs an observational analysis to mirror a randomised trial\[[32](https://arxiv.org/html/2611.27028#bib.bib32)\], and when that trial has been run its result gives a second check\. We apply both checks to an ICU model with pre\-specified controls\. They include side effects, an inert drug, opposite drugs and two trial emulations, one of a null trial\.

## 3Data, prediction contract and tasks

#### Cohort\.

We used the Epic electronic health record of Mass General Brigham \(MGB\), an academic health system in Massachusetts\. The cohort is every ICU stay of an adult \(aged 18 or older, rounded to the year, at the start of the stay\) that began between 2017 and 2025: 141,556 patients, 185,244 hospital encounters and 236,906 ICU stays \(Table[1](https://arxiv.org/html/2611.27028#S3.T1)\)\. For each encounter we took bedside flowsheet measurements \(vital signs, ventilator settings, organ\-support markers\), laboratory results, medication orders, procedure, imaging and echocardiography orders, and note types \(no text\), from 24 h before the first ICU admission to 24 h after the last ICU discharge, together with the times of hospital admission and discharge, ICU admission and discharge, and death\. Encounter diagnoses \(ICD\-10\) are placed at the discharge time, so they cannot be read before the encounter ends; problem\-list diagnoses documented before admission form a history block\. Converted to the Medical Event Data Standard \(MEDS\)\[[9](https://arxiv.org/html/2611.27028#bib.bib9),[60](https://arxiv.org/html/2611.27028#bib.bib60)\], the record holds 958,956,444 time\-stamped events\. Patients are split at random 90/5/5 into training, validation and test sets, so all of a patient’s encounters fall in one set\.

#### Prediction contract\.

All methods are scored on the same patients at the same prediction time, 24 h after ICU admission\. Of the 236,906 ICU stays, 178,506 \(75\.3%\) are still in the ICU at that time\. Stays that end earlier are not scored, so the results describe patients who remain in the ICU for a day\. Inputs hold only events recorded at or before the prediction time\. Validation has 8,947 scored stays from 5,836 patients and test 8,995 from 5,794 patients\. A stay is not scored for a task when the patient is not eligible \(for example, already ventilated, for new ventilation\) or when the measurement the label reads was not taken\. If the patient leaves the setting where the event would be recorded before the window closes \(the ICU for bedside measurements, the hospital for orders\), the label is negative \(App\.[B](https://arxiv.org/html/2611.27028#A2)\)\.

#### Tasks\.

We report 19 binary tasks in five groups \(Table[4](https://arxiv.org/html/2611.27028#A2.T4)\)\. Each task is a rule over structured events\. Seven tasks are respiratory\. They are severe hypoxaemia by PaO2/FiO2and by SpO2/FiO2, moderate hypoxaemia, FiO2escalation and weaning, new invasive ventilation and ventilator liberation\. The one haemodynamic task is hypotension\. Six tasks are metabolic and renal\. They are two levels each of acidaemia and hyperlactataemia, acute kidney injury and new continuous renal replacement therapy \(CRRT\)\. Four tasks are outcomes\. They are ICU and in\-hospital mortality, ICU discharge\[[30](https://arxiv.org/html/2611.27028#bib.bib30)\]and death among patients on vasopressors\. The fifth group is the care process\. Its one task is an imaging or echocardiography order\. This makes the care process itself a target\[[3](https://arxiv.org/html/2611.27028#bib.bib3)\]\. Thresholds follow published definitions where they exist\[[8](https://arxiv.org/html/2611.27028#bib.bib8),[58](https://arxiv.org/html/2611.27028#bib.bib58),[12](https://arxiv.org/html/2611.27028#bib.bib12),[25](https://arxiv.org/html/2611.27028#bib.bib25),[1](https://arxiv.org/html/2611.27028#bib.bib1),[81](https://arxiv.org/html/2611.27028#bib.bib81),[42](https://arxiv.org/html/2611.27028#bib.bib42)\]\. Most horizons are 24 h\. Table[4](https://arxiv.org/html/2611.27028#A2.T4)gives each task’s threshold, horizon and eligibility rule\. Two rules chose these tasks from a larger registry before the test set was scored\. A task needs at least 50 positive rows in validation\. Its label must also be computable from structured data for every stay \(App\.[B](https://arxiv.org/html/2611.27028#A2)\)\. The same 19 tasks are used on validation and test\. Predicting which discharge diagnosis groups \(HCUP CCSR\[[31](https://arxiv.org/html/2611.27028#bib.bib31)\]\) a stay will be recorded with is a separate family \(§[6\.1](https://arxiv.org/html/2611.27028#S6.SS1), App\.[I](https://arxiv.org/html/2611.27028#A9)\)\. Each group collects related ICD\-10 codes into one clinical category, such as heart failure or pneumonia\.

Table 1:Cohort by split\. App\.[A](https://arxiv.org/html/2611.27028#A1)adds race, ethnicity and the outcomes of the scored stays\.aOne ICU unit admission in the record, so a transfer between ICUs starts a new stay\.bMedian \[interquartile range\]\.cRead from ventilator\-setting markers \(App\.[B](https://arxiv.org/html/2611.27028#A2)\)\.

## 4Method

![Refer to caption](https://arxiv.org/html/2611.27028v1/x1.png)Figure 1:Overview of TWICE\.\(a\)Training\. The events of an ICU encounter are represented by one token sequence \(§[4\.1](https://arxiv.org/html/2611.27028#S4.SS1)\)\. The transformer is trained to predict each next token \(§[4\.2](https://arxiv.org/html/2611.27028#S4.SS2)\)\.\(b\)Prediction\. At the prediction timett, TWICE samples 50 futures from the encounter up tott\(§[4\.3](https://arxiv.org/html/2611.27028#S4.SS3)\)\. The predicted probability of a task is the fraction of decided futures in which its event occurs\. For a what\-if, an order is written into the encounter before sampling \(§[4\.4](https://arxiv.org/html/2611.27028#S4.SS4)\)\. Token names are shortened for display\.### 4\.1Tokenization

We represent each hospital encounter as one token sequence \(Fig\.[1](https://arxiv.org/html/2611.27028#S4.F1)a and App\.[C](https://arxiv.org/html/2611.27028#A3)\)\. The sequence begins with a static block \(sex, race, ethnicity, age in 5\-year bands and admission year\)\. It continues with the diagnoses on the patient’s problem list from before the admission, and then with the events of the encounter in time order\. The sequence ends at discharge\.

- •*Codes\.*Bedside, laboratory, medication, procedure and diagnosis events are each represented by a token for their code\. We map a code recorded for fewer than 0\.5% of training patients to the token of its broader parent code, which is the LOINC analyte for a laboratory test and the three\-character ICD\-10 category for a diagnosis\. A rare code without a parent, or whose parent is also rare, is mapped to a single “other” token for its family, which pools all such codes\. Bedside physiology, ventilator, organ\-support, admission and discharge codes are exempt from this rule\. Diagnoses and medications are represented hierarchically so that related codes share tokens\[[93](https://arxiv.org/html/2611.27028#bib.bib93)\]\. An ICD\-10 code is split into up to three tokens \(characters 1–3, 4–5 and 6–7\)\. A medication is split in the same way into up to three tokens from its Anatomical Therapeutic Chemical \(ATC\) code\[[94](https://arxiv.org/html/2611.27028#bib.bib94)\]\.
- •*Values\.*Each numeric result is represented by a token for its code followed by a token for the decile of its value\[[75](https://arxiv.org/html/2611.27028#bib.bib75),[93](https://arxiv.org/html/2611.27028#bib.bib93)\]\. We fit the deciles for each code and unit on the training split only\. All codes share the same ten decile tokens\. The “other” token records presence only and has no decile token\.
- •*Time\.*We insert time\-interval tokens\[[75](https://arxiv.org/html/2611.27028#bib.bib75)\]between consecutive events that are at least one minute apart\. Each token is selected from seven intervals \(1–5, 5–15, 15–30 and 30–60 min, and 1–4, 4–12 and≥\\geq12 h\)\. A longer gap is represented by up to eight repeated≥\\geq12 h tokens\. The intervals are spaced for the ICU, where most gaps are minutes long\.
- •*Order within one minute\.*Events stamped with the same minute are placed in a fixed clinical order\. Admission and transfer events, which record where the patient is, come first\. Observations follow\. These are bedside measurements, such as heart rate or a ventilator setting, and laboratory results\. Values computed from the observations, such as the oxygenation bands below, come after them\. Treatments \(medication orders and procedures\) come next, then documentation \(imaging, echocardiography and clinical notes\) and diagnoses\. Leaving events \(ICU discharge, death and hospital discharge\) come last\. A computed value never precedes its evidence, and a treatment follows the physiology charted with it\.
- •*Oxygenation bands\.*PaO2/FiO2and SpO2/FiO2are ratios of two measurements taken at different times, so no single value token can represent them\. Wherever a ratio can be computed, we add a token for its band\. The PaO2/FiO2bands are the Berlin bands \(≥\\geq300, 200–300, 100–200 and<<100\)\[[8](https://arxiv.org/html/2611.27028#bib.bib8)\]\. SpO2/FiO2has two bands, above and below 148\[[58](https://arxiv.org/html/2611.27028#bib.bib58)\]\.

The vocabulary contains 4,986 tokens\. The training split yields 166,745 encounter sequences with 1\.65 billion tokens\. To select the checkpoint, we hold out 5% of the training encounters at random \(8,337 sequences and 82\.8 million tokens\)\. This hold\-out is separate from the validation set\. The remaining 158,408 sequences and 1\.57 billion tokens are used for training\.

### 4\.2Model and training

TWICE is a decoder\-only transformer with RMSNorm pre\-normalisation\[[102](https://arxiv.org/html/2611.27028#bib.bib102)\], SwiGLU feed\-forward layers\[[79](https://arxiv.org/html/2611.27028#bib.bib79)\], rotary position embeddings\[[87](https://arxiv.org/html/2611.27028#bib.bib87)\]and grouped\-query attention\[[4](https://arxiv.org/html/2611.27028#bib.bib4)\]\. The input and output embeddings are tied\[[73](https://arxiv.org/html/2611.27028#bib.bib73)\]\. The position embeddings encode only where a token sits in the sequence, not when the event happened\. The model learns how much time has passed from the time\-interval tokens alone\. The model has 12 layers of width 768 and 79\.3 million parameters, and it uses a context window of 2,048 tokens\. It is trained by next\-token cross\-entropy on 2,048\-token windows that start at a uniformly random token of the concatenated training sequences, so every training token is equally likely to be seen\[[75](https://arxiv.org/html/2611.27028#bib.bib75)\]\. Table[5](https://arxiv.org/html/2611.27028#A4.T5)lists the optimiser and the other training settings\. Training stopped when the held\-out cross\-entropy had not improved for 20 evaluations, at step 435,000 \(57\.0 billion tokens, or 36\.4 passes over the training tokens\)\. We evaluate the best checkpoint, at step 415,000, which reaches 0\.630 nats per token compared with 2\.98 for a bigram model\. Training took about 32 h on one NVIDIA H200 GPU\. The model size, the context length and the readout settings below were chosen on validation \(§[6\.2](https://arxiv.org/html/2611.27028#S6.SS2)\)\. No validation or test patient is seen in training\.

### 4\.3Reading clinical predictions off simulated futures

To make a prediction for a patient at the prediction timett, we prompt TWICE with the last 2,048 tokens of the encounter up tott\. We then sampleN=50N=50futures at temperature 1 from the full next\-token distribution\. Each generated time\-interval token advances a future’s clock by the geometric midpoint of its interval\[[93](https://arxiv.org/html/2611.27028#bib.bib93)\]\. The open\-ended≥\\geq12 h interval advances it by12⋅24≈17\\sqrt\{12\\cdot 24\}\\approx 17h\. A future stops at hospital discharge or death, after 8,192 generated tokens \(the budget\), or when its clock passes 30 days\[[75](https://arxiv.org/html/2611.27028#bib.bib75)\]\. For a task with horizonhh, we call a future*decided*when its outcome withinhhis known\. It is positive if the event occurs withinhh\. It is negative if the future reacheshhor the end of the stay without the event\. A future that hits the budget or the 30\-day limit before either outcome is*undecided*for that task \(right\-censored\)\. A future can decide a 24 h task long before it stops\. It decides in\-hospital mortality only when it stops at discharge or death\. The predicted probability is the fraction of decided futures in which the event occurs\[[93](https://arxiv.org/html/2611.27028#bib.bib93), eq\. 2\],

p^=\#​\{futures with the event within​h\}\#​\{decided futures\}\.\\hat\{p\}=\\frac\{\\\#\\\{\\text\{futures with the event within \}h\\\}\}\{\\\#\\\{\\text\{decided futures\}\\\}\}\.\(1\)If no future is decided, Eq\. \([1](https://arxiv.org/html/2611.27028#S4.E1)\) has nothing to count, and the futures give no evidence on whether the event occurs\. We therefore predict the fraction of training stays in which the event occurred, which uses no information about the patient\. Every scored stay thus receives a prediction\. Events are identified by exact token matches\. Ventilation is identified by its ventilator\-setting tokens, and an oxygenation threshold by the band tokens\. A threshold on one analyte \(for example lactate≥\\geq2 mmol/L\) is identified by the analyte’s code token followed by a decile token\. The label for such a task exists only where the analyte was measured, so the readout likewise counts only the futures in which the analyte is measured within the window\. When the threshold falls inside a decile, the token for that decile does not show whether the value is above or below the threshold\. We therefore computep^\\hat\{p\}twice\. The first count uses only the deciles wholly beyond the threshold, and the second also includes the decile that contains it\. We report the midpoint of the two\. A rise or fall is judged against the patient’s own value beforett\. The same 50 futures are used for every task\. During sampling, we cache the keys and values of only the last 2,048 tokens\. Generation therefore uses sliding\-window attention, whereas the model was trained with full attention within each window\. App\.[E](https://arxiv.org/html/2611.27028#A5)measures what this changes\.

### 4\.4Writing an intervention into the record

To ask “what if”, we compare treatment arms with a control arm at a decision timett, as in a clinical trial\. Treatments are compared within a clinical scenario, such as a high potassium\. In six of our seven scenarios the treatments are drugs\. In one they are ventilator settings \(§[5](https://arxiv.org/html/2611.27028#S5)\)\. The arms differ only in what is ordered\. When the treatments are drugs, the control arm forbids all of them for the whole future\. Whenever the model samples one of them, the event is discarded and redrawn from the same step’s distribution, renormalised over the allowed events\. For a ventilator change, the control arm is usual care\. Nothing is inserted or forbidden, and the model may change the ventilator settings as it predicts\. The order is placed att\+dt\+d, whereddis the median delay from the decision time to the order in the training data\. Until then, every arm is sampled as the control arm\. Att\+dt\+dwe insert a time\-interval token and the order’s own token sequence and continue sampling\. All arms share the prompt and the random seeds, so the tokens before the order are identical across arms and every contrast is paired\. After the order, nothing is forbidden and care continues as the model predicts, so an arm estimates “orderaanow, then usual care”\. This is Monte Carlo g\-computation\[[77](https://arxiv.org/html/2611.27028#bib.bib77)\]\. Its contrasts are causal only if the history holds what drove the order \(no unmeasured confounding\) and similar patients received each arm \(positivity\)\[[33](https://arxiv.org/html/2611.27028#bib.bib33)\]\. §[6\.5](https://arxiv.org/html/2611.27028#S6.SS5)tests these assumptions with controls rather than granting them\.

## 5Evaluation design

#### Protocol and statistics\.

A single generative model, selected on validation, was evaluated once on the test split, as were the supervised baselines\. The clinical prediction tasks are scored on the test split\. Generation fidelity, individual trajectories and counterfactual validation are scored on validation\. Ablations are reported on validation and labelled as such\. For the clinical prediction tasks, we compare TWICE with the strongest supervised baseline\. This is the best of 144 supervised configurations of tabular and sequence models trained on the task labels, selected by mean validation AUROC over the 19 tasks\. It is LightGBM\[[41](https://arxiv.org/html/2611.27028#bib.bib41)\]on summaries of all events charted in the previous 24 h \(App\.[F](https://arxiv.org/html/2611.27028#A6)\)\. We report 95% percentile confidence intervals from 1,000 bootstrap replicates\. Each replicate resamples patients rather than stays, to account for patients with several stays\[[23](https://arxiv.org/html/2611.27028#bib.bib23),[26](https://arxiv.org/html/2611.27028#bib.bib26)\]\. A mean over tasks uses the same resampled patients for every task\. Two\-sidedpp\-values are computed from the bootstrap distribution of the paired difference and adjusted across the 19 tasks with Holm’s method\[[35](https://arxiv.org/html/2611.27028#bib.bib35)\]\. The expected calibration error \(ECE\)\[[29](https://arxiv.org/html/2611.27028#bib.bib29)\]is computed over 10 equal\-width bins of predicted probability\.

#### Counterfactual validation\.

We test the interventions of §[4\.4](https://arxiv.org/html/2611.27028#S4.SS4)in seven clinical scenarios on validation\. Five begin at a charted event after which clinicians commonly choose a treatment\. These events are a high potassium, a low glucose, a low blood pressure, a low oxygen saturation on the ventilator and the start of mechanical ventilation\. The other two copy the entry criteria of the ROSE trial\[[67](https://arxiv.org/html/2611.27028#bib.bib67)\]and of the invasively ventilated patients in the RECOVERY trial\[[74](https://arxiv.org/html/2611.27028#bib.bib74)\]\. The effect of a treatment on an outcome is the change in the outcome’s predicted probability against the control arm \(§[4\.4](https://arxiv.org/html/2611.27028#S4.SS4)\), averaged over ICU stays\. We pre\-specified the outcomes and the expected direction of each effect\. App\.[K](https://arxiv.org/html/2611.27028#A11)gives the full design and a worked example\.

## 6Results

### 6\.1Clinical prediction tasks

Table 2:Clinical prediction tasks: means over the 19 test tasks\. Differences are TWICE minus the strongest supervised baseline, paired on identical rows; the CI comes from 1,000 bootstrap replicates that resample patients \(§[5](https://arxiv.org/html/2611.27028#S5)\)\. Validation AUROC is given for reference\. Per\-task values are in App\.[G](https://arxiv.org/html/2611.27028#A7)\.![Refer to caption](https://arxiv.org/html/2611.27028v1/x2.png)Figure 2:Clinical prediction tasks on test\. Dots are the AUROC difference per task, TWICE minus the strongest supervised baseline, with 95% CIs from 1,000 patient\-clustered bootstrap replicates\. Open circles are the same difference on validation\. Orange marks a test CI above 0, blue a CI below 0 and grey a CI that includes 0\. Holm’s correction across the 19 tasks keeps seven of the nine coloured tasks, all but ventilator liberation and acute kidney injury\. Each method’s test AUROC is in Table[9](https://arxiv.org/html/2611.27028#A7.T9)\. P/F is PaO2/FiO2and S/F is SpO2/FiO2\. Definitions are in Table[4](https://arxiv.org/html/2611.27028#A2.T4)\.On the 19 test tasks, TWICE’s mean AUROC is 0\.8362 and that of the strongest supervised baseline is 0\.8345, a paired difference of\+0\.0017\+0\.0017\(95% CI−0\.0053\-0\.0053to\+0\.0090\+0\.0090;p=0\.64p=0\.64; Table[2](https://arxiv.org/html/2611.27028#S6.T2)\)\. The two tie, although TWICE was trained on none of these labels and the strongest supervised baseline was trained on each, in the configuration that scored best of 144 on validation\. Both scored slightly higher on test than on validation \(0\.8357 and 0\.8329\)\. Mean AUPRC is higher for TWICE \(0\.523 vs\. 0\.495\), a paired difference of\+0\.027\+0\.027\(95% CI\+0\.013\+0\.013to\+0\.041\+0\.041\)\. The Brier score is 0\.0892, against 0\.0889 for the strongest supervised baseline, but the expected calibration error is higher \(0\.030 vs\. 0\.012\)\. TWICE’s probabilities are frequencies over 50 futures, not recalibrated against any label, while the strongest supervised baseline is fitted to each one\. Reliability curves are in App\.[G](https://arxiv.org/html/2611.27028#A7)\.

The tie on the mean is not a tie on every task \(Fig\.[2](https://arxiv.org/html/2611.27028#S6.F2); App\.[G](https://arxiv.org/html/2611.27028#A7)\)\. TWICE leads on five tasks whose CIs exclude zero: imaging orders \(\+0\.036\+0\.036\), new invasive ventilation \(\+0\.034\+0\.034\), ICU discharge \(\+0\.033\+0\.033\), hypotension \(\+0\.020\+0\.020\) and ventilator liberation \(\+0\.016\+0\.016\)\. The strongest supervised baseline leads on four: FiO2weaning \(−0\.032\-0\.032\), ICU mortality \(−0\.024\-0\.024\), in\-hospital mortality \(−0\.015\-0\.015\) and acute kidney injury \(−0\.012\-0\.012\)\. Seven of the nine survive Holm’s correction across the 19 tasks; ventilator liberation and acute kidney injury do not\. The other ten tasks tie\. TWICE leads on events that change the state of care within hours or a day \(an imaging order, the start or end of ventilation, ICU discharge, a fall in blood pressure\), and it trails on death, on oxygen weaning and on a rise in creatinine\. The same five and four tasks clear zero, in the same directions, on validation, whose patients are disjoint from those in test\.

#### Discharge diagnoses, from the same futures\.

A future that reaches discharge writes the encounter’s diagnoses, so the same 50 futures also predict which diagnosis groups \(HCUP CCSR\[[31](https://arxiv.org/html/2611.27028#bib.bib31)\]\) the stay will be recorded with \(App\.[I](https://arxiv.org/html/2611.27028#A9)\)\. We trained no supervised model for these groups\. As a reference, the*documented*rule uses only whether a group is already documented at the prediction time, on the problem list or from an earlier admission\. It predicts the group’s training frequency among patients with the same documentation status\. Over the 116 groups common enough to score on test, TWICE reaches a macro AUROC of 0\.717 on all of a stay’s diagnoses and the documented rule reaches 0\.742\. TWICE has the higher macro AUPRC \(0\.174 vs\. 0\.141\)\. On diagnoses not yet documented at the prediction time, where the rule has no information, TWICE reaches 0\.693\.

The other baselines are in App\.[F](https://arxiv.org/html/2611.27028#A6): 143 more supervised configurations, of which the best sequence model on validation reaches 0\.782 on test, and 40 bedside\-score configurations, of which the best on validation reaches 0\.601 on test\.

### 6\.2Readout compute, model size and context

![Refer to caption](https://arxiv.org/html/2611.27028v1/x3.png)Figure 3:Readout compute, model size and context on validation\.\(a\)Mean AUROC over the 19 tasks for each checkpoint, read with 20 futures of at most 4,096 tokens and with 50 futures of at most 8,192\. The three lines are models trained at context 1,024\. TWICE is the 79\.3M\-parameter model trained at context 2,048\.†\\daggerRead with 40 futures, as this model was not read with 50 futures of 8,192 tokens\.\(b\)Share of TWICE’s 50 futures that decide each task, as a mean over the scored stays, at token budgets of 4,096 and 8,192\. Grey lines are the other 17 tasks\. The number beside each mortality task counts the scored stays with no decided future\.All results in this section are on validation\. Each comparison is paired on identical rows \(App\.[H](https://arxiv.org/html/2611.27028#A8), Table[11](https://arxiv.org/html/2611.27028#A8.T11)\)\.

#### Readout compute\.

The same checkpoint scores higher when it samples more futures and lets each run longer \(Fig\.[3](https://arxiv.org/html/2611.27028#S6.F3)a\)\. CoMET found the first of these at scale, with gains flattening near 64 simulations\[[93](https://arxiv.org/html/2611.27028#bib.bib93)\]\. Here we price both against model size, with the training data fixed\. From 20 futures of at most 4,096 tokens to 50 of at most 8,192, the mean AUROC of an 11\.7M\-parameter model rose from 0\.771 to 0\.803, and that of a 26\.2M model from 0\.784 to 0\.818\. A 79\.3M model with the same 1,024\-token context rose from 0\.794 to 0\.822 at 40 futures of 8,192 tokens\. Four to five times more readout compute was thus worth\+0\.029\+0\.029to\+0\.034\+0\.034to every checkpoint, more than the\+0\.023\+0\.023gained from 11\.7M to 79\.3M parameters at the cheapest readout\. The smallest model read at the largest setting outscored a model 6\.8 times its size read at the smallest \(0\.803 vs\. 0\.794\)\. To test where the gain from more futures flattens, we also read the 79\.3M model at context 1,024 with 40 and 50 futures of 4,096 tokens\. Going from 20 to 40 futures added\+0\.022\+0\.022\. Going from 40 to 50 added only\+0\.003\+0\.003\(unpaired, Table[11](https://arxiv.org/html/2611.27028#A8.T11)\), so the gain had nearly flattened by 50\. Doubling the token budget alone, from 4,096 to 8,192 tokens at 50 futures, added\+0\.009\+0\.009\(95% CI\+0\.002\+0\.002to\+0\.015\+0\.015\) to TWICE\.

#### Why the budget matters\.

A future that stops at the token budget before it decides a task leaves that task undecided \(Eq\.[1](https://arxiv.org/html/2611.27028#S4.E1)\)\. At a budget of 4,096 tokens, 40\.6% of TWICE’s futures stopped at the budget\. At 8,192, 28\.5% did\. The 17 tasks with horizons of 2 days or less were decided in 91% to 100% of futures at either budget \(Fig\.[3](https://arxiv.org/html/2611.27028#S6.F3)b\)\. The tasks whose horizon is the whole stay were decided less often\. With the longer budget, the share of futures that decided in\-hospital mortality rose from 58% to 70%\. The number of scored stays with no decided future, which receive the training rate, fell from 116 to 3\. The longer budget helped these two tasks most\. AUROC rose by\+0\.032\+0\.032\(95% CI\+0\.019\+0\.019to\+0\.045\+0\.045\) for in\-hospital and by\+0\.035\+0\.035\(\+0\.019\+0\.019to\+0\.051\+0\.051\) for ICU mortality, against\+0\.006\+0\.006on average over the other 17 tasks\. Censoring by the budget is informative\. The futures decided within it are those of patients who die or leave soon\. For TWICE this did not shift the mean predicted risk of in\-hospital death, which was 1\.12 times the training rate at both budgets\. For the 79\.3M model at context 1,024 it did\. Its ratio fell from 1\.08 to 1\.00 as its budget doubled, so its short\-budget futures had over\-stated death\. The budget is therefore part of the estimator, not only its cost, and it must be long enough for nearly every future to decide the question asked\.

#### Model size\.

Larger models scored higher\. At 50 futures of 8,192 tokens, the mean AUROC was 0\.803, 0\.818 and 0\.831 at 11\.7M, 26\.2M and 79\.3M parameters\. Each step added\+0\.014\+0\.014, and both 95% CIs exclude zero \(Table[11](https://arxiv.org/html/2611.27028#A8.T11)\)\. Only the first step changes size alone\. The 79\.3M model was also trained at a longer context, with stronger regularisation and a longer early\-stopping patience\.

#### Context length\.

Training at a longer context also helped\. In matched pairs, a context of 2,048 tokens instead of 1,024 added\+0\.012\+0\.012at 26\.2M parameters and\+0\.009\+0\.009at 79\.3M \(95% CIs\+0\.003\+0\.003to\+0\.020\+0\.020and\+0\.001\+0\.001to\+0\.017\+0\.017\)\. A warm start that extended a converged 1,024\-token model to 2,048 tokens added\+0\.001\+0\.001\. The gain therefore came from training at that length\. TWICE is the 79\.3M model trained at context 2,048 without the stronger regularisation \(0\.836\)\.

#### What did not help\.

Ten other changes left the mean within 0\.005 of their matched controls, except one \(App\.[H](https://arxiv.org/html/2611.27028#A8), Table[11](https://arxiv.org/html/2611.27028#A8.T11)\)\. They touched the input \(a demographic prefix on every training window, so that a window starting mid\-stay still sees the patient’s age and sex; training windows drawn per stay rather than per token\), the value tokens \(tail bins added to the deciles, log\-spaced bins, 30 quantile bins, and an auxiliary head regressing the value, at two sizes\), the training objective \(same\-minute events shuffled; auxiliary heads predicting which codes occur in the next 24 h, or when\), and the regularisation above\. The exception, log\-spaced bins, scored0\.0080\.008lower, with a 95% CI that includes zero \(−0\.017\-0\.017to\+0\.001\+0\.001\)\. With four bins across the bulk of a distribution, a threshold such as a creatinine rise of 0\.3 mg/dL falls inside a wide bin\.

### 6\.3Generation fidelity

![Refer to caption](https://arxiv.org/html/2611.27028v1/x4.png)Figure 4:Generation fidelity on validation\.\(a\)Next\-token accuracy by the type of the true next token, at 571,002 random positions in 8,938 stays\. Bars show top\-1 \(with its value\) and top\-5, and the tick shows the bigram model’s top\-1\.\(b\)The real next 24 h against one generated future, per panel of concepts\. Each dot is Curiosity’s RMSLE\[[93](https://arxiv.org/html/2611.27028#bib.bib93)\]divided by the median of 999 RMSLEs recomputed after swapping each patient’s real and generated windows with probability one half, so that 1 is the noise level\. The grey bar \(noise range\) runs from 1 to the 95th percentile of the swapped RMSLEs\. Filled dots differ after Holm’s correction across the 20 panels\. Panel labels abbreviate bedside and ventilator codes \(Bedside\), diagnoses \(Dx\), laboratory tests \(Lab\), medications \(Med\) and procedures \(Proc\)\.\(c\)Per\-patient Jaccard overlap of the concepts in the next 24 h\.We evaluated generation fidelity on the next token\[[80](https://arxiv.org/html/2611.27028#bib.bib80),[103](https://arxiv.org/html/2611.27028#bib.bib103)\], on the orders placed after an abnormal value and on the next 24 h of events\[[93](https://arxiv.org/html/2611.27028#bib.bib93)\]\(Fig\.[4](https://arxiv.org/html/2611.27028#S6.F4)\)\.

#### Next token\.

At 571,002 positions drawn at random from 8,938 validation stays \(64 per stay\), TWICE ranks the true next token first 75\.0% of the time \(95% CI 74\.7 to 75\.2\) and among its first five 95\.5% of the time, against 20\.1% top\-1 for a bigram model and 5\.1% for token frequencies\. Accuracy follows how predictable each kind of event is from what came before\. Bedside codes \(92\.6%\) and laboratory tests \(90\.6%\), which recur on schedules, are almost always placed first\. Value bins \(64\.3%\) and time gaps \(54\.6%\) are placed first about half the time and among the first five 96% and 98% of the time\. Medication orders \(19\.8%\) and diagnoses \(29\.4%\), which turn on decisions not yet in the record, are the hardest\. Of the distinct event codes among the next five events, 54\.2% are among the model’s ten most likely next tokens, against 29\.6% for the bigram model \(set recall SR@\(10, 5\)\[[71](https://arxiv.org/html/2611.27028#bib.bib71)\]\)\.

#### Orders after an abnormal value\.

Because a medication order is hard to place at the exact next position, we also asked whether the futures contain the order that clinicians placed after an abnormal value\. When a high potassium, a low glucose or a low blood pressure was first charted \(§[5](https://arxiv.org/html/2611.27028#S5)\), the futures sampled under usual care \(§[4\.4](https://arxiv.org/html/2611.27028#S4.SS4)\) predict six orders about as well as a gradient\-boosted model on summaries of the previous 24 h, with overlapping 95% CIs for all six \(App\.[L](https://arxiv.org/html/2611.27028#A12)\)\. For example, a vasopressor within 1 h of a low blood pressure is predicted with an AUROC of 0\.935 \(0\.910 to 0\.954\), against 0\.900 \(0\.864 to 0\.930\)\. Four of the six orders appear in the futures at 0\.4 to 0\.5 times the rate at which clinicians placed them, and vasopressors at the same rate \(0\.14\)\.

#### Generated versus real next 24 h\.

We compare the concepts in each patient’s real next 24 h with those in one generated window \(App\.[L](https://arxiv.org/html/2611.27028#A12)\)\. The statistic is the RMSLE between real and generated rates of single concepts \(prevalence\) and of concept pairs \(co\-occurrence\)\[[93](https://arxiv.org/html/2611.27028#bib.bib93)\]\. We compare the observed RMSLE with 999 RMSLEs recomputed after swapping each patient’s real and generated windows with probability one half\[[24](https://arxiv.org/html/2611.27028#bib.bib24)\]\. Each window is a single draw, so the RMSLE is above zero even when generated and real windows follow the same distribution\. The median of the 999 swapped RMSLEs estimates this noise level, and a ratio of 1 means no difference beyond noise\. After Holm’s correction, 11 of 20 panels differ, by at most 1\.32 times the noise level \(Fig\.[4](https://arxiv.org/html/2611.27028#S6.F4)b\)\. For co\-occurrence the ratio is 1\.02 to 1\.13\. Prevalence differs most for diagnoses, which enter the window only when the stay ends within it\. Of 2,697 single concepts, 16 occur at a different rate in the generated 24 h \(12 laboratory tests, 3 procedures and 1 medication class\)\. No diagnosis or bedside code differs\.

#### Patient specificity\.

A model could match these rates without using the patient’s history\. We compare each patient’s real next 24 h with one generated window by the Jaccard overlap of their concept sets \(Fig\.[4](https://arxiv.org/html/2611.27028#S6.F4)c\)\. The mean overlap is 0\.526, against 0\.278 when the real window is compared with a window generated for another patient\[[80](https://arxiv.org/html/2611.27028#bib.bib80)\]\(permutation testp=0\.001p=0\.001\)\. Two windows generated for the same patient have a mean overlap of 0\.522\. The real window thus overlaps a generated one about as much as two generated windows overlap each other \(sign\-flip testp=0\.063p=0\.063\)\. The two overlaps are equal in expectation when the futures are draws from the right distribution\.

### 6\.4Individual trajectories

![Refer to caption](https://arxiv.org/html/2611.27028v1/x5.png)Figure 5:Individual trajectories on validation\.\(a\)Risk of new ventilation within 24 h along the first stay that progressed to ventilation, from 50 futures sampled every 2 h, with a binomial 95% CI\. The grey interval is the largest rise after the prediction time\.\(b\)Mean predicted risk by hours before the event, 150 stays per outcome, with patient\-clustered 95% CIs\. Dashed lines are stays with neither event\.We evaluated whether TWICE follows one patient through a stay\[[76](https://arxiv.org/html/2611.27028#bib.bib76),[80](https://arxiv.org/html/2611.27028#bib.bib80)\]\(Fig\.[5](https://arxiv.org/html/2611.27028#S6.F5)\)\. The two outcomes, new invasive ventilation and in\-hospital death, were fixed before any output was read\. TWICE leads the strongest supervised baseline on the first and trails it on the second \(§[6\.1](https://arxiv.org/html/2611.27028#S6.SS1)\)\.

#### Case studies\.

We followed eight validation stays through their ICU course\. Every 2 h along each stay, TWICE was given the record up to that hour and sampled 50 futures, from which the risk at that hour is read \(§[4\.3](https://arxiv.org/html/2611.27028#S4.SS3)\)\. Stays were grouped by what happened after the prediction time\. We drew at random three stays that progressed to ventilation, three that ended in death and two with neither event, before any output was read \(App\.[G](https://arxiv.org/html/2611.27028#A7)\)\. In the first stay that progressed to ventilation, the risk of ventilation within 24 h was 0\.46 at the prediction time\. It then stayed at or below 0\.26 from 26 h until 54 h after ICU admission\. It rose to 0\.86 at 56 h, about 2 h before ventilation was charted \(Fig\.[5](https://arxiv.org/html/2611.27028#S6.F5)a\)\. Leaving out every event charted between 54 and 56 h lowers the risk at 56 h by 0\.56 \(95% CI 0\.40 to 0\.72, App\.[G](https://arxiv.org/html/2611.27028#A7)\)\. Leaving out any one of the interval’s 39 codes alone changes it by at most 0\.06\. In the other two stays that progressed to ventilation, leaving out the interval of the largest rise lowers the risk by 0\.18 and 0\.70, each with a CI above zero\. In all three stays, the largest rise in risk can thus be traced to the events of one 2 h interval\. In the first stay, the rise came 2 h before ventilation and may reflect care that had already begun\. To protect the patient’s privacy, Fig\.[5](https://arxiv.org/html/2611.27028#S6.F5)a shows no dates or measured values\[[101](https://arxiv.org/html/2611.27028#bib.bib101)\]\.

#### Risk before the event\.

We also sampled futures every 12 h along 150 validation stays that progressed to ventilation, 150 that ended in death and 148 with neither event \(Fig\.[5](https://arxiv.org/html/2611.27028#S6.F5)b\)\. Within 6 h of ventilator charting, TWICE’s mean risk of new ventilation is 0\.39 \(95% CI 0\.33 to 0\.46\), against 0\.14 \(0\.12 to 0\.16\) one to two days before and 0\.038 in stays with neither event\. The strongest supervised baseline gives 0\.23, 0\.10 and 0\.035 on the same rows\. Within 6 h of death, TWICE’s risk of in\-hospital death is 0\.77 \(0\.72 to 0\.82\), against 0\.50 \(0\.42 to 0\.57\) five days or more before and 0\.077 in stays with neither event \(strongest supervised baseline 0\.69, 0\.41 and 0\.074\)\. Both models give more risk as the event nears\. TWICE gives more risk to imminent ventilation at a similar risk in stays without it\. The same ordering holds at the prediction time on every scored stay \(App\.[G](https://arxiv.org/html/2611.27028#A7)\)\.

### 6\.5Counterfactual validation

![Refer to caption](https://arxiv.org/html/2611.27028v1/x6.png)Figure 6:Counterfactual validation on validation\.\(a\)Effect of each order on the probability of each event, against the control arm \(§[4\.4](https://arxiv.org/html/2611.27028#S4.SS4)\), with patient\-clustered 95% CIs\. The shaded side of zero is the pre\-specified direction\. Pantoprazole is expected to change nothing\. Open circles show the other drugs tested in the same scenario\.\(b\)In\-hospital death in two trial emulations at the longest token budget \(App\.[K](https://arxiv.org/html/2611.27028#A11)\), TWICE against the published estimate\[[67](https://arxiv.org/html/2611.27028#bib.bib67),[74](https://arxiv.org/html/2611.27028#bib.bib74)\]\.We evaluated whether TWICE responds correctly when a treatment is written into the EHR\[[71](https://arxiv.org/html/2611.27028#bib.bib71),[56](https://arxiv.org/html/2611.27028#bib.bib56),[78](https://arxiv.org/html/2611.27028#bib.bib78)\], in the seven clinical scenarios of §[5](https://arxiv.org/html/2611.27028#S5)\.

#### Side effects\.

Clinicians rarely order a drug for its side effects, so a side effect is less likely than an intended effect to reflect why the drug was ordered\[[63](https://arxiv.org/html/2611.27028#bib.bib63),[89](https://arxiv.org/html/2611.27028#bib.bib89)\]\. TWICE predicted all four pre\-specified side effects, each with a 95% CI above zero\. Two of them were specific to the drug \(Fig\.[6](https://arxiv.org/html/2611.27028#S6.F6)a\)\. At a high potassium, insulin raised the probability of glucose<<70 mg/dL within 6 h by 0\.031 \(0\.023 to 0\.039\)\. The other drugs tested there raised it by at most 0\.006\. At the start of ventilation, where the tested drugs are sedatives, dexmedetomidine raised the probability of a heart rate<<50 within 6 h by 0\.033 \(0\.029 to 0\.036\), about twice as much as propofol or midazolam\. Propofol raised the probability of a mean arterial pressure<<65 mmHg within 2 h by 0\.022 \(0\.017 to 0\.027\)\. Dexmedetomidine and midazolam raised it by as much\. In the RECOVERY emulation, dexamethasone raised the probability of glucose\>\>180 mg/dL within 24 h by 0\.109 \(0\.076 to 0\.150\)\. These effects suggest that TWICE learned what these drugs do, not only when clinicians order them\.

#### Inert drugs\.

Pantoprazole is ordered to prevent stress ulcers in patients sick enough to be at risk\[[20](https://arxiv.org/html/2611.27028#bib.bib20)\]\. It is not expected to change potassium, glucose, blood pressure, oxygen saturation or heart rate within hours\. A model that reads any order as a sign of illness could still move these values after it\[[53](https://arxiv.org/html/2611.27028#bib.bib53)\]\. We therefore wrote it in as an extra treatment in every scenario\. As expected, it barely moved the forecasts\. It moved no primary outcome at a high potassium, a low glucose or a low blood pressure\. Three of its effects had CIs that exclude zero\. They were on oxygen saturation on the ventilator and on low blood pressure and low heart rate at the start of ventilation\. Each was at most 0\.006, against 0\.022 to 0\.033 for the side effects outside the trials\. At a high potassium, IV calcium moved neither potassium outcome either\. It protects the heart but is not expected to lower potassium\[[6](https://arxiv.org/html/2611.27028#bib.bib6)\]\. Its effect on the first potassium below 5\.5 mmol/L within 4 h was\+0\.007\+0\.007\(−0\.001\-0\.001to\+0\.016\+0\.016\)\. TWICE thus did not read every order as a sign of illness\.

#### Effects on the target\.

The target of a treatment is the value it is given to correct, such as a high potassium\. Four scenarios compare the right treatment, which guidelines recommend, with an opposite treatment, which is expected to push the target the other way\. At a high potassium, for example, insulin is the right treatment and potassium chloride the opposite one\. Insulin, dextrose and a higher FiO2improved their targets \(Fig\.[6](https://arxiv.org/html/2611.27028#S6.F6)a\)\. In all four scenarios, however, the opposite treatment failed to make the target worse\. At a high potassium, insulin raised the probability that the first potassium within 4 h is below 5\.5 mmol/L by 0\.018 \(0\.009 to 0\.028\)\. Potassium chloride, which adds potassium, raised it by 0\.013 \(0\.006 to 0\.022\)\. Both effects are smaller on the pre\-specified primary outcome \(App\.[K](https://arxiv.org/html/2611.27028#A11)\)\. At a low glucose and a low oxygen saturation on the ventilator, the opposite treatment also improved the target about as much as the right one\. At a low blood pressure, norepinephrine lowered the probability that the first mean arterial pressure within 1 h is at least 65 mmHg \(−0\.014\-0\.014,−0\.017\-0\.017to−0\.010\-0\.010\)\. A PEEP increase at a low oxygen saturation also moved the target against the expected direction, although the oxygenation response to PEEP varies between patients\[[27](https://arxiv.org/html/2611.27028#bib.bib27)\]\. These patterns are expected when an order is read as a sign of the patient’s state, as in the vasopressor example of §[2](https://arxiv.org/html/2611.27028#S2)\.

#### Measurement of the target\.

We checked whether the gains after the opposite treatments reflect how outcomes on a measured value are counted\. Such an outcome counts only the futures that measure the value within the window, as in the prediction tasks \(§[4\.3](https://arxiv.org/html/2611.27028#S4.SS3)\)\. An order can therefore change an outcome by changing which futures are counted, without changing the value itself\[[3](https://arxiv.org/html/2611.27028#bib.bib3)\]\. At a low oxygen saturation on the ventilator, nearly every future measured SpO2within the hour \(0\.98 in every arm\)\. Measurement therefore cannot explain why lowering FiO2raised SpO2as much as raising it did\. At a low glucose, writing in dextrose or insulin made a glucose measurement within the hour more likely \(0\.48 and 0\.41 of futures, against 0\.35 in the control arm and with pantoprazole\)\. Part of the glucose result may therefore reflect which futures are measured rather than the glucose value itself\.

#### Observed outcomes\.

Some patients in the five scenarios that start at a charted event received one of the tested treatments within 1 to 2 h\. For these patients we asked whether writing in the treatment they actually received predicts what followed better than futures with nothing written in or forbidden\. Each pre\-specified outcome is scored by the Brier score against what the EHR recorded \(App\.[K](https://arxiv.org/html/2611.27028#A11)\)\. Knowing the treatment did not improve the forecast\. Across the 26 pairs of a treatment and an outcome, the gain in Brier score ranged from−0\.041\-0\.041to\+0\.019\+0\.019\. Only one CI excluded zero, and it favoured the futures with nothing written in \(midazolam on a heart rate<<50,−0\.006\-0\.006,−0\.014\-0\.014to−0\.001\-0\.001\)\. A written\-in treatment moved the predicted probabilities by only a few hundredths \(Fig\.[6](https://arxiv.org/html/2611.27028#S6.F6)a\), which limits how much it can change the Brier score\.

#### Tabular estimators\.

We also estimated the effects with two standard methods for observational data, fitted on the same scenarios in the training split \(App\.[K](https://arxiv.org/html/2611.27028#A11)\)\. The S\-learner is a gradient\-boosted model of the outcome given the history and the treatment, read with the treatment switched on and off\[[47](https://arxiv.org/html/2611.27028#bib.bib47)\]\. The other is inverse\-probability weighting\[[33](https://arxiv.org/html/2611.27028#bib.bib33)\]\. The S\-learner reversed both effects\. After norepinephrine, it lowered the probability that the first mean arterial pressure within 1 h is at least 65 mmHg \(−0\.147\-0\.147,−0\.150\-0\.150to−0\.144\-0\.144\), against−0\.014\-0\.014for TWICE\. After insulin, it lowered the probability that the first potassium within 4 h is below 5\.5 mmol/L \(−0\.110\-0\.110,−0\.126\-0\.126to−0\.093\-0\.093\), where TWICE raised it by 0\.018\. Inverse\-probability weighting also lowered it \(−0\.227\-0\.227,−0\.471\-0\.471to\+0\.020\+0\.020\), in the 113 stays where both choices were plausible\. Neither method did better than TWICE on the targets\.

#### Trial emulations\.

TWICE agreed with the null trial, ROSE, and disagreed with the effective one, RECOVERY \(Fig\.[6](https://arxiv.org/html/2611.27028#S6.F6)b, App\.[K](https://arxiv.org/html/2611.27028#A11)\)\. In ROSE, early neuromuscular blockade in moderate to severe ARDS did not change mortality at 90 days\[[67](https://arxiv.org/html/2611.27028#bib.bib67)\]\. In the emulation, cisatracurium changed the probability of in\-hospital death by\+0\.013\+0\.013\(−0\.026\-0\.026to\+0\.051\+0\.051\), within the trial’s 95% CI of−0\.064\-0\.064to\+0\.059\+0\.059\[[92](https://arxiv.org/html/2611.27028#bib.bib92)\]\. This agreement cannot be told apart from insensitivity, however\. Every effect on death in the two emulations, pantoprazole included, lies within±\\pm0\.025\. A single order therefore barely moves TWICE’s predicted death\. In the invasively ventilated stratum of RECOVERY, dexamethasone reduced 28\-day mortality, with a rate ratio of 0\.64 \(0\.51 to 0\.81\)\[[74](https://arxiv.org/html/2611.27028#bib.bib74)\]\. In the emulation, the risk ratio for in\-hospital death was 0\.95 \(0\.88 to 1\.04\)\. The two intervals do not overlap\. The emulation reads COVID\-19 from a diagnosis code recorded at discharge, and TWICE does not see SARS\-CoV\-2 test results\. Both emulations also differ from the trials in endpoint, era and control arm\. For example, 17% of ROSE’s usual\-care patients received a neuromuscular blocker, which the control arm here forbids \(App\.[K](https://arxiv.org/html/2611.27028#A11)\)\.

## 7Discussion

We asked how far a generative event model trained on the ICU records of one health system goes toward a digital twin of the ICU patient\[[66](https://arxiv.org/html/2611.27028#bib.bib66)\]\. Without task\-specific training, TWICE matched the strongest of 144 supervised configurations on 19 clinical prediction tasks on held\-out patients\. Its mean AUPRC was also higher\. It led on the events that change care within hours or a day, such as the start of ventilation, a fall in blood pressure, ICU discharge and an imaging order\. These leads appeared on validation and again on the separate test patients\. Its generated records were close to real ones at the next token and over the next 24 h \(§[6\.3](https://arxiv.org/html/2611.27028#S6.SS3)\)\. A patient’s real future overlapped a generated one about as much as two generated futures overlapped each other\. Its futures predicted the orders that clinicians placed after an abnormal value about as well as a gradient\-boosted model\. Its predicted risk rose as an event approached\. Within 6 h of ventilation, it gave more risk than the strongest supervised baseline\. Because a twin is meant to inform decisions about care, we also tested how TWICE responds when a treatment is written into the EHR\. It reproduced all four pre\-specified side effects, two of them specific to the drug, and an inert drug barely moved its forecasts\. Insulin, dextrose and a higher FiO2moved their targets in the expected direction\. Two standard methods for observational data did no better on the targets\. In all four scenarios that compare a right and an opposite treatment, however, the opposite treatment failed to make the target worse\.

#### Target effects and confounding by indication\.

An order in the EHR follows the clinician’s reading of the patient, and much of that reading is not recorded\. A potassium result judged falsely high from a haemolysed sample is one example \(App\.[K](https://arxiv.org/html/2611.27028#A11)\), and the patient’s appearance at the bedside is another\. A model trained to continue the EHR may therefore learn an order as a sign of the state that prompted it, which is confounding by indication \(§[2](https://arxiv.org/html/2611.27028#S2)\)\. A gradient\-boosted S\-learner, which sees the same history through tabular features, reversed the effects of both norepinephrine and insulin on their targets \(§[6\.5](https://arxiv.org/html/2611.27028#S6.SS5)\)\. This suggests that the failure arises from what observational records contain rather than from the architecture alone\. We suggest that generative event models be evaluated with controls that can detect this failure, such as the side effects, inert drugs and opposite treatments of §[6\.5](https://arxiv.org/html/2611.27028#S6.SS5)\. EHR\-MPC and FlatASCEND insert treatments into generative models of sepsis care and of MIMIC\-IV\[[71](https://arxiv.org/html/2611.27028#bib.bib71),[78](https://arxiv.org/html/2611.27028#bib.bib78)\]\. Our set of controls is a template on which such models can be compared\.

#### Readout compute and its cost\.

With the training data fixed, four to five times more readout compute raised the mean AUROC of every checkpoint more than a 6\.8\-fold larger model did \(§[6\.2](https://arxiv.org/html/2611.27028#S6.SS2)\)\. More simulated futures improve the estimates of generative event models\[[93](https://arxiv.org/html/2611.27028#bib.bib93),[59](https://arxiv.org/html/2611.27028#bib.bib59)\], as test\-time compute improves language models\[[82](https://arxiv.org/html/2611.27028#bib.bib82)\]\. Here we compared this gain with the gain from model size\. For TWICE, the readout took 29\.8 h for 8,947 scored validation stays on one NVIDIA H200, about 12 s per stay for 50 futures\. At this rate, the forecasts for an ICU could be refreshed every few hours\. Estimators that read probabilities from the next\-token distribution may reduce the cost further\[[83](https://arxiv.org/html/2611.27028#bib.bib83)\]\. A hospital that cannot pool its data with others can still increase its readout compute\. At 79\.3M parameters, TWICE had about 20 unique training tokens per parameter, as Chinchilla had\[[34](https://arxiv.org/html/2611.27028#bib.bib34)\], against 134 at 11\.7M\. It reached its best held\-out loss after about 35 passes over the training tokens, well beyond the four or so passes for which repeated data were nearly as useful as new data\[[65](https://arxiv.org/html/2611.27028#bib.bib65)\]\. The token budget is also part of the estimator\. CoMET right\-censors futures that stop before the horizon and leaves futures that always reach it to future work\[[93](https://arxiv.org/html/2611.27028#bib.bib93)\]\. We found that this censoring is informative \(§[6\.2](https://arxiv.org/html/2611.27028#S6.SS2)\)\. The budget should therefore be set for the question, and long\-horizon questions need long budgets\.

#### Shared futures across tasks\.

The same 50 futures per patient answered the 19 tasks, 449 diagnosis groups and the fidelity tests\. With an order written in, they also answered the counterfactual scenarios\. Each future is one course of the stay, so the answers to different questions about a patient come from the same courses\. Risks read from shared futures therefore respect the dependencies between events\[[76](https://arxiv.org/html/2611.27028#bib.bib76)\]\. A patient who dies in a future, for example, cannot also leave the ICU alive in it\. Separately trained models for the 19 tasks carry no such constraint\. The supervised baseline needed a labelled training set and a model for each task\. TWICE needed neither, and it can be asked a new question without training\.

#### Limitations\.

This study has several limitations\. First, the data come from one health system, and TWICE has not yet been tested on another\. MIMIC\-IV\[[38](https://arxiv.org/html/2611.27028#bib.bib38)\], eICU\[[72](https://arxiv.org/html/2611.27028#bib.bib72)\]and EHRSHOT\[[95](https://arxiv.org/html/2611.27028#bib.bib95)\]have been converted for that purpose\. Second, every modelling and readout choice was made on validation, which makes validation results optimistic\. Only the results of §[6\.1](https://arxiv.org/html/2611.27028#S6.SS1)are on the test split, which was read once\. Third, the evaluation has a limited scope\. Tasks were excluded by stated rules\. The single prediction time covers only patients still in the ICU after a day\. Fourth, some events are recorded imprecisely\. Ventilation is read from ventilator charting, which lags intubation\. An ICU stay is one unit’s admission, so a death after a transfer between ICUs is not an ICU death for the first stay \(App\.[B](https://arxiv.org/html/2611.27028#A2)\)\. Medications are orders, not administrations\. Fifth, values are represented by deciles, so a threshold inside a bin is bracketed rather than resolved\. This limits how finely TWICE represents laboratory targets \(App\.[K](https://arxiv.org/html/2611.27028#A11)\)\. Sixth, probabilities are not recalibrated, and the expected calibration error is higher than that of the strongest supervised baseline\. The readout also needs more compute than a supervised model\. Finally, the simulated interventions estimate the effect of “order now, then usual care” under no unmeasured confounding and positivity\. Counterfactual validation suggests that the first of these assumptions does not hold for target effects\. Performance by subgroup is reported in App\.[N](https://arxiv.org/html/2611.27028#A14)\.

#### Next steps\.

We see three directions for further work\. The first is to add notes and images\. TWICE reads only structured events\. It sees that a note was written or an image was ordered but not what the note says or what the image shows\. Notes record part of the clinician’s reading of the patient, and chest radiographs show the bilateral opacities that the Berlin definition of ARDS requires\[[8](https://arxiv.org/html/2611.27028#bib.bib8)\]\. Adding them may reduce the confounding by indication described above\. Autoregressive EHR models have been conditioned on notes, chest radiographs and ECGs, although these inputs did not always improve the prediction of ICU death\[[54](https://arxiv.org/html/2611.27028#bib.bib54)\]\. APOLLO places notes and images on the same timeline as structured events\[[101](https://arxiv.org/html/2611.27028#bib.bib101)\]\. The second is to change the training target\. TWICE is trained to predict each next token, so it must also predict how care is documented, such as when a value is charted\. Joint\-embedding predictive architectures predict the representation of a hidden part of an image rather than its pixels, which may let a model leave out details that cannot be predicted\[[50](https://arxiv.org/html/2611.27028#bib.bib50),[10](https://arxiv.org/html/2611.27028#bib.bib10)\]\. An ICU stay can also be viewed as a hidden Markov model\. The hidden state is the patient’s condition\. The EHR and other data are observations of that state, and orders are actions that change it\. Deep state\-space models have represented EHR data in this way, with treatments as inputs to the change of state\[[45](https://arxiv.org/html/2611.27028#bib.bib45),[46](https://arxiv.org/html/2611.27028#bib.bib46)\]\. Recent models of ICU, cancer and pulmonary embolism patients predict future states in a learned latent space\[[99](https://arxiv.org/html/2611.27028#bib.bib99),[2](https://arxiv.org/html/2611.27028#bib.bib2)\]\. Any model trained only on observational records may still face confounding by indication, so the third direction looks outside the EHR\. A model can be anchored to trials, natural experiments and pharmacology, as HealthFormer was compared with published trials\[[56](https://arxiv.org/html/2611.27028#bib.bib56)\]\. Silent prospective use, in which forecasts are recorded before clinicians act, would show when such responses can support decisions\.

We see this work as a step toward a digital twin of the ICU patient\. TWICE forecasts ICU events about as well as the strongest supervised baseline, leads it on events that change care within a day and generates records close to real ones\. It also reproduces known side effects of drugs\. Its predicted effects of treatments on their targets, however, do not yet separate the right treatment from the opposite one, so it is not yet a twin\. Controls such as those of §[6\.5](https://arxiv.org/html/2611.27028#S6.SS5), external data and prospective use will show when a model of this kind can inform decisions about care\.

## Ethics, data and code availability

The MGB Institutional Review Board approved this retrospective study \(protocol 2022P001232\) and waived the requirement for informed consent\. The data contain protected health information and cannot be shared\. The code will be made publicly available\.

## Author contributions

Roles follow the CRediT taxonomy\. Zhuoyang Lyu:Conceptualization, Methodology, Software, Data curation, Formal analysis, Investigation, Visualization, Writing – original draft, Writing – review & editing\. Yiming Li:Data curation, Supervision\. Peter C\. Hou:Conceptualization, Supervision, Resources, Funding acquisition, Writing – review & editing\. Pengyu Hong:Conceptualization, Supervision, Resources, Funding acquisition, Writing – review & editing\. Li Zhou:Conceptualization, Supervision, Resources, Funding acquisition, Writing – review & editing\.

## References

- \[1\]Acute Respiratory Distress Syndrome Network\.Ventilation with lower tidal volumes as compared with traditional tidal volumes for acute lung injury and the acute respiratory distress syndrome\.*New England Journal of Medicine*, 342\(18\):1301–1308, 2000\.doi:10\.1056/NEJM200005043421801\.URL[https://doi\.org/10\.1056/NEJM200005043421801](https://doi.org/10.1056/NEJM200005043421801)\.
- \[2\]I\. Adam, Z\. Chen, D\. Laprade, S\. Porwal, D\. Laub, E\. Reinertsen, A\. Pekis, and K\. Brown\.The patient is not a moving document: A world model training paradigm for longitudinal EHR\.arXiv preprint arXiv:2601\.22128, 2026\.URL[https://arxiv\.org/abs/2601\.22128](https://arxiv.org/abs/2601.22128)\.Version 1, 29 January 2026\.
- \[3\]D\. Agniel, I\. S\. Kohane, and G\. M\. Weber\.Biases in electronic health record data due to processes within the healthcare system: retrospective observational study\.*BMJ*, 361:k1479, 2018\.doi:10\.1136/bmj\.k1479\.URL[https://doi\.org/10\.1136/bmj\.k1479](https://doi.org/10.1136/bmj.k1479)\.
- \[4\]J\. Ainslie, J\. Lee\-Thorp, M\. de Jong, Y\. Zemlyanskiy, F\. Lebrón, and S\. Sanghai\.GQA: Training generalized multi\-query Transformer models from multi\-head checkpoints\.In*Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing*, pages 4895–4901, Singapore, 2023\. Association for Computational Linguistics\.doi:10\.18653/v1/2023\.emnlp\-main\.298\.URL[https://aclanthology\.org/2023\.emnlp\-main\.298/](https://aclanthology.org/2023.emnlp-main.298/)\.
- \[5\]Y\. Akagi, T\. Seki, H\. Ito, T\. Takiguchi, K\. Ohe, and Y\. Kawazoe\.High\-fidelity longitudinal patient simulation using real\-world data\.arXiv preprint arXiv:2601\.17310, 2026\.URL[https://arxiv\.org/abs/2601\.17310](https://arxiv.org/abs/2601.17310)\.Version 1, 24 January 2026\.
- \[6\]A\. Alfonzo, A\. Harrison, R\. Baines, A\. Chu, S\. Mann, and M\. MacRury\.Clinical practice guidelines: Treatment of acute hyperkalaemia in adults\.The Renal Association \(now the UK Kidney Association\), 2020\.URL[https://ukkidney\.org/wp\-content/uploads/drupal\-archive/RENAL%20ASSOCIATION%20HYPERKALAEMIA%20GUIDELINE%20\-%20JULY%202022%20V2\_0\.pdf](https://ukkidney.org/wp-content/uploads/drupal-archive/RENAL%20ASSOCIATION%20HYPERKALAEMIA%20GUIDELINE%20-%20JULY%202022%20V2_0.pdf)\.Final version June 2020; the copy hosted by the UK Kidney Association is Version 2 \(2022 amendment\)\. Accessed 12 November 2026\.
- \[7\]American Diabetes Association Professional Practice Committee\.6\. Glycemic goals and hypoglycemia: Standards of Care in Diabetes—2024\.*Diabetes Care*, 47\(Suppl\. 1\):S111–S125, 2024\.doi:10\.2337/dc24\-S006\.URL[https://doi\.org/10\.2337/dc24\-S006](https://doi.org/10.2337/dc24-S006)\.
- \[8\]ARDS Definition Task Force, V\. M\. Ranieri, G\. D\. Rubenfeld, B\. T\. Thompson, N\. D\. Ferguson, E\. Caldwell, E\. Fan, L\. Camporota, and A\. S\. Slutsky\.Acute respiratory distress syndrome: The Berlin Definition\.*JAMA*, 307\(23\):2526–2533, 2012\.doi:10\.1001/jama\.2012\.5669\.URL[https://doi\.org/10\.1001/jama\.2012\.5669](https://doi.org/10.1001/jama.2012.5669)\.
- \[9\]B\. Arnrich, E\. Choi, J\. Fries, M\. McDermott, J\. Oh, T\. Pollard, N\. Shah, E\. Steinberg, M\. Wornow, and R\. van de Water\.Medical Event Data Standard \(MEDS\): Facilitating machine learning for health\.In*ICLR 2024 Workshop on Learning from Time Series for Health*, 2024\.URL[https://openreview\.net/forum?id=IsHy2ebjIG](https://openreview.net/forum?id=IsHy2ebjIG)\.
- \[10\]M\. Assran, Q\. Duval, I\. Misra, P\. Bojanowski, P\. Vincent, M\. Rabbat, Y\. LeCun, and N\. Ballas\.Self\-supervised learning from images with a joint\-embedding predictive architecture\.In*Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition \(CVPR\)*, pages 15619–15629\. IEEE, 2023\.doi:10\.1109/CVPR52729\.2023\.01499\.URL[https://openaccess\.thecvf\.com/content/CVPR2023/html/Assran\_Self\-Supervised\_Learning\_From\_Images\_With\_a\_Joint\-Embedding\_Predictive\_Architecture\_CVPR\_2023\_paper\.html](https://openaccess.thecvf.com/content/CVPR2023/html/Assran_Self-Supervised_Learning_From_Images_With_a_Joint-Embedding_Predictive_Architecture_CVPR_2023_paper.html)\.
- \[11\]Y\. Benjamini and Y\. Hochberg\.Controlling the false discovery rate: A practical and powerful approach to multiple testing\.*Journal of the Royal Statistical Society\. Series B \(Methodological\)*, 57\(1\):289–300, 1995\.doi:10\.1111/j\.2517\-6161\.1995\.tb02031\.x\.URL[https://doi\.org/10\.1111/j\.2517\-6161\.1995\.tb02031\.x](https://doi.org/10.1111/j.2517-6161.1995.tb02031.x)\.
- \[12\]J\.\-M\. Boles, J\. Bion, A\. Connors, M\. Herridge, B\. Marsh, C\. Melot, R\. Pearl, H\. Silverman, M\. Stanchina, A\. Vieillard\-Baron, and T\. Welte\.Weaning from mechanical ventilation\.*European Respiratory Journal*, 29\(5\):1033–1056, 2007\.doi:10\.1183/09031936\.00010206\.URL[https://doi\.org/10\.1183/09031936\.00010206](https://doi.org/10.1183/09031936.00010206)\.
- \[13\]M\. Burger, D\. Chopard, G\. Lichtner, M\. Londschien, F\. Sergeev, M\. Fuchs, H\. Yèche, R\. Kuznetsova, M\. Faltys, E\. Gerdes, P\. Leshetkina, M\. Christ, M\. Schanz, N\. Göbel, P\. Bühlmann, E\. Grünewald, F\. Balzer, and G\. Rätsch\.A foundation model for intensive care: Unlocking generalization across tasks and domains at scale\.medRxiv preprint, 2025\.URL[https://doi\.org/10\.1101/2025\.07\.25\.25331635](https://doi.org/10.1101/2025.07.25.25331635)\.Version 2, posted 2 April 2026\.
- \[14\]M\. C\. Burkhart, L\. Solo, I\. Lee, S\. Charles, Z\. W\. Liao, K\. Chhikara, D\. Therese, W\.\-T\. Liao, C\. A\. Gao, W\. F\. Parker, and B\. K\. Beaulieu\-Jones\.Federated generative event models for tokenized electronic health records\.arXiv preprint arXiv:2608\.02939, 2026\.URL[https://arxiv\.org/abs/2608\.02939](https://arxiv.org/abs/2608.02939)\.
- \[15\]B\. Casserly, G\. S\. Phillips, C\. Schorr, R\. P\. Dellinger, S\. R\. Townsend, T\. M\. Osborn, K\. Reinhart, N\. Selvakumar, and M\. M\. Levy\.Lactate measurements in sepsis\-induced tissue hypoperfusion: Results from the Surviving Sepsis Campaign database\.*Critical Care Medicine*, 43\(3\):567–573, 2015\.doi:10\.1097/CCM\.0000000000000742\.URL[https://doi\.org/10\.1097/CCM\.0000000000000742](https://doi.org/10.1097/CCM.0000000000000742)\.
- \[16\]T\. Chen and C\. Guestrin\.XGBoost: A scalable tree boosting system\.In*Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining*, pages 785–794, San Francisco, CA, USA, 2016\. ACM\.doi:10\.1145/2939672\.2939785\.URL[https://doi\.org/10\.1145/2939672\.2939785](https://doi.org/10.1145/2939672.2939785)\.
- \[17\]K\. Cho, B\. van Merriënboer, C\. Gulcehre, D\. Bahdanau, F\. Bougares, H\. Schwenk, and Y\. Bengio\.Learning phrase representations using RNN encoder–decoder for statistical machine translation\.In*Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing \(EMNLP\)*, pages 1724–1734, Doha, Qatar, 2014\. Association for Computational Linguistics\.doi:10\.3115/v1/D14\-1179\.URL[https://aclanthology\.org/D14\-1179/](https://aclanthology.org/D14-1179/)\.
- \[18\]J\. N\. Clore and L\. Thurby\-Hay\.Glucocorticoid\-induced hyperglycemia\.*Endocrine Practice*, 15\(5\):469–474, 2009\.doi:10\.4158/EP08331\.RAR\.URL[https://doi\.org/10\.4158/EP08331\.RAR](https://doi.org/10.4158/EP08331.RAR)\.
- \[19\]G\. S\. Collins, K\. G\. M\. Moons, P\. Dhiman, R\. D\. Riley, A\. L\. Beam, B\. Van Calster, M\. Ghassemi, X\. Liu, J\. B\. Reitsma, M\. van Smeden, A\.\-L\. Boulesteix, J\. C\. Camaradou, L\. A\. Celi, S\. Denaxas, A\. K\. Denniston, B\. Glocker, R\. M\. Golub, H\. Harvey, G\. Heinze, M\. M\. Hoffman, A\. P\. Kengne, E\. Lam, N\. Lee, E\. W\. Loder, L\. Maier\-Hein, B\. A\. Mateen, M\. D\. McCradden, L\. Oakden\-Rayner, J\. Ordish, R\. Parnell, S\. Rose, K\. Singh, L\. Wynants, and P\. Logullo\.TRIPOD\+AI statement: updated guidance for reporting clinical prediction models that use regression or machine learning methods\.*BMJ*, 385:e078378, 2024\.doi:10\.1136/bmj\-2023\-078378\.URL[https://doi\.org/10\.1136/bmj\-2023\-078378](https://doi.org/10.1136/bmj-2023-078378)\.
- \[20\]D\. Cook, A\. Deane, F\. Lauzier, N\. Zytaruk, G\. Guyatt, L\. Saunders, M\. Hardie, D\. Heels\-Ansdell, W\. Alhazzani, J\. Marshall, J\. Muscedere, J\. Myburgh, S\. English, Y\. M\. Arabi, M\. Ostermann, S\. Knowles, N\. Hammond, K\. M\. Byrne, M\. Chapman, B\. Venkatesh, P\. Young, D\. Rajbhandari, A\. Poole, A\. Al\-Fares, G\. Reis, D\. Johnson, M\. Iqbal, R\. Hall, M\. Meade, L\. Hand, E\. Duan, F\. Clarke, J\. C\. Dionne, J\. L\. Y\. Tsang, B\. Rochwerg, T\. Karachi, F\. Lamontagne, F\. D’Aragon, C\. St\. Arnaud, B\. Reeve, A\. Geagea, D\. Niven, G\. Vazquez\-Grande, R\. Zarychanski, D\. Ovakim, G\. Wood, K\. E\. A\. Burns, A\. Goffi, M\. E\. Wilcox, W\. Henderson, D\. Forrest, R\. Fowler, N\. K\. J\. Adhikari, I\. Ball, T\. Mele, A\. Binnie, S\. Trop, S\. Mehta, I\. Morgan, O\. Loubani, M\. Vanstone, K\. Fiest, E\. Charbonney, Y\. A\. Cavayas, P\. Archambault, O\. G\. Rewa, V\. Lau, A\. S\. Kristof, K\. Khwaja, D\. Williamson, S\. Kanji, E\. Sy, B\. Dennis, S\. Reynolds, F\. Marquis, F\. Lellouche, A\. Rahman, P\. Hosek, J\. F\. Barletta, R\. Cirrone, M\. Tutschka, F\. Xie, L\. Billot, L\. Thabane, and S\. Finfer\.Stress ulcer prophylaxis during invasive mechanical ventilation\.*New England Journal of Medicine*, 391\(1\):9–20, 2024\.doi:10\.1056/NEJMoa2404245\.URL[https://doi\.org/10\.1056/NEJMoa2404245](https://doi.org/10.1056/NEJMoa2404245)\.
- \[21\]C\. Czado, T\. Gneiting, and L\. Held\.Predictive model assessment for count data\.*Biometrics*, 65\(4\):1254–1261, 2009\.doi:10\.1111/j\.1541\-0420\.2009\.01191\.x\.URL[https://doi\.org/10\.1111/j\.1541\-0420\.2009\.01191\.x](https://doi.org/10.1111/j.1541-0420.2009.01191.x)\.
- \[22\]J\. W\. Devlin, Y\. Skrobik, C\. Gélinas, D\. M\. Needham, A\. J\. C\. Slooter, P\. P\. Pandharipande, P\. L\. Watson, G\. L\. Weinhouse, M\. E\. Nunnally, B\. Rochwerg, M\. C\. Balas, M\. van den Boogaard, K\. J\. Bosma, N\. E\. Brummel, G\. Chanques, L\. Denehy, X\. Drouot, G\. L\. Fraser, J\. E\. Harris, A\. M\. Joffe, M\. E\. Kho, J\. P\. Kress, J\. A\. Lanphere, S\. McKinley, K\. J\. Neufeld, M\. A\. Pisani, J\.\-F\. Payen, B\. T\. Pun, K\. A\. Puntillo, R\. R\. Riker, B\. R\. H\. Robinson, Y\. Shehabi, P\. M\. Szumita, C\. Winkelman, J\. E\. Centofanti, C\. Price, S\. Nikayin, C\. J\. Misak, P\. D\. Flood, K\. Kiedrowski, and W\. Alhazzani\.Clinical practice guidelines for the prevention and management of pain, agitation/sedation, delirium, immobility, and sleep disruption in adult patients in the ICU\.*Critical Care Medicine*, 46\(9\):e825–e873, 2018\.doi:10\.1097/CCM\.0000000000003299\.URL[https://doi\.org/10\.1097/CCM\.0000000000003299](https://doi.org/10.1097/CCM.0000000000003299)\.
- \[23\]B\. Efron and R\. J\. Tibshirani\.*An Introduction to the Bootstrap*\.Number 57 in Monographs on Statistics and Applied Probability\. Chapman & Hall, New York, 1993\.ISBN 9780412042317\.
- \[24\]M\. D\. Ernst\.Permutation methods: A basis for exact inference\.*Statistical Science*, 19\(4\):676–685, 2004\.doi:10\.1214/088342304000000396\.URL[https://doi\.org/10\.1214/088342304000000396](https://doi.org/10.1214/088342304000000396)\.
- \[25\]L\. Evans, A\. Rhodes, W\. Alhazzani, M\. Antonelli, C\. M\. Coopersmith, C\. French, F\. R\. Machado, L\. Mcintyre, M\. Ostermann, H\. C\. Prescott, C\. Schorr, S\. Simpson, W\. J\. Wiersinga, F\. Alshamsi, D\. C\. Angus, Y\. Arabi, L\. Azevedo, R\. Beale, G\. Beilman, E\. Belley\-Cote, L\. Burry, M\. Cecconi, J\. Centofanti, A\. Coz Yataco, J\. De Waele, R\. P\. Dellinger, K\. Doi, B\. Du, E\. Estenssoro, R\. Ferrer, C\. Gomersall, C\. Hodgson, M\. Hylander Møller, T\. Iwashyna, S\. Jacob, R\. Kleinpell, M\. Klompas, Y\. Koh, A\. Kumar, A\. Kwizera, S\. Lobo, H\. Masur, S\. McGloughlin, S\. Mehta, Y\. Mehta, M\. Mer, M\. Nunnally, S\. Oczkowski, T\. Osborn, E\. Papathanassoglou, A\. Perner, M\. Puskarich, J\. Roberts, W\. Schweickert, M\. Seckel, J\. Sevransky, C\. L\. Sprung, T\. Welte, J\. Zimmerman, and M\. Levy\.Surviving Sepsis Campaign: International guidelines for management of sepsis and septic shock 2021\.*Critical Care Medicine*, 49\(11\):e1063–e1143, 2021\.doi:10\.1097/CCM\.0000000000005337\.URL[https://doi\.org/10\.1097/CCM\.0000000000005337](https://doi.org/10.1097/CCM.0000000000005337)\.
- \[26\]C\. A\. Field and A\. H\. Welsh\.Bootstrapping clustered data\.*Journal of the Royal Statistical Society Series B: Statistical Methodology*, 69\(3\):369–390, 2007\.doi:10\.1111/j\.1467\-9868\.2007\.00593\.x\.URL[https://doi\.org/10\.1111/j\.1467\-9868\.2007\.00593\.x](https://doi.org/10.1111/j.1467-9868.2007.00593.x)\.
- \[27\]E\. C\. Goligher, B\. P\. Kavanagh, G\. D\. Rubenfeld, N\. K\. J\. Adhikari, R\. Pinto, E\. Fan, L\. J\. Brochard, J\. T\. Granton, A\. Mercat, J\.\-C\. Marie Richard, J\.\-M\. Chretien, G\. L\. Jones, D\. J\. Cook, T\. E\. Stewart, A\. S\. Slutsky, M\. O\. Meade, and N\. D\. Ferguson\.Oxygenation response to positive end\-expiratory pressure predicts mortality in acute respiratory distress syndrome\. a secondary analysis of the LOVS and ExPress trials\.*American Journal of Respiratory and Critical Care Medicine*, 190\(1\):70–76, 2014\.doi:10\.1164/rccm\.201404\-0688OC\.URL[https://doi\.org/10\.1164/rccm\.201404\-0688OC](https://doi.org/10.1164/rccm.201404-0688OC)\.
- \[28\]L\. Grinsztajn, E\. Oyallon, and G\. Varoquaux\.Why do tree\-based models still outperform deep learning on typical tabular data?In*Advances in Neural Information Processing Systems*, volume 35, pages 507–520\. Curran Associates, Inc\., 2022\.doi:10\.52202/068431\-0037\.URL[https://proceedings\.neurips\.cc/paper\_files/paper/2022/hash/0378c7692da36807bdec87ab043cdadc\-Abstract\-Datasets\_and\_Benchmarks\.html](https://proceedings.neurips.cc/paper_files/paper/2022/hash/0378c7692da36807bdec87ab043cdadc-Abstract-Datasets_and_Benchmarks.html)\.Datasets and Benchmarks Track\.
- \[29\]C\. Guo, G\. Pleiss, Y\. Sun, and K\. Q\. Weinberger\.On calibration of modern neural networks\.In*Proceedings of the 34th International Conference on Machine Learning*, volume 70 of*Proceedings of Machine Learning Research*, pages 1321–1330\. PMLR, 2017\.URL[https://proceedings\.mlr\.press/v70/guo17a\.html](https://proceedings.mlr.press/v70/guo17a.html)\.
- \[30\]H\. Harutyunyan, H\. Khachatrian, D\. C\. Kale, G\. Ver Steeg, and A\. Galstyan\.Multitask learning and benchmarking with clinical time series data\.*Scientific Data*, 6\(1\):96, 2019\.doi:10\.1038/s41597\-019\-0103\-9\.URL[https://doi\.org/10\.1038/s41597\-019\-0103\-9](https://doi.org/10.1038/s41597-019-0103-9)\.
- \[31\]Healthcare Cost and Utilization Project \(HCUP\)\.Clinical Classifications Software Refined \(CCSR\) for ICD\-10\-CM Diagnoses, v2026\.1\.Agency for Healthcare Research and Quality, Rockville, MD, 2025\.URL[https://hcup\-us\.ahrq\.gov/toolssoftware/ccsr/ccsr\_archive\.jsp](https://hcup-us.ahrq.gov/toolssoftware/ccsr/ccsr_archive.jsp)\.Version v2026\.1 \(fiscal year 2026\), released 19 November 2025; valid for ICD\-10\-CM diagnosis codes through September 2026\. Accessed 10 November 2026\.
- \[32\]M\. A\. Hernán and J\. M\. Robins\.Using big data to emulate a target trial when a randomized trial is not available\.*American Journal of Epidemiology*, 183\(8\):758–764, 2016\.doi:10\.1093/aje/kwv254\.URL[https://doi\.org/10\.1093/aje/kwv254](https://doi.org/10.1093/aje/kwv254)\.
- \[33\]M\. A\. Hernán and J\. M\. Robins\.*Causal Inference: What If*\.Chapman & Hall/CRC, Boca Raton, 2020\.URL[https://miguelhernan\.org/whatifbook](https://miguelhernan.org/whatifbook)\.Online edition, version of 19 August 2026\.
- \[34\]J\. Hoffmann, S\. Borgeaud, A\. Mensch, E\. Buchatskaya, T\. Cai, E\. Rutherford, D\. de Las Casas, L\. A\. Hendricks, J\. Welbl, A\. Clark, T\. Hennigan, E\. Noland, K\. Millican, G\. van den Driessche, B\. Damoc, A\. Guy, S\. Osindero, K\. Simonyan, E\. Elsen, O\. Vinyals, J\. W\. Rae, and L\. Sifre\.Training compute\-optimal large language models\.In*Advances in Neural Information Processing Systems*, volume 35, pages 30016–30030\. Curran Associates, Inc\., 2022\.doi:10\.52202/068431\-2176\.URL[https://proceedings\.neurips\.cc/paper\_files/paper/2022/hash/c1e2faff6f588870935f114ebe04a3e5\-Abstract\-Conference\.html](https://proceedings.neurips.cc/paper_files/paper/2022/hash/c1e2faff6f588870935f114ebe04a3e5-Abstract-Conference.html)\.
- \[35\]S\. Holm\.A simple sequentially rejective multiple test procedure\.*Scandinavian Journal of Statistics*, 6\(2\):65–70, 1979\.
- \[36\]E\. A\. J\. Hoste, S\. M\. Bagshaw, R\. Bellomo, C\. M\. Cely, R\. Colman, D\. N\. Cruz, K\. Edipidis, L\. G\. Forni, C\. D\. Gomersall, D\. Govil, P\. M\. Honoré, O\. Joannes\-Boyau, M\. Joannidis, A\.\-M\. Korhonen, A\. Lavrentieva, R\. L\. Mehta, P\. Palevsky, E\. Roessler, C\. Ronco, S\. Uchino, J\. A\. Vazquez, E\. Vidal Andrade, S\. Webb, and J\. A\. Kellum\.Epidemiology of acute kidney injury in critically ill patients: the multinational AKI\-EPI study\.*Intensive Care Medicine*, 41\(8\):1411–1423, 2015\.doi:10\.1007/s00134\-015\-3934\-7\.URL[https://doi\.org/10\.1007/s00134\-015\-3934\-7](https://doi.org/10.1007/s00134-015-3934-7)\.
- \[37\]C\. G\. Hughes, S\. McGrane, and P\. P\. Pandharipande\.Sedation in the intensive care setting\.*Clinical Pharmacology: Advances and Applications*, 4:53–63, 2012\.doi:10\.2147/CPAA\.S26582\.URL[https://doi\.org/10\.2147/CPAA\.S26582](https://doi.org/10.2147/CPAA.S26582)\.
- \[38\]A\. E\. W\. Johnson, L\. Bulgarelli, L\. Shen, A\. Gayles, A\. Shammout, S\. Horng, T\. J\. Pollard, S\. Hao, B\. Moody, B\. Gow, L\.\-w\. H\. Lehman, L\. A\. Celi, and R\. G\. Mark\.MIMIC\-IV, a freely accessible electronic health record dataset\.*Scientific Data*, 10\(1\):1, 2023\.doi:10\.1038/s41597\-022\-01899\-x\.URL[https://doi\.org/10\.1038/s41597\-022\-01899\-x](https://doi.org/10.1038/s41597-022-01899-x)\.
- \[39\]B\. Jung, T\. Rimmele, C\. Le Goff, G\. Chanques, P\. Corne, O\. Jonquet, L\. Muller, J\.\-Y\. Lefrant, C\. Guervilly, L\. Papazian, B\. Allaouchiche, S\. Jaber, and AzuRea Group\.Severe metabolic or mixed acidemia on intensive care unit admission: incidence, prognosis and administration of buffer therapy\. A prospective, multiple\-center study\.*Critical Care*, 15\(5\):R238, 2011\.doi:10\.1186/cc10487\.URL[https://doi\.org/10\.1186/cc10487](https://doi.org/10.1186/cc10487)\.
- \[40\]J\. Kaplan, S\. McCandlish, T\. Henighan, T\. B\. Brown, B\. Chess, R\. Child, S\. Gray, A\. Radford, J\. Wu, and D\. Amodei\.Scaling laws for neural language models\.arXiv preprint arXiv:2001\.08361, 2020\.URL[https://arxiv\.org/abs/2001\.08361](https://arxiv.org/abs/2001.08361)\.Version 1, 23 January 2020\.
- \[41\]G\. Ke, Q\. Meng, T\. Finley, T\. Wang, W\. Chen, W\. Ma, Q\. Ye, and T\.\-Y\. Liu\.LightGBM: A highly efficient gradient boosting decision tree\.In*Advances in Neural Information Processing Systems*, volume 30, pages 3146–3154\. Curran Associates, Inc\., 2017\.URL[https://proceedings\.neurips\.cc/paper\_files/paper/2017/hash/6449f44a102fde848669bdd9eb6b76fa\-Abstract\.html](https://proceedings.neurips.cc/paper_files/paper/2017/hash/6449f44a102fde848669bdd9eb6b76fa-Abstract.html)\.
- \[42\]Kidney Disease: Improving Global Outcomes \(KDIGO\) Acute Kidney Injury Work Group\.KDIGO clinical practice guideline for acute kidney injury\.*Kidney International Supplements*, 2\(1\):1–138, 2012\.URL[https://kdigo\.org/wp\-content/uploads/2016/10/KDIGO\-2012\-AKI\-Guideline\-English\.pdf](https://kdigo.org/wp-content/uploads/2016/10/KDIGO-2012-AKI-Guideline-English.pdf)\.
- \[43\]K\. Kim, S\. Kotha, P\. Liang, and T\. Hashimoto\.Pre\-training under infinite compute\.In*International Conference on Learning Representations \(ICLR\)*, pages 74596–74636, 2026\.URL[https://openreview\.net/forum?id=ck0aZTAnwK](https://openreview.net/forum?id=ck0aZTAnwK)\.
- \[44\]Z\. Kraljevic, D\. Bean, A\. Shek, R\. Bendayan, H\. Hemingway, J\. A\. Yeung, A\. Deng, A\. Baston, J\. Ross, E\. Idowu, J\. T\. Teo, and R\. J\. B\. Dobson\.Foresight—a generative pretrained transformer for modelling of patient timelines using electronic health records: a retrospective modelling study\.*The Lancet Digital Health*, 6\(4\):e281–e290, 2024\.doi:10\.1016/S2589\-7500\(24\)00025\-6\.URL[https://doi\.org/10\.1016/S2589\-7500\(24\)00025\-6](https://doi.org/10.1016/S2589-7500(24)00025-6)\.
- \[45\]R\. G\. Krishnan, U\. Shalit, and D\. Sontag\.Deep Kalman filters\.arXiv preprint arXiv:1511\.05121, 2015\.URL[https://arxiv\.org/abs/1511\.05121](https://arxiv.org/abs/1511.05121)\.Version 2, 25 November 2015\.
- \[46\]R\. G\. Krishnan, U\. Shalit, and D\. Sontag\.Structured inference networks for nonlinear state space models\.In*Proceedings of the AAAI Conference on Artificial Intelligence*, volume 31, pages 2101–2109\. AAAI Press, 2017\.doi:10\.1609/aaai\.v31i1\.10779\.URL[https://ojs\.aaai\.org/index\.php/AAAI/article/view/10779](https://ojs.aaai.org/index.php/AAAI/article/view/10779)\.
- \[47\]S\. R\. Künzel, J\. S\. Sekhon, P\. J\. Bickel, and B\. Yu\.Metalearners for estimating heterogeneous treatment effects using machine learning\.*Proceedings of the National Academy of Sciences*, 116\(10\):4156–4165, 2019\.doi:10\.1073/pnas\.1804597116\.URL[https://doi\.org/10\.1073/pnas\.1804597116](https://doi.org/10.1073/pnas.1804597116)\.
- \[48\]F\. M\. Kusumoto, M\. H\. Schoenfeld, C\. Barrett, J\. R\. Edgerton, K\. A\. Ellenbogen, M\. R\. Gold, N\. F\. Goldschlager, R\. M\. Hamilton, J\. A\. Joglar, R\. J\. Kim, R\. Lee, J\. E\. Marine, C\. J\. McLeod, K\. R\. Oken, K\. K\. Patton, C\. N\. Pellegrini, K\. A\. Selzman, A\. Thompson, and P\. D\. Varosy\.2018 ACC/AHA/HRS guideline on the evaluation and management of patients with bradycardia and cardiac conduction delay: A report of the American College of Cardiology/American Heart Association Task Force on Clinical Practice Guidelines and the Heart Rhythm Society\.*Circulation*, 140\(8\):e382–e482, 2019\.doi:10\.1161/CIR\.0000000000000628\.URL[https://doi\.org/10\.1161/CIR\.0000000000000628](https://doi.org/10.1161/CIR.0000000000000628)\.
- \[49\]D\. N\. Kyriacou and R\. J\. Lewis\.Confounding by indication in clinical research\.*JAMA*, 316\(17\):1818–1819, 2016\.doi:10\.1001/jama\.2016\.16435\.URL[https://doi\.org/10\.1001/jama\.2016\.16435](https://doi.org/10.1001/jama.2016.16435)\.
- \[50\]Y\. LeCun\.A path towards autonomous machine intelligence\.OpenReview, 2022\.URL[https://openreview\.net/forum?id=BZ5a1r\-kVsf](https://openreview.net/forum?id=BZ5a1r-kVsf)\.Version 0\.9\.2, 27 June 2022\.
- \[51\]I\. Lee, L\. Solo, M\. C\. Burkhart, B\. Ramadan, S\. Sethi, S\. Jabbour, W\. F\. Parker, and B\. K\. Beaulieu\-Jones\.Representation before training: A practical benchmark for generative medical event model tokenization\.arXiv preprint arXiv:2604\.16775, 2026\.URL[https://arxiv\.org/abs/2604\.16775](https://arxiv.org/abs/2604.16775)\.Version 3, 18 September 2026; version 1 was titled “Representation Before Training: A Fixed\-Budget Benchmark for Generative Medical Event Models”\.
- \[52\]R\. Li, S\. Hu, M\. Lu, Y\. Utsumi, P\. Chakraborty, D\. M\. Sow, P\. Madan, M\. Ghalwash, Z\. Shahn, and L\.\-w\. H\. Lehman\.G\-Net: a recurrent network approach to G\-computation for counterfactual prediction under a dynamic treatment regime\.In*Proceedings of Machine Learning for Health*, volume 158 of*Proceedings of Machine Learning Research*, pages 282–299\. PMLR, 2021\.URL[https://proceedings\.mlr\.press/v158/li21a\.html](https://proceedings.mlr.press/v158/li21a.html)\.
- \[53\]M\. Lipsitch, E\. Tchetgen Tchetgen, and T\. Cohen\.Negative controls: A tool for detecting confounding and bias in observational studies\.*Epidemiology*, 21\(3\):383–388, 2010\.doi:10\.1097/EDE\.0b013e3181d61eeb\.URL[https://doi\.org/10\.1097/EDE\.0b013e3181d61eeb](https://doi.org/10.1097/EDE.0b013e3181d61eeb)\.
- \[54\]Y\. Liu, J\. Placidi, J\. Han, A\. J\. Balston, M\. Rei, and A\. A\. Faisal\.Autoregressive EHR foundation models with multimodal inputs\.arXiv preprint arXiv:2607\.22264, 2026\.URL[https://arxiv\.org/abs/2607\.22264](https://arxiv.org/abs/2607.22264)\.Version 1, 24 July 2026; presented at the ICML 2026 Workshop on Structured Data for Health \(non\-archival\)\.
- \[55\]I\. Loshchilov and F\. Hutter\.Decoupled weight decay regularization\.In*International Conference on Learning Representations \(ICLR\)*, 2019\.URL[https://openreview\.net/forum?id=Bkg6RiCqY7](https://openreview.net/forum?id=Bkg6RiCqY7)\.
- \[56\]G\. Lutsker, G\. Sapir, J\. Merino, S\. Shilo, A\. Godneva, E\. Meirom, S\. Mannor, H\. Rossman, G\. Chechik, and E\. Segal\.Simulating clinical interventions with a generative multimodal model of human physiology\.arXiv preprint arXiv:2604\.27899, 2026\.URL[https://arxiv\.org/abs/2604\.27899](https://arxiv.org/abs/2604.27899)\.Version 1, 30 April 2026\.
- \[57\]N\. Makarov, M\. Bordukova, P\. Quengdaeng, D\. Garger, R\. Rodriguez\-Esteban, F\. Schmich, and M\. P\. Menden\.Large language models forecast patient health trajectories enabling digital twins\.*npj Digital Medicine*, 8\(1\):588, 2025\.doi:10\.1038/s41746\-025\-02004\-3\.URL[https://doi\.org/10\.1038/s41746\-025\-02004\-3](https://doi.org/10.1038/s41746-025-02004-3)\.
- \[58\]M\. A\. Matthay, Y\. Arabi, A\. C\. Arroliga, G\. Bernard, A\. D\. Bersten, L\. J\. Brochard, C\. S\. Calfee, A\. Combes, B\. M\. Daniel, N\. D\. Ferguson, M\. N\. Gong, J\. E\. Gotts, M\. S\. Herridge, J\. G\. Laffey, K\. D\. Liu, F\. R\. Machado, T\. R\. Martin, D\. F\. McAuley, A\. Mercat, M\. Moss, R\. A\. Mularski, A\. Pesenti, H\. Qiu, N\. Ramakrishnan, V\. M\. Ranieri, E\. D\. Riviello, E\. Rubin, A\. S\. Slutsky, B\. T\. Thompson, T\. Twagirumugabe, L\. B\. Ware, and K\. D\. Wick\.A new global definition of acute respiratory distress syndrome\.*American Journal of Respiratory and Critical Care Medicine*, 209\(1\):37–47, 2024\.doi:10\.1164/rccm\.202303\-0558WS\.URL[https://doi\.org/10\.1164/rccm\.202303\-0558WS](https://doi.org/10.1164/rccm.202303-0558WS)\.
- \[59\]K\. A\. McCann, I\. Shin, H\. Li, D\. White, E\. R\. Melnick, M\. Iscoe, and A\. J\. Loza\.Continuous value tokenization improves medical event foundation models\.medRxiv preprint, 2026\.URL[https://doi\.org/10\.64898/2026\.08\.04\.26359713](https://doi.org/10.64898/2026.08.04.26359713)\.Version 1, posted 6 August 2026\.
- \[60\]M\. B\. A\. McDermott, E\. Steinberg, J\. A\. Fries, R\. P\. van de Water, C\. Pang, P\. Rockenschaub, P\. Renc, J\. Oh, K\. Stankevičiūtė, J\. Xu, T\. J\. Pollard, N\. Oufattole, M\. Wornow, T\. S\. Bergamaschi, H\. Jeong, S\. A\. Lee, V\. Jeanselme, K\. V\. Klein, M\. Odgaard, M\. E\. Montgomery, A\. Sitek, M\. Nielsen, J\. N\. Chiang, N\. Dagan, I\. Kohane, S\. Joshi, E\. Choi, and N\. H\. Shah\.MEDS — an emerging data standard and ecosystem for health AI research\.*NEJM AI*, 3\(6\), 2026\.doi:10\.1056/AIra2501253\.URL[https://doi\.org/10\.1056/AIra2501253](https://doi.org/10.1056/AIra2501253)\.
- \[61\]Q\. McNemar\.Note on the sampling error of the difference between correlated proportions or percentages\.*Psychometrika*, 12\(2\):153–157, 1947\.doi:10\.1007/BF02295996\.URL[https://doi\.org/10\.1007/BF02295996](https://doi.org/10.1007/BF02295996)\.
- \[62\]V\. Melnychuk, D\. Frauen, and S\. Feuerriegel\.Causal Transformer for estimating counterfactual outcomes\.In*Proceedings of the 39th International Conference on Machine Learning*, volume 162 of*Proceedings of Machine Learning Research*, pages 15293–15329\. PMLR, 2022\.URL[https://proceedings\.mlr\.press/v162/melnychuk22a\.html](https://proceedings.mlr.press/v162/melnychuk22a.html)\.
- \[63\]O\. S\. Miettinen\.The need for randomization in the study of intended effects\.*Statistics in Medicine*, 2\(2\):267–271, 1983\.doi:10\.1002/sim\.4780020222\.URL[https://doi\.org/10\.1002/sim\.4780020222](https://doi.org/10.1002/sim.4780020222)\.
- \[64\]M\. E\. Montgomery, C\. Igel, M\. Odgaard, M\. Sillesen, and M\. Nielsen\.How should transformers encode numeric values in electronic health records?In*Proceedings of the 43rd International Conference on Machine Learning*, volume 306 of*Proceedings of Machine Learning Research*, pages 90118–90133\. PMLR, 2026\.URL[https://proceedings\.mlr\.press/v306/montgomery26a\.html](https://proceedings.mlr.press/v306/montgomery26a.html)\.
- \[65\]N\. Muennighoff, A\. M\. Rush, B\. Barak, T\. Le Scao, A\. Piktus, N\. Tazi, S\. Pyysalo, T\. Wolf, and C\. Raffel\.Scaling data\-constrained language models\.In*Advances in Neural Information Processing Systems*, volume 36, pages 50358–50376\. Curran Associates, Inc\., 2023\.doi:10\.52202/075280\-2191\.URL[https://proceedings\.neurips\.cc/paper\_files/paper/2023/hash/9d89448b63ce1e2e8dc7af72c984c196\-Abstract\-Conference\.html](https://proceedings.neurips.cc/paper_files/paper/2023/hash/9d89448b63ce1e2e8dc7af72c984c196-Abstract-Conference.html)\.
- \[66\]National Academies of Sciences, Engineering, and Medicine\.*Foundational Research Gaps and Future Directions for Digital Twins*\.The National Academies Press, Washington, DC, 2024\.ISBN 9780309700429\.doi:10\.17226/26894\.URL[https://doi\.org/10\.17226/26894](https://doi.org/10.17226/26894)\.
- \[67\]National Heart, Lung, and Blood Institute PETAL Clinical Trials Network\.Early neuromuscular blockade in the acute respiratory distress syndrome\.*New England Journal of Medicine*, 380\(21\):1997–2008, 2019\.doi:10\.1056/NEJMoa1901686\.URL[https://doi\.org/10\.1056/NEJMoa1901686](https://doi.org/10.1056/NEJMoa1901686)\.
- \[68\]N\. Oufattole, T\. Bergamaschi, A\. Kolo, H\. Jeong, H\. Gaggin, C\. M\. Stultz, and M\. B\. A\. McDermott\.MEDS\-Tab: Automated tabularization and baseline methods for MEDS datasets\.arXiv preprint arXiv:2411\.00200, 2024\.URL[https://arxiv\.org/abs/2411\.00200](https://arxiv.org/abs/2411.00200)\.Version 1, 31 October 2024\.
- \[69\]C\. Pang, J\. Park, X\. Jiang, N\. P\. Pavinkurve, K\. S\. Kalluri, S\. Joshi, N\. Elhadad, and K\. Natarajan\.CEHR\-XGPT: A scalable multi\-task foundation model for electronic health records\.arXiv preprint arXiv:2509\.03643, 2025\.URL[https://arxiv\.org/abs/2509\.03643](https://arxiv.org/abs/2509.03643)\.Version 2, 5 September 2025; version 1 was titled “CEHR\-GPT: A Scalable Multi\-Task Foundation Model for Electronic Health Records”\.
- \[70\]F\. Pedregosa, G\. Varoquaux, A\. Gramfort, V\. Michel, B\. Thirion, O\. Grisel, M\. Blondel, P\. Prettenhofer, R\. Weiss, V\. Dubourg, J\. Vanderplas, A\. Passos, D\. Cournapeau, M\. Brucher, M\. Perrot, and É\. Duchesnay\.Scikit\-learn: Machine learning in Python\.*Journal of Machine Learning Research*, 12\(85\):2825–2830, 2011\.URL[https://jmlr\.org/papers/v12/pedregosa11a\.html](https://jmlr.org/papers/v12/pedregosa11a.html)\.
- \[71\]J\. Pickard, W\. Qi, N\. Li, A\. Woolley, L\. Cosimi, R\. Kishony, and D\. Hung\.EHR\-MPC: Inference\-time control for sepsis treatment with generative patient digital twins\.In*Proceedings of the 11th Machine Learning for Healthcare Conference*, volume 340 of*Proceedings of Machine Learning Research*, pages 1488–1516\. PMLR, 2026\.URL[https://proceedings\.mlr\.press/v340/pickard26a\.html](https://proceedings.mlr.press/v340/pickard26a.html)\.
- \[72\]T\. J\. Pollard, A\. E\. W\. Johnson, J\. D\. Raffa, L\. A\. Celi, R\. G\. Mark, and O\. Badawi\.The eICU Collaborative Research Database, a freely available multi\-center database for critical care research\.*Scientific Data*, 5\(1\):180178, 2018\.doi:10\.1038/sdata\.2018\.178\.URL[https://doi\.org/10\.1038/sdata\.2018\.178](https://doi.org/10.1038/sdata.2018.178)\.
- \[73\]O\. Press and L\. Wolf\.Using the output embedding to improve language models\.In*Proceedings of the 15th Conference of the European Chapter of the Association for Computational Linguistics: Volume 2, Short Papers*, pages 157–163, Valencia, Spain, 2017\. Association for Computational Linguistics\.doi:10\.18653/v1/E17\-2025\.URL[https://aclanthology\.org/E17\-2025/](https://aclanthology.org/E17-2025/)\.
- \[74\]RECOVERY Collaborative Group\.Dexamethasone in hospitalized patients with Covid\-19\.*New England Journal of Medicine*, 384\(8\):693–704, 2021\.doi:10\.1056/NEJMoa2021436\.URL[https://doi\.org/10\.1056/NEJMoa2021436](https://doi.org/10.1056/NEJMoa2021436)\.
- \[75\]P\. Renc, Y\. Jia, A\. E\. Samir, J\. Was, Q\. Li, D\. W\. Bates, and A\. Sitek\.Zero shot health trajectory prediction using transformer\.*npj Digital Medicine*, 7\(1\):256, 2024\.doi:10\.1038/s41746\-024\-01235\-0\.URL[https://doi\.org/10\.1038/s41746\-024\-01235\-0](https://doi.org/10.1038/s41746-024-01235-0)\.
- \[76\]P\. Renc, M\. K\. Grzeszczyk, N\. Oufattole, D\. Goode, Y\. Jia, S\. Bieganski, M\. B\. A\. McDermott, J\. Was, A\. E\. Samir, J\. W\. Cunningham, D\. W\. Bates, and A\. Sitek\.Foundation model of electronic medical records for adaptive risk estimation\.*GigaScience*, 14:giaf107, 2025\.doi:10\.1093/gigascience/giaf107\.URL[https://doi\.org/10\.1093/gigascience/giaf107](https://doi.org/10.1093/gigascience/giaf107)\.
- \[77\]J\. Robins\.A new approach to causal inference in mortality studies with a sustained exposure period—application to control of the healthy worker survivor effect\.*Mathematical Modelling*, 7\(9–12\):1393–1512, 1986\.doi:10\.1016/0270\-0255\(86\)90088\-6\.URL[https://doi\.org/10\.1016/0270\-0255\(86\)90088\-6](https://doi.org/10.1016/0270-0255(86)90088-6)\.
- \[78\]C\. Sainsbury, F\. Dong, and A\. Karwath\.FlatASCEND: Autoregressive clinical sequence generation with continuous time prediction and association\-based pharmacological testing\.arXiv preprint arXiv:2605\.04071, 2026\.URL[https://arxiv\.org/abs/2605\.04071](https://arxiv.org/abs/2605.04071)\.Version 1, 13 April 2026\.
- \[79\]N\. Shazeer\.GLU variants improve Transformer\.arXiv preprint arXiv:2002\.05202, 2020\.URL[https://arxiv\.org/abs/2002\.05202](https://arxiv.org/abs/2002.05202)\.
- \[80\]A\. Shmatko, A\. W\. Jung, K\. Gaurav, S\. Brunak, L\. H\. Mortensen, E\. Birney, T\. Fitzgerald, and M\. Gerstung\.Learning the natural history of human disease with generative transformers\.*Nature*, 647\(8088\):248–256, 2025\.doi:10\.1038/s41586\-025\-09529\-3\.URL[https://doi\.org/10\.1038/s41586\-025\-09529\-3](https://doi.org/10.1038/s41586-025-09529-3)\.
- \[81\]M\. Singer, C\. S\. Deutschman, C\. W\. Seymour, M\. Shankar\-Hari, D\. Annane, M\. Bauer, R\. Bellomo, G\. R\. Bernard, J\.\-D\. Chiche, C\. M\. Coopersmith, R\. S\. Hotchkiss, M\. M\. Levy, J\. C\. Marshall, G\. S\. Martin, S\. M\. Opal, G\. D\. Rubenfeld, T\. van der Poll, J\.\-L\. Vincent, and D\. C\. Angus\.The third international consensus definitions for sepsis and septic shock \(Sepsis\-3\)\.*JAMA*, 315\(8\):801–810, 2016\.doi:10\.1001/jama\.2016\.0287\.URL[https://doi\.org/10\.1001/jama\.2016\.0287](https://doi.org/10.1001/jama.2016.0287)\.
- \[82\]C\. Snell, J\. Lee, K\. Xu, and A\. Kumar\.Scaling LLM test\-time compute optimally can be more effective than scaling parameters for reasoning\.In*International Conference on Learning Representations \(ICLR\)*, pages 10131–10165, 2025\.URL[https://openreview\.net/forum?id=4FWAwZtd2n](https://openreview.net/forum?id=4FWAwZtd2n)\.
- \[83\]L\. Solo, M\. B\. A\. McDermott, W\. F\. Parker, B\. Ramadan, M\. C\. Burkhart, and B\. K\. Beaulieu\-Jones\.Efficient generative prediction for EHR foundation models: The SCOPE and REACH estimators\.arXiv preprint arXiv:2602\.03730, 2026\.URL[https://arxiv\.org/abs/2602\.03730](https://arxiv.org/abs/2602.03730)\.Version 2, 12 May 2026\.
- \[84\]E\. Steinberg, K\. Jung, J\. A\. Fries, C\. K\. Corbin, S\. R\. Pfohl, and N\. H\. Shah\.Language models are an effective representation learning technique for electronic health record data\.*Journal of Biomedical Informatics*, 113:103637, 2021\.doi:10\.1016/j\.jbi\.2020\.103637\.URL[https://doi\.org/10\.1016/j\.jbi\.2020\.103637](https://doi.org/10.1016/j.jbi.2020.103637)\.
- \[85\]E\. Steinberg, J\. A\. Fries, Y\. Xu, and N\. H\. Shah\.MOTOR: A time\-to\-event foundation model for structured medical records\.In*International Conference on Learning Representations \(ICLR\)*, pages 41038–41077, 2024\.URL[https://openreview\.net/forum?id=NialiwI2V6](https://openreview.net/forum?id=NialiwI2V6)\.
- \[86\]E\. Stutz, G\. Marino, D\. Meeker, Q\. Liu, and A\. J\. Loza\.Conditional attribute estimation with autoregressive sequence models\.arXiv preprint arXiv:2605\.14004, 2026\.URL[https://arxiv\.org/abs/2605\.14004](https://arxiv.org/abs/2605.14004)\.Version 1, 13 May 2026\.
- \[87\]J\. Su, M\. Ahmed, Y\. Lu, S\. Pan, W\. Bo, and Y\. Liu\.RoFormer: Enhanced transformer with Rotary Position Embedding\.*Neurocomputing*, 568:127063, 2024\.doi:10\.1016/j\.neucom\.2023\.127063\.URL[https://doi\.org/10\.1016/j\.neucom\.2023\.127063](https://doi.org/10.1016/j.neucom.2023.127063)\.
- \[88\]R\. van de Water, H\. Schmidt, P\. Elbers, P\. Thoral, B\. Arnrich, and P\. Rockenschaub\.Yet another ICU benchmark: A flexible multi\-center framework for clinical ML\.In*International Conference on Learning Representations \(ICLR\)*, pages 44638–44693, 2024\.URL[https://openreview\.net/forum?id=ox2ATRM90I](https://openreview.net/forum?id=ox2ATRM90I)\.
- \[89\]J\. P\. Vandenbroucke\.When are observational studies as credible as randomised trials?*The Lancet*, 363\(9422\):1728–1731, 2004\.doi:10\.1016/S0140\-6736\(04\)16261\-2\.URL[https://doi\.org/10\.1016/S0140\-6736\(04\)16261\-2](https://doi.org/10.1016/S0140-6736(04)16261-2)\.
- \[90\]A\. Vaswani, N\. Shazeer, N\. Parmar, J\. Uszkoreit, L\. Jones, A\. N\. Gomez, Ł\. Kaiser, and I\. Polosukhin\.Attention is all you need\.In*Advances in Neural Information Processing Systems*, volume 30, pages 5998–6008\. Curran Associates, Inc\., 2017\.URL[https://proceedings\.neurips\.cc/paper\_files/paper/2017/hash/3f5ee243547dee91fbd053c1c4a845aa\-Abstract\.html](https://proceedings.neurips.cc/paper_files/paper/2017/hash/3f5ee243547dee91fbd053c1c4a845aa-Abstract.html)\.
- \[91\]A\. J\. Vickers and E\. B\. Elkin\.Decision curve analysis: A novel method for evaluating prediction models\.*Medical Decision Making*, 26\(6\):565–574, 2006\.doi:10\.1177/0272989X06295361\.URL[https://doi\.org/10\.1177/0272989X06295361](https://doi.org/10.1177/0272989X06295361)\.
- \[92\]S\. V\. Wang, S\. Schneeweiss, and RCT\-DUPLICATE Initiative\.Emulation of randomized clinical trials with nonrandomized database analyses: Results of 32 clinical trials\.*JAMA*, 329\(16\):1376–1385, 2023\.doi:10\.1001/jama\.2023\.4221\.URL[https://doi\.org/10\.1001/jama\.2023\.4221](https://doi.org/10.1001/jama.2023.4221)\.
- \[93\]S\. Waxler, P\. Blazek, D\. White, D\. Sneider, K\. Chung, M\. Nagarathnam, P\. Williams, H\. Voeller, K\. Wong, M\. Swanhorst, S\. Zhang, N\. Usuyama, C\. Wong, T\. Naumann, H\. Poon, A\. Loza, D\. Meeker, S\. Hain, and R\. Shah\.Generative medical event models improve with scale\.arXiv preprint arXiv:2508\.12104, 2025\.URL[https://arxiv\.org/abs/2508\.12104](https://arxiv.org/abs/2508.12104)\.Version 3, 7 November 2025\.
- \[94\]WHO Collaborating Centre for Drug Statistics Methodology\.ATC/DDD index 2026\.Norwegian Institute of Public Health, Oslo, Norway, 2026\.URL[https://atcddd\.fhi\.no/atc\_ddd\_index/](https://atcddd.fhi.no/atc_ddd_index/)\.Last updated 20 January 2026\. Accessed 10 November 2026\.
- \[95\]M\. Wornow, R\. Thapa, E\. Steinberg, J\. A\. Fries, and N\. H\. Shah\.EHRSHOT: An EHR benchmark for few\-shot evaluation of foundation models\.In*Advances in Neural Information Processing Systems*, volume 36, pages 67125–67137\. Curran Associates, Inc\., 2023\.doi:10\.52202/075280\-2933\.URL[https://proceedings\.neurips\.cc/paper\_files/paper/2023/hash/d42db1f74df54cb992b3956eb7f15a6f\-Abstract\-Datasets\_and\_Benchmarks\.html](https://proceedings.neurips.cc/paper_files/paper/2023/hash/d42db1f74df54cb992b3956eb7f15a6f-Abstract-Datasets_and_Benchmarks.html)\.Datasets and Benchmarks Track\.
- \[96\]M\. Wornow, S\. Bedi, M\. A\. Fuentes Hernandez, E\. Steinberg, J\. A\. Fries, C\. Ré, S\. Koyejo, and N\. H\. Shah\.Context clues: Evaluating long context models for clinical prediction tasks on EHRs\.In*International Conference on Learning Representations \(ICLR\)*, pages 16518–16555, 2025\.URL[https://openreview\.net/forum?id=zg3ec1TdAP](https://openreview.net/forum?id=zg3ec1TdAP)\.
- \[97\]G\. Xiao, Y\. Tian, B\. Chen, S\. Han, and M\. Lewis\.Efficient streaming language models with attention sinks\.In*International Conference on Learning Representations \(ICLR\)*, pages 21875–21895, 2024\.URL[https://openreview\.net/forum?id=NG7sS51zVF](https://openreview.net/forum?id=NG7sS51zVF)\.
- \[98\]F\. Xue, Y\. Fu, W\. Zhou, Z\. Zheng, and Y\. You\.To repeat or not to repeat: Insights from scaling LLM under token\-crisis\.In*Advances in Neural Information Processing Systems*, volume 36, pages 59304–59322\. Curran Associates, Inc\., 2023\.doi:10\.52202/075280\-2590\.URL[https://proceedings\.neurips\.cc/paper\_files/paper/2023/hash/b9e472cd579c83e2f6aa3459f46aac28\-Abstract\-Conference\.html](https://proceedings.neurips.cc/paper_files/paper/2023/hash/b9e472cd579c83e2f6aa3459f46aac28-Abstract-Conference.html)\.
- \[99\]Y\. Yang, M\. Arora, R\. Zhang, B\. Abed, J\. Kim, T\. Choudhary, M\. Hassanuzzaman, K\. Zhu, A\. Ali, C\. Yang, A\. E\. Gent, V\. Moas, and R\. Kamaleswaran\.Clin\-JEPA: A multi\-phase co\-training framework for joint\-embedding predictive pretraining on EHR patient trajectories\.arXiv preprint arXiv:2605\.10840, 2026\.URL[https://arxiv\.org/abs/2605\.10840](https://arxiv.org/abs/2605.10840)\.Version 5, 16 September 2026\.
- \[100\]H\. Yèche, R\. Kuznetsova, M\. Zimmermann, M\. Hüser, X\. Lyu, M\. Faltys, and G\. Rätsch\.HiRID\-ICU\-Benchmark — a comprehensive machine learning benchmark on high\-resolution ICU data\.In*Proceedings of the Neural Information Processing Systems Track on Datasets and Benchmarks*, volume 1, 2021\.URL[https://datasets\-benchmarks\-proceedings\.neurips\.cc/paper\_files/paper/2021/hash/5878a7ab84fb43402106c575658472fa\-Abstract\-round1\.html](https://datasets-benchmarks-proceedings.neurips.cc/paper_files/paper/2021/hash/5878a7ab84fb43402106c575658472fa-Abstract-round1.html)\.
- \[101\]A\. Zhang, T\. Ding, S\. J\. Wagner, C\. Tian, M\. Y\. Lu, R\. Pettit, J\. E\. Lewis, A\. Misrahi, D\. Mo, L\. P\. Le, and F\. Mahmood\.A multimodal and temporal foundation model for virtual patient representations at healthcare system scale\.arXiv preprint arXiv:2604\.18570, 2026\.URL[https://arxiv\.org/abs/2604\.18570](https://arxiv.org/abs/2604.18570)\.Version 2, 21 April 2026\.
- \[102\]B\. Zhang and R\. Sennrich\.Root mean square layer normalization\.In*Advances in Neural Information Processing Systems*, volume 32, pages 12381–12392\. Curran Associates, Inc\., 2019\.URL[https://proceedings\.neurips\.cc/paper\_files/paper/2019/hash/1e8a19426224ca89e83cef47f1e7f53b\-Abstract\.html](https://proceedings.neurips.cc/paper_files/paper/2019/hash/1e8a19426224ca89e83cef47f1e7f53b-Abstract.html)\.
- \[103\]Y\. Zhu, A\. R\. Weckstein, K\. J\. Lin, and J\. Yang\.DT\-Transformer: A foundation model for disease trajectory prediction on a real\-world health system\.arXiv preprint arXiv:2605\.14227, 2026\.URL[https://arxiv\.org/abs/2605\.14227](https://arxiv.org/abs/2605.14227)\.Version 1, 14 May 2026\.

## Appendix ACohort

The data come from Epic Clarity through the MGB enterprise data warehouse\. An ICU stay is one record in Epic’s ICU location table \(F\_PAT\_ICU\_LOCATION\), so a transfer between two ICUs starts a new stay\.The age and year criteria apply to the start of a stay\. Because age is rounded to the year before the adult test, 293 stays \(0\.12%\) entered at an exact age between 17\.45 and 18 years\. Selection is on stays starting from 2017 to 2025, so 57 later unit admissions, all in encounters that entered the ICU in 2025, fall in 2026\. For each encounter we took events from 24 h before its first ICU admission to 24 h after its last ICU discharge, so that deterioration before the ICU and the course after it are visible\. Medications are orders, not administrations; after a name\-based rescue of uncoded medications, 96\.1% of medication\-order rows carry an ATC code\[[94](https://arxiv.org/html/2611.27028#bib.bib94)\]\. Conversion to MEDS removed 7,623,443 duplicate rows \(0\.79%\)\. The split is a deterministic hash of the patient identifier, so a re\-cut cohort keeps every patient in the same split\. Of the 236,906 ICU stays, 178,506 were still in the ICU 24 h after admission and are scored\. These are 8,947 stays in validation \(5,836 patients\) and 8,995 in test \(5,794\)\.

Table[3](https://arxiv.org/html/2611.27028#A1.T3)gives the cohort by split\. Race and ethnicity are shown as the record holds them\. A patient with several race entries has one combined value; the most common such value, “unavailable” together with “White”, is shown on its own, and the others are pooled\. A category is pooled whenever a column would show fewer than 11 patients\.

Table 3:Cohort by split, full version of Table[1](https://arxiv.org/html/2611.27028#S3.T1)\.aOne ICU unit admission in the record\.bMedian \[interquartile range\]\.cRead from ventilator\-setting markers \(App\.[B](https://arxiv.org/html/2611.27028#A2)\)\.dAge is rounded to the year before the adult test \(§[3](https://arxiv.org/html/2611.27028#S3)\)\.eEncounters that passed our collaborators’ screen for acute hypoxaemic respiratory failure\.fAs recorded; categories with fewer than 11 patients in any column are pooled\.
## Appendix BTasks

Labels are built once from the MEDS events by a registry of task definitions and shared by every method\. A task combines a template \(the first occurrence of an event; a measured value beyond a bound; a rise or fall against the patient’s own last value; the end of a support\) with a horizon and an eligibility rule \(Table[4](https://arxiv.org/html/2611.27028#A2.T4)\)\.*New*: no event earlier in the encounter\.*Not active*: no event, or no value beyond the bound, in the previous 24 h \(12 h for imaging\)\.*Active*: at least one in the previous 24 h\.*All*: every scored stay\. The PaO2/FiO2and SpO2/FiO2tasks use the last FiO2setting charted in the same ICU stay, carried forward, as the band tokens do \(§[4\.1](https://arxiv.org/html/2611.27028#S4.SS1)\)\.

Two rules set the reported list\. A task needs at least 50 positive rows in validation\. This removes ECMO, tracheostomy and death among patients given corticosteroids\. A task’s label must also be computable from structured data for every stay\. This removes ARDS onset\. Its label rests on our collaborators’ NLP\-based adjudication of the Berlin criteria, which covers only encounters that passed a screen for acute hypoxaemic respiratory failure \(App\.[J](https://arxiv.org/html/2611.27028#A10)\)\. Both rules depend only on properties of the labels\. Both were fixed before TWICE was scored on test\.

A row is not scored for a threshold task when the series was not measured in the window\. When the patient leaves the setting in which the event would be recorded before the window closes \(the ICU for bedside measurements and ventilation, the hospital for orders and death\), the row is labelled negative\. On a 10,000\-patient development subset, scoring such rows as undefined instead changed the bedside scores’ AUROC by at most 0\.029\. Three definitions carry known biases\. Ventilation has no intubation marker in the record; it is read from the first charting of ventilator settings, which lags intubation\. ICU mortality closes at the end of the ICU stay, which is one unit’s admission \(App\.[A](https://arxiv.org/html/2611.27028#A1)\), so a patient who is transferred to another ICU and dies there is negative for the first stay; this lowers ICU mortality relative to in\-hospital mortality \(6\.3% and 11\.6% of scored stays\)\. And the SpO2/FiO2band<<148 is the severe band of the global ARDS definition\[[58](https://arxiv.org/html/2611.27028#bib.bib58)\], which applies it to intubated patients with SpO2≤\{\}\_\{2\}\\leq97%; our series applies neither restriction\. Severe hypoxaemia by PaO2/FiO2has 49 positive rows on test, one fewer than the validation threshold, and stays in the suite because the list was fixed on validation\. Counts in Table[4](https://arxiv.org/html/2611.27028#A2.T4)are scored rows \(positives\)\.

Table 4:The 19 reported tasks and the four excluded by rule\.TaskDefinitionEligibleValnn\(pos\)Testnn\(pos\)*Respiratory*Severe hypoxaemiaPaO2/FiO2<100<100within 24 hnot active1,022 \(62\)1,037 \(49\)Severe hypoxaemia, SpO2/FiO2SpO2/FiO2<148<148within 24 hnot active1,591 \(412\)1,555 \(404\)Moderate hypoxaemiaPaO2/FiO2<200<200within 24 hnot active615 \(135\)631 \(138\)FiO2escalationFiO2rises≥\\geq0\.20 over its last value in the previous 24 h, within 12 hall2,817 \(491\)2,892 \(456\)FiO2weaningFiO2falls≥\\geq0\.20 below its last value in the previous 24 h, within 12 hall2,817 \(230\)2,892 \(244\)New invasive ventilationfirst ventilator\-setting marker \(set tidal volume, set rate, peak or plateau pressure, mode\) within 24 hnew3,419 \(226\)3,549 \(213\)Ventilator liberationventilator markers stop for≥\\geq48 h, the stop starting within 24 hactive3,825 \(734\)3,798 \(677\)*Haemodynamic*Hypotensionmean arterial pressure<65<65mmHg within 6 hall7,319 \(1,690\)7,250 \(1,700\)*Metabolic and renal*AcidaemiapH<7\.30<7\.30within 24 hnot active1,751 \(501\)1,707 \(475\)Severe acidaemiapH<7\.20<7\.20within 24 hnot active2,252 \(511\)2,260 \(478\)Hyperlactataemialactate≥\\geq2 mmol/L within 24 hnot active922 \(181\)883 \(155\)Severe hyperlactataemialactate≥\\geq4 mmol/L within 24 hnot active1,565 \(80\)1,548 \(74\)Acute kidney injurycreatinine rises≥\\geq0\.3 mg/dL over its last value in the previous 48 h, within 48 hall8,326 \(1,079\)8,344 \(1,067\)New CRRTfirst CRRT marker within 48 hnew8,567 \(102\)8,587 \(94\)*Outcomes*ICU mortalitydeath before ICU dischargeall8,944 \(560\)8,994 \(611\)In\-hospital mortalitydeath before hospital dischargeall8,947 \(1,041\)8,993 \(1,092\)ICU dischargeICU discharge within 24 hall8,947 \(2,907\)8,995 \(2,902\)Death on vasopressorsdeath within 24 h, among patients with a vasopressor order in the previous 24 hactive3,455 \(100\)3,440 \(97\)*Care process*Imaging orderimaging or echocardiography order within 6 hnot active \(12 h\)5,274 \(833\)5,342 \(833\)*Excluded by rule*ARDS onsetadjudicated onset within 48 h; label provenance \(App\.[J](https://arxiv.org/html/2611.27028#A10)\)not active928 \(75\)–Tracheostomytracheostomy order within 48 h;<<50 val positivesnew8,810 \(31\)–ECMOfirst ECMO marker within 48 h;<<50 val positivesnew8,786 \(18\)–Death on corticosteroidsdeath within 24 h, corticosteroid in previous 24 h;<<50 val positivesactive1,780 \(44\)–
## Appendix CTokenization

#### Vocabulary\.

A code is kept as its own token if it is recorded for at least 0\.5% of training patients, counted over the whole training split\. Otherwise it is mapped to the token of its broader parent code \(a laboratory test to its LOINC analyte, a diagnosis to its ICD\-10 category\)\. A code without a parent, or whose parent is also rare, is mapped to the “other” token for its family, which carries presence only\. Static fields, admission, ICU and discharge events, oxygenation, vital signs, ventilator settings and organ support are never pruned; pruning acts on laboratory, medication, diagnosis, procedure, imaging, echocardiography and note codes\. Encounter diagnoses, history diagnoses and medications are written hierarchically: an ICD\-10 code as up to three tokens \(characters 1–3, 4–5 and 6–7\) and a medication as up to three tokens of its ATC code\. The identity of the ICU unit is left out of the stream, and exact duplicate tokens at one instant are dropped\. The vocabulary has 4,986 tokens\.

#### Values and time\.

A numeric value becomes the decile of its \(code, unit\) among training values, with the same edges as the tabular baseline’s value\-bin encoding \(App\.[F](https://arxiv.org/html/2611.27028#A6)\); one set of ten value tokens serves every code\. The record is stamped to the minute, so gaps under a minute emit no time token; longer gaps use the ladder of §[4\.1](https://arxiv.org/html/2611.27028#S4.SS1), whose open last step is repeated at most eight times\.

#### Order and bands\.

Within one minute, events follow a fixed order by kind: openers \(admission, ICU admission\), observations, derived values, actions \(medications, procedures\), documentation, diagnoses, and closers \(ICU discharge, death, discharge\); within a kind, codes are alphabetical\. At every instant where an oxygenation ratio can be graded, a band token names its band: PaO2/FiO2≥\\geq300, 200–300, 100–200 or<<100, and SpO2/FiO2≥\\geq148 or<<148\. The ratio uses the last FiO2setting charted in the same ICU stay, as the labels do\. The stream also carries a token at ARDS onset from our collaborators’ adjudication of the Berlin criteria \(App\.[J](https://arxiv.org/html/2611.27028#A10)\)\. Only encounters that passed the screen for acute hypoxaemic respiratory failure were adjudicated, so the token’s absence does not mean that ARDS did not occur\.

## Appendix DModel and training

Table[5](https://arxiv.org/html/2611.27028#A4.T5)gives TWICE’s architecture and training settings\. A training window may run from the end of one encounter into the next, with no mask between them; a prompt holds the current encounter only\. The smaller models of §[6\.2](https://arxiv.org/html/2611.27028#S6.SS2)have 6 layers of width 384 \(11\.7M parameters\) and 8 layers of width 512 \(26\.2M\)\. They were trained with the same recipe at context 1,024 with 128 windows per step, the same number of tokens per step, and an early\-stopping patience of 10\. The regularised 79\.3M model of §[6\.2](https://arxiv.org/html/2611.27028#S6.SS2)differs from TWICE only in weight decay \(0\.1\) and dropout \(0\.2\), and trained for the full 500,000 steps\.

Table 5:TWICE architecture and training\.- •A training window may run from one encounter into the next \(no document mask\); a prompt holds the current encounter only\.
- •Size curve, at the same readout: 11\.7M \(6 layers, width 384\), 26\.2M \(8, 512\), 79\.3M \(12, 768\) parameters \(§[6\.2](https://arxiv.org/html/2611.27028#S6.SS2)\)\.

## Appendix EReadout and its engineering

Futures are sampled at temperature 1 from the full next\-token distribution, without top\-kkor nucleus truncation\. The temperature was fixed on the fidelity of what the model generates, not on AUROC\. With 50 futures, a probability is a multiple of1/n1/n, wheren≤50n\\leq 50is the number of decided futures\. For a threshold that falls inside a decile bin, the lower bound counts only the bins wholly beyond the threshold and the upper bound adds the bin that contains it; the midpoint is reported\.

Sampling uses a ring\-buffer key–value cache with CUDA graphs: each new token costs one forward pass of one position, and the oldest token’s keys and values are evicted once 2,048 are held\. This is sliding\-window attention over a model trained on full windows, which can degrade language models\[[97](https://arxiv.org/html/2611.27028#bib.bib97)\]\. Against an exact reference that re\-encodes the last 2,048 tokens at every step, per\-step token probabilities differ by about10−310^\{\-3\}, and the 26\.2M model’s mean AUROC changed by\+0\.001\+0\.001\(20 tasks:\+0\.0043\+0\.0043,−0\.0034\-0\.0034to\+0\.0128\+0\.0128; Table[11](https://arxiv.org/html/2611.27028#A8.T11)\)\. Simulating the 8,947 scored validation stays at 50 futures of 8,192 tokens took 29\.8 h on one NVIDIA H200, and the 8,995 test stays 53\.5 h on one NVIDIA L40S\. Runs resume exactly across 12\-hour job segments\.

## Appendix FAll baselines

Every baseline is scored on the same stays as TWICE, and every number in Tables[6](https://arxiv.org/html/2611.27028#A6.T6)–[8](https://arxiv.org/html/2611.27028#A6.T8)is a mean AUROC over the 19 tasks\. The supervised baselines are trained per task on the training split\. Their inputs come from four nested variable sets:essential\(static data, oxygenation and routine vital signs; 55 codes\),essentialTier2\(adds ventilator mechanics; 78\),extended\(adds organ support and every laboratory test; 1,292\) andfull\(adds medication, procedure and imaging orders and diagnoses; 4,675\)\.

- •*Tabular*\(Table[6](https://arxiv.org/html/2611.27028#A6.T6); 48 configurations\)\. The events of the ICU stay in the 24 h beforettbecome presence indicators; presence plus the count, last, minimum, maximum and mean of each code\[[30](https://arxiv.org/html/2611.27028#bib.bib30)\]; or presence plus value bins \(the deciles of §[4\.1](https://arxiv.org/html/2611.27028#S4.SS1)\)\. Each encoding also carries age, hours since ICU admission and the stay’s order in the encounter, and these three alone form a fourth, time\-only encoding\. Each is fitted by LightGBM\[[41](https://arxiv.org/html/2611.27028#bib.bib41)\], XGBoost\[[16](https://arxiv.org/html/2611.27028#bib.bib16)\]or L2\-regularised logistic regression\. Tree counts come from early stopping and the L2 strength from a grid, both on validation; every other hyperparameter is the library default\.
- •*Sequence*\(Table[7](https://arxiv.org/html/2611.27028#A6.T7); 96 configurations\)\. A GRU\[[17](https://arxiv.org/html/2611.27028#bib.bib17)\]or a transformer encoder\[[90](https://arxiv.org/html/2611.27028#bib.bib90)\]reads the same 24 h as 1 h or 4 h bins, each bin holding presence, z\-scored values or value bins\. It is trained as one model per task or as one shared trunk with a head per task: hidden size 128, one layer, dropout 0\.3, AdamW at learning rate10−310^\{\-3\}, stopping after 5 evaluations without improvement on validation\.
- •*Bedside scores*\(Table[8](https://arxiv.org/html/2611.27028#A6.T8)\)\. A partial SOFA \(3 of its 6 components: respiratory, renal, and cardiovascular capped at 1 point, because the record holds vasopressor orders rather than doses; the neurological, coagulation and liver components were not computed\), PaO2/FiO2, SpO2/FiO2, creatinine and mean arterial pressure, each atttor as the worst value in the previous 24 h\. A two\-parameter logistic fit on the training split sets each score’s direction and scale for each task\. The best on validation, the partial SOFA as its worst value in the previous 24 h, reaches 0\.607 on validation and 0\.601 on test\.

The strongest supervised baseline is the best of the 144 supervised configurations on validation \(bold in Table[6](https://arxiv.org/html/2611.27028#A6.T6)\): LightGBM on summaries of thefullset, 0\.8329 on validation and 0\.8345 on test\. The best sequence configuration on validation, a transformer over z\-scored 4 h bins of theextendedset, reaches 0\.7823 on test, 0\.052 below the strongest supervised baseline and 0\.054 below TWICE \(paired 95% CI0\.0440\.044to0\.0630\.063\)\. Because early stopping and the choice of hyperparameters used the validation split, the supervised baselines’ validation scores are slightly optimistic; no choice used the test split\.

Table 6:Tabular baselines: mean AUROC over the 19 tasks, by variable set\. Bold: best on validation, the strongest supervised baseline\.Table 7:Sequence baselines: mean AUROC over the 19 tasks, by variable set\. Bold: best on validation\.Table 8:Bedside scores: mean AUROC over the 19 tasks, calibrated on training data, under the headline rule for carrying the last FiO2setting\. Bold: best on validation\. The other 30 configurations \(raw scores, and a stricter rule that pairs each PaO2or SpO2with an FiO2charted within 5 min\) reach at most 0\.604 on validation\.
## Appendix GFull per\-task results, calibration and decision curves

Table[9](https://arxiv.org/html/2611.27028#A7.T9)gives each task’s test AUROC for both methods and their paired difference\. Thepp\-value is two\-sided, from the bootstrap distribution of the difference; a tick marks a task that stays significant after Holm’s correction across the 19 tasks at level 0\.05\. The last column is the validation difference\. Table[10](https://arxiv.org/html/2611.27028#A7.T10)gives AUPRC, Brier score and ECE on test\. Fig\.[7](https://arxiv.org/html/2611.27028#A7.F7)shows each task’s reliability on test\. TWICE’s probabilities are close to the diagonal for most tasks\. They over\-predict across the middle of the range for FiO2weaning and acute kidney injury, the two tasks with the highest ECE, and at high risk for in\-hospital death; no recalibration was applied\. Fig\.[8](https://arxiv.org/html/2611.27028#A7.F8)gives decision curves on every scored validation stay for the two outcomes fixed for the individual trajectories \(§[6\.4](https://arxiv.org/html/2611.27028#S6.SS4)\)\.

#### Individual trajectories\.

The eight stays of §[6\.4](https://arxiv.org/html/2611.27028#S6.SS4)were drawn at random, before any output was read, from validation stays of at most 14 days still in the ICU at the prediction time\. A stay progressed to ventilation if the patient was not ventilated at the prediction time and ventilator charting began in the ICU at least 12 h later\. A stay ended in death if the patient died in hospital at least 12 h after the prediction time and no later than ICU discharge\. A stay had neither event if the patient was never ventilated, survived and stayed at least 12 h past the prediction time\. We drew three, three and two stays\. For each stay and outcome we explain the largest rise between consecutive points from the prediction time on, 15 rises in all because one stay had no rise in predicted death\. Each rise is picked as the largest of many noisy estimates, so its end is sampled again with a new set of 50 futures\. The futures with events left out reuse the random numbers of this set, which keeps the noise in each difference small\. In the first stay that progressed to ventilation, the new set gives a risk of 0\.94 and leaving out every event of the rise gives 0\.38\. Of the 315 codes left out alone across these rises, seven have a 95% CI that excludes zero\. Two are the operative note and the procedure of one ventilation rise \(\+0\.32\+0\.32and\+0\.20\+0\.20\)\. Four come from one rise in predicted death whose re\-sampled risk at its end was zero\. The seventh is a temperature\-site entry \(\+0\.20\+0\.20\)\. At the prediction time, on the scored validation stays, TWICE’s mean predicted risk of new ventilation is 0\.40 \(95% CI 0\.32 to 0\.48\) for the 65 stays ventilated within 6 h, 0\.26 \(0\.20 to 0\.33\) for 6 to 12 h and 0\.19 \(0\.16 to 0\.22\) for 12 to 24 h, against 0\.050 for stays not ventilated within 24 h \(strongest supervised baseline 0\.30, 0\.13, 0\.15 and 0\.044\)\. Its mean predicted risk of in\-hospital death is 0\.73 \(0\.69 to 0\.77\) for deaths within 24 h and 0\.37 \(0\.33 to 0\.42\) for deaths two weeks or more away, against 0\.084 for survivors \(strongest supervised baseline 0\.63, 0\.32 and 0\.077\)\. In the decision curves, TWICE’s net benefit\[[91](https://arxiv.org/html/2611.27028#bib.bib91)\]is above that of the strongest supervised baseline, with a 95% CI above zero, at 15 of the 50 thresholds for new ventilation and below it at none\. For in\-hospital death it is below at 39 thresholds and above at none \(Fig\.[8](https://arxiv.org/html/2611.27028#A7.F8)\)\.

#### Spread of the futures\.

We measured how often the real value of a series falls inside the central 50% and 90% of its simulated values at 6, 12 and 24 h, for SpO2, FiO2, PEEP, mean arterial pressure, lactate, pH and creatinine\. The value at each horizon is the last one charted between the prediction time and that horizon\. Values are deciles, so coverage uses the randomised probability integral transform\[[21](https://arxiv.org/html/2611.27028#bib.bib21)\]\. Across the seven series and three windows, the central 90% contains the real value in 83% to 90% of cases, and its 95% CI includes 90% in 16 of the 21\. In the other five the futures are too narrow, for FiO2, mean arterial pressure and pH at 6 h, pH at 12 h and lactate at 24 h\. The central 50% contains the real value in 44% to 54% of cases, and its CI includes 50% in 19 of the 21\.

#### Value edits\.

Setting a patient’s last lactate, pH or creatinine to each decile in turn measures the weight TWICE puts on that value\[[86](https://arxiv.org/html/2611.27028#bib.bib86)\]\. We expected predicted death to rise with lactate\[[15](https://arxiv.org/html/2611.27028#bib.bib15)\]and creatinine\[[36](https://arxiv.org/html/2611.27028#bib.bib36)\]and to fall with pH\[[39](https://arxiv.org/html/2611.27028#bib.bib39)\]\. Between the top and bottom deciles, predicted death changes by\+0\.036\+0\.036\(95% CI\+0\.023\+0\.023to\+0\.052\+0\.052\) for lactate,\+0\.003\+0\.003\(−0\.013\-0\.013to\+0\.017\+0\.017\) for pH and−0\.006\-0\.006\(−0\.015\-0\.015to\+0\.004\+0\.004\) for creatinine \(276, 224 and 286 patients\)\. Only the lactate contrast has the expected sign with a CI that excludes zero\. Each edit changes one value and leaves its correlates as charted, so it measures the model’s reliance on an observation, not physiology\.

![Refer to caption](https://arxiv.org/html/2611.27028v1/x7.png)Figure 7:Reliability on test, per task\. Each point is the observed rate against the mean predicted probability in one of the 10 equal\-width bins used for the ECE, for TWICE \(orange\) and the strongest supervised baseline \(blue\)\. Every non\-empty bin is shown\.![Refer to caption](https://arxiv.org/html/2611.27028v1/x8.png)Figure 8:Decision curves on every scored validation stay\[[91](https://arxiv.org/html/2611.27028#bib.bib91)\]\. The top plots show net benefit against the threshold probability for TWICE, the strongest supervised baseline and treating everyone\. The bottom plots show TWICE minus the strongest supervised baseline, with a patient\-clustered 95% CI \(dashed\)\. Thresholds run from 0\.01 to 0\.50 in steps of 0\.01\.Table 9:Per\-task AUROC on test, TWICE against the strongest supervised baseline, paired on identical rows\.Table 10:Per\-task AUPRC, Brier score and ECE \(10 equal\-width bins\) on test, TWICE against the strongest supervised baseline\.

## Appendix HAblations

Table[11](https://arxiv.org/html/2611.27028#A8.T11)lists every paired comparison on validation behind §[6\.2](https://arxiv.org/html/2611.27028#S6.SS2)\. Each changes one setting against a matched control and is scored on the same stays;Δ\\Deltais the difference in mean AUROC over the 19 tasks\. Training changes were screened on the 26\.2M\-parameter model, trained for 150,000 steps and read with 20 futures of 4,096 tokens, against a control trained the same way\. Changes to the 79\.3M\-parameter model were read at 50 futures of 8,192 tokens against TWICE\.

- •*Demographic prefix\.*The static block \(sex, race, ethnicity, age band, admission year\) is placed before every training window and kept in the prompt, so that a window starting mid\-stay still sees it\. The loss is not taken on the prefix\.
- •*Windows drawn per stay\.*Every encounter is equally likely to supply a training window, instead of in proportion to its length\. The tie hides a trade: in\-hospital and ICU mortality rose \(\+0\.042\+0\.042and\+0\.049\+0\.049on the 20\-task read, CIs clear of zero\), while ventilator liberation, new CRRT and acute kidney injury fell\. The model also overfit: at 150,000 steps its held\-out loss exceeded its training loss by 0\.037 nats per token, against 0\.002 for the control\.
- •*Value bins\.*Tail bins add edges at the 0\.1st, 1st, 99th and 99\.9th percentiles to the deciles\. Log\-spaced bins keep the 10th, 50th and 90th percentiles and the same tails\. Thirty quantile bins triple the resolution, within the range that other work on event models has compared\[[51](https://arxiv.org/html/2611.27028#bib.bib51),[64](https://arxiv.org/html/2611.27028#bib.bib64)\]\. Each changes the vocabulary, so held\-out losses do not compare across them\.
- •*Value\-regression head\.*A linear head at each code token, used in training only, predicts the robust z\-score of the value that follows,\(v−median\)/\(IQR/1\.35\)\(v\-\\mathrm\{median\}\)/\(\\mathrm\{IQR\}/1\.35\)clipped to±5\\pm 5, with weight 1 beside the token loss; tasks are still read from the bins\. Its pre\-specified read, the 11 threshold tasks, also tied:\+0\.0075\+0\.0075\(−0\.0049\-0\.0049to\+0\.0203\+0\.0203\) at 26\.2M and−0\.0048\-0\.0048\(−0\.0147\-0\.0147to\+0\.0057\+0\.0057\) at 79\.3M\.
- •*Same\-minute shuffling\.*Events stamped with the same minute and of the same kind, whose order is otherwise alphabetical, are permuted in every training window\. The mean tied, but the model then wrote ventilator settings far too often: the mean probability of new ventilation was 0\.19 against a rate of 0\.06\.
- •*Auxiliary future heads\.*A head used in training only reads the state after each instant and predicts which codes occur in the next 24 h \(binary cross\-entropy\), or the time bin in which each first occurs \(a discrete\-time hazard\), with weight 0\.3 beside the token loss\. The first head learned its target \(1\.25 nats per event against 2\.19 for per\-code rates\), yet its model’s futures stopped for the same reasons, in the same shares, as the control’s\.
- •*Regularisation\.*Weight decay 0\.1 instead of 0\.01 and dropout 0\.2 instead of 0\.1 on the 79\.3M model at context 2,048, trained for the full 500,000 steps, since repeated data calls for more regularisation\[[98](https://arxiv.org/html/2611.27028#bib.bib98),[43](https://arxiv.org/html/2611.27028#bib.bib43)\]\. Its held\-out loss matched TWICE’s \(0\.630\)\.
- •*Context by warm start\.*The converged 79\.3M model at context 1,024 was trained for up to 100,000 more steps at 2,048\. It stopped early at 29,000 steps; its best checkpoint, used here, came at 5,000\. It is compared with the same starting checkpoint at 1,024, both read at 20 futures of 4,096 tokens\.

Table 11:Paired comparisons on validation\.Δ\\Delta: mean AUROC over the 19 tasks,a−ba\-b, on identical rows; 95% CIs from 1,000 patient\-clustered bootstrap replicates\. Readout: futures×\\timestoken budget\.†CI over 20 tasks, ARDS onset included: these predictions were deleted before the 19\-task re\-read\.‡The sampler also changed, from the exact sliding window to the ring buffer \(next row\)\.§Context 1,024→\\rightarrow2,048, weight decay 0\.01→\\rightarrow0\.1, dropout 0\.1→\\rightarrow0\.2 and early\-stopping patience 10→\\rightarrow20 change with size\.Change \(a→ba\\rightarrow b\)Model and trainingReadoutΔ\\DeltaAUROC95% CI*Readout \(same checkpoint\)*Futures 20→\\rightarrow40‡base, context 1,0244,096 tokens\+0\.0219\+0\.0219\[\+0\.0148\+0\.0148,\+0\.0314\+0\.0314\]†Futures 40→\\rightarrow50 \(unpaired\)base, context 1,0244,096 tokens\+0\.0028\+0\.0028–Budget 4,096→\\rightarrow8,192 tokensbase, context 1,02440 futures\+0\.0067\+0\.0067\[\+0\.0002\+0\.0002,\+0\.0146\+0\.0146\]†Budget 4,096→\\rightarrow8,192 tokensTWICE50 futures\+0\.0086\+0\.0086\[\+0\.0020\+0\.0020,\+0\.0146\+0\.0146\]Ring\-buffer cache vs\. exact sliding windowsmall, context 1,02420×\\times4,096\+0\.0013\+0\.0013\[−0\.0034\-0\.0034,\+0\.0128\+0\.0128\]†*Context length*Context 1,024→\\rightarrow2,048small, 150k steps20×\\times4,096\+0\.0116\+0\.0116\[\+0\.0028\+0\.0028,\+0\.0202\+0\.0202\]Context 1,024→\\rightarrow2,048base50×\\times4,096\+0\.0088\+0\.0088\[\+0\.0010\+0\.0010,\+0\.0165\+0\.0165\]Context 1,024→\\rightarrow2,048 by warm startbase, \+5k steps at 2,04820×\\times4,096\+0\.0007\+0\.0007\[−0\.0078\-0\.0078,\+0\.0092\+0\.0092\]*Model size*11\.7M→\\rightarrow26\.2M parameterscontext 1,02450×\\times8,192\+0\.0145\+0\.0145\[\+0\.0076\+0\.0076,\+0\.0217\+0\.0217\]26\.2M→\\rightarrow79\.3M parameters§context and regularisation step too50×\\times8,192\+0\.0136\+0\.0136\[\+0\.0069\+0\.0069,\+0\.0206\+0\.0206\]*Changes that did not help*Regularisation \(weight decay 0\.1, dropout 0\.2\)base, context 2,04850×\\times8,192−0\.0042\-0\.0042\[−0\.0111\-0\.0111,\+0\.0026\+0\.0026\]Demographic prefix on every windowsmall, 150k steps20×\\times4,096−0\.0004\-0\.0004\[−0\.0111\-0\.0111,\+0\.0066\+0\.0066\]†Windows drawn per stay, not per tokensmall, 150k steps20×\\times4,096−0\.0016\-0\.0016\[−0\.0111\-0\.0111,\+0\.0077\+0\.0077\]Value bins: deciles plus tail binssmall, 150k steps20×\\times4,096−0\.0005\-0\.0005\[−0\.0092\-0\.0092,\+0\.0084\+0\.0084\]Value bins: log\-spaced \(3 bulk bins plus tails\)small, 150k steps20×\\times4,096−0\.0079\-0\.0079\[−0\.0166\-0\.0166,\+0\.0009\+0\.0009\]Value bins: 30 quantilessmall, 150k steps20×\\times4,096\+0\.0024\+0\.0024\[−0\.0060\-0\.0060,\+0\.0109\+0\.0109\]Auxiliary value\-regression headsmall, 150k steps20×\\times4,096\+0\.0045\+0\.0045\[−0\.0043\-0\.0043,\+0\.0126\+0\.0126\]Auxiliary value\-regression headbase, context 2,04850×\\times8,192−0\.0021\-0\.0021\[−0\.0085\-0\.0085,\+0\.0043\+0\.0043\]Same\-minute events shuffled in trainingsmall, 150k steps20×\\times4,096−0\.0019\-0\.0019\[−0\.0104\-0\.0104,\+0\.0070\+0\.0070\]Auxiliary head: codes in the next 24 hsmall, 150k steps20×\\times4,096\+0\.0001\+0\.0001\[−0\.0088\-0\.0088,\+0\.0084\+0\.0084\]Auxiliary head: time to each code, 24 hsmall, 150k steps20×\\times4,096\+0\.0044\+0\.0044\[−0\.0042\-0\.0042,\+0\.0125\+0\.0125\]
## Appendix IDischarge diagnoses

Each task asks, at the prediction time, whether the hospital stay will be recorded with a diagnosis in a given CCSR group\[[31](https://arxiv.org/html/2611.27028#bib.bib31)\]\. Encounter diagnoses sit at the discharge time \(§[3](https://arxiv.org/html/2611.27028#S3)\), so each group is read from the futures that reach discharge by the rule of Eq\.[1](https://arxiv.org/html/2611.27028#S4.E1)\. A*new*variant counts only patients for whom the group is not yet documented at the prediction time: not on the problem list and not recorded in an earlier admission\. A group is scored on its own if its expected number of positives \(training prevalence times scored rows\) is at least 50 \(*common*: 116 groups on test\)\. Groups with at least 10 training positives below that are summarised by a macro average \(*rare*: 333 groups\); 70 groups with fewer are not scored\. The ARDS code J80 is removed from every group, since ARDS onset has its own task\.

#### Reading a group\.

A future’s diagnosis tokens are read at two depths: the three\-character ICD\-10 category \(*cat\.*\) or the full hierarchical code \(§[4\.1](https://arxiv.org/html/2611.27028#S4.SS1)\)\. A token counts for a group only if every vocabulary code sharing it belongs to that group\. At full depth, the tokens can express a median 94% of a common group’s diagnosis rows, and on the patients’ real futures the reader recovers the label with median recall 0\.94\. For 264 of the 333 rare groups, no row can be expressed: their codes were pruned from the vocabulary and roll up to tokens shared with other groups\. Such a group falls back to its training rate and scores an AUROC of exactly 0\.5\.

#### Comparator\.

No supervised model was trained for this family\. The*documented*rule predicts each group’s training rate given whether the group is already documented at the prediction time\. On new diagnoses it gives every patient the same probability, so its AUROC is 0\.5\.

#### Results\.

Table[12](https://arxiv.org/html/2611.27028#A9.T12)gives macro averages over groups\. TWICE reaches 0\.717 on all diagnoses and 0\.693 on new ones\. The documented rule leads on all diagnoses by AUROC \(0\.742\) and trails by AUPRC \(0\.141 vs\. 0\.174\)\. The category\-level reader is weaker \(0\.648 and 0\.632\), since many groups are defined below the three\-character level\. Validation is within 0\.005 of test on every row\.

#### Threats\.

The new arm inherits the common set from all diagnoses, so 47 of its 115 scorable groups have fewer than 50 positives on test \(macro AUROC 0\.647, against 0\.725 over the other 68\)\. A future that stops at the token budget before discharge writes no diagnoses and is undecided\. Of the test futures, 28\.2% stop this way\. A future that dies before discharge counts as positive for a group it has already written and is undecided otherwise, which biases dying patients’ probabilities upward\. Encounter diagnoses record what was documented, which need not be what occurred\.

Table 12:Discharge diagnosis groups: macro averages over groups with both classes \(nn\)\. Pos\.: positive rows summed over groups\. TWICE reads the full code \(AUROC, AUPRC\) or the three\-character category only \(cat\.\);*documented*is the rule that uses only whether the group is already documented at the prediction time\.

## Appendix JARDS onset

ARDS onset within 48 h is excluded from the reported suite by the rule in §[3](https://arxiv.org/html/2611.27028#S3)\. Its label rests on our collaborators’ NLP\-based adjudication of the Berlin criteria\[[8](https://arxiv.org/html/2611.27028#bib.bib8)\], which exists only for encounters that passed a screen for acute hypoxaemic respiratory failure, while every other label is a rule over structured events\. The rule was fixed before TWICE was scored on test\. On test \(868 rows, 68 positives\), TWICE reaches an AUROC of 0\.757 \(95% CI 0\.687–0\.817\) and the strongest supervised baseline 0\.816 \(0\.755–0\.867\)\. On validation \(928 rows, 75 positives\) they reach 0\.780 and 0\.830, a paired difference of−0\.050\-0\.050\(−0\.094\-0\.094to−0\.009\-0\.009\)\. Including the task would move the mean difference over tasks from\+0\.0017\+0\.0017to−0\.0013\-0\.0013on test \(point estimates\) and from\+0\.0028\+0\.0028to\+0\.0002\+0\.0002on validation; the two methods tie either way\.

## Appendix KWhat\-if scenarios and trial emulation

#### Design\.

Each scenario of §[5](https://arxiv.org/html/2611.27028#S5)is defined by its decision points, arms and outcomes \(Table[13](https://arxiv.org/html/2611.27028#A11.T13)\)\.

- •*Decision points\.*A trigger is a charted event after which clinicians commonly choose a treatment\. A decision point is the first trigger of a scenario in a validation ICU stay, and the history is cut there\. Each stay therefore contributes at most one decision point to a scenario\. In the two trial scenarios, the trigger is the moment a patient first meets the trial’s enrolment criteria\.
- •*Arms\.*Each scenario compares treatment arms with a control arm \(§[4\.4](https://arxiv.org/html/2611.27028#S4.SS4)\)\. For each arm at each decision point, TWICE samples 50 futures from the same history\.
- •*Outcomes and effects\.*An outcome is an event within a fixed window after the decision point\. Its value in an arm is the fraction of the arm’s futures in which the event occurs\. An outcome on a laboratory value counts only the futures that measure the value in the window, as in §[4\.3](https://arxiv.org/html/2611.27028#S4.SS3)\. The effect of an order on an outcome is its value in the order’s arm minus its value in the control arm, averaged over decision points\.
- •*Kinds of effect\.*In each of the five scenarios that do not emulate a trial, a*right treatment*is one that guidelines recommend for the trigger, and an*opposite treatment*is expected to move the triggering value the other way\. A*target effect*is the effect of either on that value\. For a right treatment, it is the intended effect\[[63](https://arxiv.org/html/2611.27028#bib.bib63)\]\. A*side effect*is a known adverse effect of a drug on another outcome\. An*inert drug*is expected to change no outcome\. Pantoprazole is the inert drug in every scenario\.
- •*Confounding by indication\.*A treatment is ordered because of its target, so target effects are the most open to confounding by indication \(§[2](https://arxiv.org/html/2611.27028#S2)\)\. A drug is rarely ordered for its side effects, so they are less open to it\[[63](https://arxiv.org/html/2611.27028#bib.bib63),[89](https://arxiv.org/html/2611.27028#bib.bib89)\]\. Side effects therefore serve as positive controls, and the inert drug serves as a negative\-control exposure\[[53](https://arxiv.org/html/2611.27028#bib.bib53)\]\.
- •*Pass rule\.*An effect passes when its 95% CI excludes zero in the expected direction\. It is reversed when its CI excludes zero in the other direction, and inconclusive otherwise\. An expected\-zero effect whose CI excludes zero counts as a shift\. We pre\-specified the outcomes, their windows, the expected directions and this rule\.

#### Worked example\.

The high\-potassium scenario illustrates the design\. Its trigger is a potassium of at least 6\.0 mmol/L in a patient who has received no potassium\-lowering drug in the previous 24 h\. Validation contains 221 such decision points\. The control arm forbids all of the scenario’s drugs\. The drug arms order insulin, salbutamol, IV calcium, potassium chloride and pantoprazole \(Table[13](https://arxiv.org/html/2611.27028#A11.T13)\)\. Each order is written into the EHR 63 min after the trigger, the median delay from trigger to order in the training data\. One outcome is a first potassium below 5\.5 mmol/L within 4 h\. Its value in an arm is the fraction of futures with that event, among the futures that measure potassium in that window\. The cutoff of 5\.5 mmol/L lies inside the top potassium decile, so this outcome is bracketed \(§[4\.3](https://arxiv.org/html/2611.27028#S4.SS3)\)\. Insulin lowers potassium\[[6](https://arxiv.org/html/2611.27028#bib.bib6)\], so its target effect passes if this fraction is higher in the insulin arm than in the control arm, with a CI above zero\. Potassium chloride is the opposite treatment, and its effect is expected to be negative\. In the training data, potassium chloride ordered at a high potassium plausibly follows a sample judged haemolysed\. A model that reads the order as a sign of the patient’s state would then predict a lower potassium after potassium chloride, as after insulin\. IV calcium protects the heart but does not lower potassium\[[6](https://arxiv.org/html/2611.27028#bib.bib6)\], so it is a second inert drug for this outcome\. Another outcome, any glucose below 70 mg/dL within 6 h, tests a side effect of insulin\.

Table 13:Clinical scenarios on validation, with the number of decision points of each\. In the low\-blood\-pressure and start\-of\-ventilation scenarios, 1,000 decision points were drawn at random from 4,232 and 2,055 to limit compute\. The control arm is listed first \(§[4\.4](https://arxiv.org/html/2611.27028#S4.SS4)\)\. Pantoprazole, the inert drug, is also an arm of every scenario\.
#### Scenarios\.

Thresholds follow guidelines: potassium from the UK Kidney Association\[[6](https://arxiv.org/html/2611.27028#bib.bib6)\], glucose from the American Diabetes Association’s level\-1 hypoglycaemia\[[7](https://arxiv.org/html/2611.27028#bib.bib7)\], blood pressure from the Surviving Sepsis Campaign\[[25](https://arxiv.org/html/2611.27028#bib.bib25)\], SpO2from the ARDS Network’s lower goal\[[1](https://arxiv.org/html/2611.27028#bib.bib1)\], sedation from the PADIS guideline\[[22](https://arxiv.org/html/2611.27028#bib.bib22)\]and bradycardia from the 2018 ACC/AHA/HRS guideline\[[48](https://arxiv.org/html/2611.27028#bib.bib48)\]\. The expected effects on the targets follow from the treatments these guidelines recommend\. Insulin and salbutamol, for example, lower potassium by shifting it into cells\[[6](https://arxiv.org/html/2611.27028#bib.bib6)\]\. The opposite arms are expected to move the target the other way\. Potassium chloride adds potassium, insulin lowers glucose, nicardipine dilates blood vessels and a lower FiO2delivers less oxygen\. The expected side effects are adverse effects of the drugs\. These are hypoglycaemia after insulin\[[6](https://arxiv.org/html/2611.27028#bib.bib6)\], hyperglycaemia after glucocorticoids\[[18](https://arxiv.org/html/2611.27028#bib.bib18)\], hypotension after propofol and bradycardia after dexmedetomidine\[[37](https://arxiv.org/html/2611.27028#bib.bib37)\]\. The trial scenarios emulate the eligibility of ROSE\[[67](https://arxiv.org/html/2611.27028#bib.bib67)\]and of RECOVERY’s invasively ventilated stratum\[[74](https://arxiv.org/html/2611.27028#bib.bib74)\]; ROSE’s onset time comes from our collaborators’ adjudication of the Berlin criteria \(App\.[J](https://arxiv.org/html/2611.27028#A10)\)\.

#### Sampling\.

An order is inserted at the median delay from trigger to order among treated training points: 63 min at a high potassium, 25 at a low glucose, 33 at a low blood pressure and 50 at the start of ventilation, at once for ventilator settings, and 156 and 465 min for ROSE and RECOVERY\. The order reached 96\.4% to 99\.9% of futures across scenarios\. Futures stop at the end of the outcome window, after 2,048 tokens, or, in the trial scenarios, at discharge, death, 30 days or 32,768 tokens\. A usual\-care arm without insertion or ban is always run\. Its futures give the orders after an abnormal value \(App\.[L](https://arxiv.org/html/2611.27028#A12)\)\.

#### Outcomes\.

An outcome whose clinical cutoff falls inside a value decile is bracketed as in §[4\.3](https://arxiv.org/html/2611.27028#S4.SS3)\. Such outcomes resolve the direction of an effect better than its size\. The top potassium decile starts between 4\.8 and 5\.7 mmol/L, depending on the laboratory code\. “Below 6\.0 mmol/L” is therefore bracketed between “below the top decile” and “any value”\. The bottom glucose decile ends between 89 and 128 mg/dL, depending on the code\. At a high potassium, the potassium outcome pre\-specified as primary was the first K\+below 6\.0 mmol/L within 2 h\. §[6\.5](https://arxiv.org/html/2611.27028#S6.SS5)and Fig\.[6](https://arxiv.org/html/2611.27028#S6.F6)report the second, below 5\.5 mmol/L within 4 h, which lies in the same top decile and differs only in its window\. On the primary outcome the effects point the same way and are smaller,\+0\.011\+0\.011\(\+0\.0004\+0\.0004to\+0\.022\+0\.022\) for insulin and\+0\.007\+0\.007\(−0\.004\-0\.004to\+0\.019\+0\.019\) for potassium chloride\.

#### Trials\.

Trial effects are compared on the difference scale for ROSE and on the log\-ratio scale for RECOVERY, with RCT\-DUPLICATE’s agreement metrics\[[92](https://arxiv.org/html/2611.27028#bib.bib92)\]\. The endpoint is in\-hospital death, not the trials’ 90\- or 28\-day mortality, and eligibility is emulated from flowsheet and laboratory data in a different era and population\. The control arms forbid the trial drug for the whole future, while 86 of ROSE’s 505 usual\-care patients \(17\.0%\) received a neuromuscular blocker\[[67](https://arxiv.org/html/2611.27028#bib.bib67)\]\. The longest budget is primary\. It was fixed before any long run because it leaves the fewest futures undecided\. At shorter budgets, read off the same futures, cisatracurium in ROSE raises death by 0\.143 \(0\.004 to 0\.289\) at 4,096 tokens and by 0\.082 \(0\.015 to 0\.159\) at 8,192, an excess of early deaths that is gone at the primary budget\. TWICE’s absolute risk of death in the 26 untreated ROSE patients is 0\.535, against an observed 0\.308 \(RECOVERY: 0\.356 against 0\.333 in 24\)\. If most futures left undecided by the budget are survivors, as long stays tend to be, death among the decided futures is inflated\. The trial contrasts assume both arms share this bias\.

#### Observed outcomes and tabular estimators\.

A decision point counts as treated when the treatment was ordered within 1 to 2 h of it, or within 12 to 24 h in the trial scenarios\. In the four scenarios with an opposite treatment, the futures with the received treatment written in never predicted the observed outcome better than the futures with the opposite treatment\. The tabular estimators use code counts and the deciles of the last values in the previous 24 h\. They are fitted on training decision points by histogram\-based gradient boosting at default settings\[[70](https://arxiv.org/html/2611.27028#bib.bib70)\]\. One is an S\-learner and the other is inverse\-probability weighting\. Inverse\-probability weighting reverses insulin on the 2 h potassium outcome \(−0\.415\-0\.415,−0\.678\-0\.678to−0\.164\-0\.164\), and its CIs include zero for every other effect on a target\. We also planned to calibrate the predictions under each treatment with inverse\-probability weights\. This could not be estimated reliably, since only 2 to 111 decision points per treatment fell where both choices were plausible\.

#### Not reported\.

PEEP changes read as natural experiments could not be scored: the inserted value token equalled the previous one at 55 of 211 points for the actual change and at 123 for its mirror image, and 57% of futures stopped at the budget within 6 h\.

## Appendix LNext\-event and fidelity details

#### Next token\.

Positions are 64 random points in each of 8,938 validation stays \(6,920 patients; 571,002 positions\), read with the true history as context, up to 2,048 tokens\. Table[14](https://arxiv.org/html/2611.27028#A12.T14)gives top\-kkaccuracy by the type of the true next token, with patient\-clustered CIs; the unigram and bigram models are counted on the training stays\. Set recall SR@\(ii,mm\)\[[71](https://arxiv.org/html/2611.27028#bib.bib71), Eq\. 9\]is the share of the distinct tokens among the nextmmthat appear among the model’siimost likely next tokens \(Table[15](https://arxiv.org/html/2611.27028#A12.T15)\); the event\-code version counts codes only and skips values and time gaps\. For long horizons and long lists, a frequency list recalls more than the next\-token distribution, which concentrates on the immediate next token, so set recall is a weak test of a next\-token model beyond short horizons\.

Table 14:Next\-token accuracy \(%\) on validation by the type of the true next token, with 95% CIs\.Table 15:Set recall SR@\(ii,mm\) \(%\) on validation: of the distinct tokens among the nextmm, the share in the topii\.
#### Orders after an abnormal value\.

The decision points are those of the high\-potassium, low\-glucose and low\-blood\-pressure scenarios \(Table[13](https://arxiv.org/html/2611.27028#A11.T13)\)\. An order’s predicted probability is Eq\. \([1](https://arxiv.org/html/2611.27028#S4.E1)\) over the usual\-care futures, with the event being any order of its drug class in the window after the trigger \(Table[16](https://arxiv.org/html/2611.27028#A12.T16)\)\. Classes are matched by ATC prefix\. Insulin is A10A, IV calcium B05XA07 and B05XA19,β2\\beta\_\{2\}\-agonists R03AC and R03CC, potassium binders V03AE, dextrose or glucagon V06DC, B05BA and H04AA, and vasopressors C01CA and H01BA\. The comparator is the gradient\-boosted model of App\.[K](https://arxiv.org/html/2611.27028#A11), fitted on training decision points to whether the order was placed\. The first drug ordered is read the same way\. Norepinephrine is 56% of the first vasopressors within 6 h in the futures and 64% of the 260 in the EHR\. Propofol is 74% of the first sedatives within 2 h of the start of ventilation in the futures and 91% of the 546 in the EHR\.

Table 16:Orders after an abnormal value on validation\. Share ordered is the fraction of decision points at which clinicians placed the order and the mean predicted probability over the futures\. AUROCs have patient\-clustered 95% CIs\.
#### Generated next 24 h\.

For every scored validation stay, one future is cut at 24 h and its concepts are compared with the real window’s \(Table[17](https://arxiv.org/html/2611.27028#A12.T17)\)\. A concept is a laboratory test, a medication’s ATC therapeutic subgroup, a procedure, a bedside code or a three\-character diagnosis category\. The all\-rows columns give Curiosity’s RMSLE between real and generated rates over 8,947 rows, beside two references: two disjoint random halves of the real rows \(each half the size, so noisier than a full\-size comparison\), and, for co\-occurrence, the real rates of each concept under independence\. The swap test uses the earliest row of each patient whose real and first two generated windows fit within the token budget \(5,747 of 5,836\)\. The test compares the observed RMSLE with 999 RMSLEs recomputed after swapping each patient’s real and generated windows with probability one half\. The ratio divides the observed RMSLE by the median of these 999\. Concepts are tested one at a time with McNemar’s exact test\[[61](https://arxiv.org/html/2611.27028#bib.bib61)\]and the Benjamini–Hochberg procedure at 5%\[[11](https://arxiv.org/html/2611.27028#bib.bib11)\]\. The personal\-overlap control and its ceiling \(§[6\.3](https://arxiv.org/html/2611.27028#S6.SS3)\) use the same 5,747 patients and two generated futures each\.

Table 17:Generated against real next 24 h on validation, per panel of concepts\. Holmpp: across the 20 panels\.

## Appendix MData\-integrity checks

#### Leakage by timing\.

Encounter diagnoses are placed at the discharge time, so no input before discharge contains them \(§[3](https://arxiv.org/html/2611.27028#S3)\)\. Note\-type tokens carry no text but are placed at the note’s service time, which for 10\.15% of notes precedes the note’s creation\. Moving every note token to the time its first version was filed changed the mean validation AUROC of the tabular baseline over the 44 tasks with at least 50 positives from 0\.8444 to 0\.8434 \(−0\.0010\-0\.0010, with 24 of 47 tasks down, 21 up and 2 unchanged\), the size of the difference between two fits, so every result is reported on the original timing\.

#### Test exposure\.

Before 10 October 2026, the development runs of the generative model drew a random sample of 2,000 prediction rows from validation and test together for their simulation diagnostics\. The real next 24 h of the sampled test patients entered the fidelity diagnostics of those runs \(no test label did\)\. No number in this paper comes from those draws, and the exposed test patients were not excluded\. From that date, simulation drew from validation only\.

#### Record checks\.

Conversion to MEDS kept every patient, encounter and ICU stay of the extract and removed 0\.79% of rows as exact duplicates\. The name\-based rescue of uncoded medications placed medications in ATC groups with a leave\-one\-out precision of 99\.0%\. Across the cohort, ICU admission and discharge events differ in number by 124, 38 encounters have no complete ICU stay, and one has no admission or discharge time\.

## Appendix NPerformance by subgroup

Table[18](https://arxiv.org/html/2611.27028#A14.T18)gives TWICE minus the strongest supervised baseline on the 19 test tasks within groups of age \(<<65 and≥\\geq65 years, the cohort’s median\), sex, race \(White, Black or African American, Asian, other or unknown\), ethnicity \(Hispanic, not Hispanic\), whether the encounter passed the screen for acute hypoxaemic respiratory failure, and era \(ICU admission before 2020, and from 2020\), as TRIPOD\+AI recommends for sociodemographic groups\[[19](https://arxiv.org/html/2611.27028#bib.bib19)\]\. The groups use the values as recorded \(Table[3](https://arxiv.org/html/2611.27028#A1.T3)\), and the comparisons are descriptive, without correction for multiplicity\. A task enters a group’s mean when both outcomes occur in the group, so some means rest on few positive stays\.

Over all scored stays the difference is\+0\.0017\+0\.0017, as in Table[2](https://arxiv.org/html/2611.27028#S6.T2)\. Its 95% CI excludes zero in one of the 14 groups, the stays that passed the screen for acute hypoxaemic respiratory failure \(\+0\.012\+0\.012, 95% CI\+0\.004\+0\.004to\+0\.020\+0\.020\)\. With 14 groups, about one such interval is expected by chance\. In no group does TWICE trail the strongest supervised baseline with a CI that excludes zero\.

Table 18:Performance by subgroup on test\. Mean AUROC over the tasks with both outcomes in the group, TWICE against the strongest supervised baseline \(Baseline\), paired on identical rows\.Δ\\Delta: TWICE minus the baseline, with 95% CIs from 1,000 patient\-clustered bootstrap replicates\. Min\. pos\.: the fewest positive stays of any task in the group\. AHRF: acute hypoxaemic respiratory failure\. The ethnicity groups leave out 512 stays with ethnicity unavailable, declined or unknown\.GroupStaysPatientsTasksMin\. pos\.TWICEBaselineΔ\\Delta95% CIAll8,9955,79419490\.83620\.8345\+0\.0017\+0\.0017\[−0\.0053\-0\.0053,\+0\.0090\+0\.0090\]*Age*<<65 years4,2922,72219300\.84140\.8397\+0\.0017\+0\.0017\[−0\.0081\-0\.0081,\+0\.0113\+0\.0113\]≥\\geq65 years4,7033,11219190\.83040\.8296\+0\.0008\+0\.0008\[−0\.0105\-0\.0105,\+0\.0125\+0\.0125\]*Sex*Female3,9032,51419160\.84150\.8359\+0\.0056\+0\.0056\[−0\.0052\-0\.0052,\+0\.0163\+0\.0163\]Male5,0923,28019330\.83300\.8337−0\.0007\-0\.0007\[−0\.0109\-0\.0109,\+0\.0092\+0\.0092\]*Race*White7,0584,54119350\.83380\.8330\+0\.0007\+0\.0007\[−0\.0080\-0\.0080,\+0\.0090\+0\.0090\]Black or African American7054021940\.84640\.8380\+0\.0084\+0\.0084\[−0\.0190\-0\.0190,\+0\.0327\+0\.0327\]Asian2761821810\.84860\.8567−0\.0081\-0\.0081\[−0\.0453\-0\.0453,\+0\.0260\+0\.0260\]Other or unknown9566691980\.84610\.8383\+0\.0078\+0\.0078\[−0\.0088\-0\.0088,\+0\.0238\+0\.0238\]*Ethnicity*Hispanic7324581930\.84960\.8312\+0\.0184\+0\.0184\[−0\.0010\-0\.0010,\+0\.0378\+0\.0378\]Not Hispanic7,7514,97019390\.83350\.8346−0\.0011\-0\.0011\[−0\.0109\-0\.0109,\+0\.0071\+0\.0071\]*AHRF screen*Passed4,5082,85919490\.81800\.8058\+0\.0121\+0\.0121\[\+0\.0042\+0\.0042,\+0\.0203\+0\.0203\]Not passed4,4873,3891810\.85650\.8617−0\.0052\-0\.0052\[−0\.0252\-0\.0252,\+0\.0144\+0\.0144\]*ICU admission*Before 20202,6131,78619140\.82970\.8215\+0\.0082\+0\.0082\[−0\.0071\-0\.0071,\+0\.0231\+0\.0231\]From 20206,3824,16919350\.83810\.8386−0\.0005\-0\.0005\[−0\.0090\-0\.0090,\+0\.0079\+0\.0079\]

Similar Articles

EHR-MPC: Inference-Time Control for Sepsis Treatment with Generative Patient Digital Twins

arXiv cs.AI

This paper introduces EHR-MPC, a framework that decouples learning patient dynamics from treatment optimization by training a generative digital twin of patients using electronic health records, then applying model predictive control at inference time, achieving comparable or improved performance over RL baselines on a multi-hospital sepsis cohort.

Federated generative event models for tokenized electronic health records

arXiv cs.LG

This arXiv paper evaluates federated training of tokenized generative event models (GEMs) on ICU EHR data from three health systems, showing that federated learning preserves most centralized performance and improves cross-site transportability compared to conventional supervised models.