Formalized SCOPE and REACH estimatorsResearch Paper
Motivation
A foundation model trained on tokenized electronic health record (EHR) timelines can be used to predict clinical outcomes without ever being finetuned for a specific prediction task: condition the model on a patient's observed timeline, autoregressively sample many possible futures, and report the fraction of sampled futures in which the outcome of interest occurs. This generative approach to inference powers a growing family of EHR foundation models— including Event Stream GPT (McDermott et al., 2023), Foresight (Kraljevic et al., 2024), ETHOS (Renc et al., 2024), and Curiosity (Waxler et al., 2025)—and it is attractive for its zero-shot approach to predicting a variety of outcomes.
It is also expensive. Reproducing one published pipeline required more than A100 GPU-hours of inference. Worse, the estimator built from sampled futures takes values in , so its resolution is tied to the sampling budget: for an outcome of prevalence , sampled futures fail more than of the time to rank a patient at ten times average risk above an average one. The most consequential clinical decisions turn on exactly such low-prevalence, high-impact outcomes.
Solo et al. (arXiv:2602.03730) observe that Monte Carlo discards almost everything the model produces: at every step the model emits a full next-token distribution and the sampler keeps only the token it drew. The paper introduces two estimators that consume the discarded probabilities instead, and proves that doing so costs no bias and—for one of them—never costs variance.
Setting and estimators
Let generate token sequences from a countable vocabulary , with designated outcome token . The next-token probabilities may depend on the complete preceding history. The time threshold is initially unexceeded. Its crossing may depend on several kinds of time-spacing tokens and on their accumulated duration.
For a sampled timeline , is the first position occupied by , or if it never appears. The time is the first position at which the threshold has been exceeded. Assume almost surely. Timelines are retained through the actual threshold crossing, even if the outcome appears earlier. Thus is not reassigned after an outcome.
The threshold is reached almost surely, but the number of tokens required may be arbitrarily large. No deterministic bound or finite expected token count is assumed. For REACH, assume also that removing the outcome token and renormalizing defines a sampler that reaches the same threshold almost surely.
For independent original timelines, the Monte Carlo estimator is
The SCOPE estimator is
For REACH, sample independent outcome-free timelines by setting the next-token probability of to zero and renormalizing the probabilities of the other tokens. Using the original model probabilities along those timelines, define
Formalization targets
The targets are:
- SCOPE unbiasedness: .
- Equal probabilities milestone: from Appendix C, where is the original outcome-before-threshold event and is at least one successful Bernoulli trial along an outcome-free timeline.
- REACH unbiasedness: .
- Rao–Blackwell identity: for every positive sample count, conditioning the average of the two-stage event indicators on the entire pool of outcome-free timelines equals almost surely.
- Main goal: at the same positive sample count, with finite second moments for both estimators.
Expectations and variances use each estimator's specified sampling law.
What the formalization establishes
The claims concern the probability assigned by the generative model. They provide unbiasedness and a comparison of sampling variance. SCOPE is kept unclipped, as in the paper's unbiasedness result. All five target statements have accompanying local Lean proofs.
Main mathematical difficulty
A pathwise finite stopping time need not have a common finite bound or a finite mean. An expectation involving the stopped SCOPE sum therefore needs justification beyond finite-sum linearity. REACH uses a different sampling law, so its unbiasedness and variance comparison also require a proved connection between the original event and the two-stage experiment. The equal-probabilities milestone records that connection explicitly.
Formalization scope
Lean represents each sampled timeline by a finite list ending at its first threshold crossing. Arbitrary finite lengths are included in the same sample space. Path probabilities are products of next-token probabilities, and the laws are countable sums of these path masses. Requiring each law to have total mass one expresses almost-sure termination of that sampler; it is not a uniform length bound. The vocabulary can be finite or countably infinite.
The stopping predicate examines a complete prefix and is not restricted to a single terminal token. The original law continues through outcomes until the threshold. A separate almost-everywhere hypothesis excludes equal outcome and threshold times. The code proves that the actual threshold time is finite almost surely and that the strict event is the event used by the internal calculations.
The two-stage experiment explicitly samples conditionally independent Bernoulli trials using the original hazards. Its conditioning information retains the complete indexed pool of outcome-free timelines. The Rao–Blackwell target uses Mathlib's conditional expectation. The variance target uses Mathlib's variance, and proves square integrability rather than assuming it.
Selected references
- Luke Solo, Matthew B. A. McDermott, William F. Parker, Bashar Ramadan, Michael C. Burkhart, Brett K. Beaulieu-Jones, Efficient Generative Prediction for EHR Foundation Models: The SCOPE and REACH Estimators, 2026. arXiv:2602.03730
- M. B. A. McDermott, B. Nestor, P. Argaw, I. S. Kohane, Event Stream GPT: A Data Pre-processing and Modeling Library for Generative, Pre-trained Transformers over Continuous-time Sequences of Complex Events, Advances in Neural Information Processing Systems 36, pp. 24322–24334, 2023. arXiv:2306.11547
- Z. Kraljevic, D. Bean, A. Shek, R. Bendayan, H. Hemingway, J. A. Yeung, A. Deng, A. Baston, J. Ross, E. Idowu, J. T. Teo, R. J. B. Dobson, Foresight—a generative pretrained transformer for modelling of patient timelines using electronic health records: a retrospective modelling study, Lancet Digital Health 6(4), pp. e281–e290, 2024. doi:10.1016/S2589-7500(24)00025-6
- P. Renc, Y. Jia, A. E. Samir, J. Was, Q. Li, D. W. Bates, A. Sitek, Zero shot health trajectory prediction using transformer, npj Digital Medicine 7(1), p. 256, 2024. doi:10.1038/s41746-024-01235-0
- 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, R. Shah, Generative medical event models improve with scale, 2025. Introduces the Curiosity model family. arXiv:2508.12104