Table of Contents
Fetching ...

TwinWeaver: An LLM-Based Foundation Model Framework for Pan-Cancer Digital Twins

Nikita Makarov, Maria Bordukova, Lena Voith von Voithenberg, Estrella Pivel-Villanueva, Sabrina Mielke, Jonathan Wickes, Hanchen Wang, Mingyu Derek Ma, Keunwoo Choi, Kyunghyun Cho, Stephen Ra, Raul Rodriguez-Esteban, Fabian Schmich, Michael Menden

TL;DR

TwinWeaver enables LLM-based patient digital twins by serializing heterogeneous longitudinal EHR data into text prompts for joint biomarker forecasting and landmark-event prediction across 20 cancers. The Genie Digital Twin (GDT) demonstrates strong real-world and clinical-trial generalization, outperforming baselines on forecasting accuracy ($MASE$) and risk ranking ($C$-index), while enabling an interpretable reasoning extension grounded in clinical concepts. The framework achieves pan-cancer transfer benefits, improves performance in low-data settings, and supports a reasoning-informed pipeline through distillation and GRPO optimization. Open-source and scalable, TwinWeaver offers a practical pathway to interpretable, data-efficient trajectory modeling in precision oncology, with future directions including additional modalities and rigorous prospective validation.

Abstract

Precision oncology requires forecasting clinical events and trajectories, yet modeling sparse, multi-modal clinical time series remains a critical challenge. We introduce TwinWeaver, an open-source framework that serializes longitudinal patient histories into text, enabling unified event prediction as well as forecasting with large language models, and use it to build Genie Digital Twin (GDT) on 93,054 patients across 20 cancer types. In benchmarks, GDT significantly reduces forecasting error, achieving a median Mean Absolute Scaled Error (MASE) of 0.87 compared to 0.97 for the strongest time-series baseline (p<0.001). Furthermore, GDT improves risk stratification, achieving an average concordance index (C-index) of 0.703 across survival, progression, and therapy switching tasks, surpassing the best baseline of 0.662. GDT also generalizes to out-of-distribution clinical trials, matching trained baselines at zero-shot and surpassing them with fine-tuning, achieving a median MASE of 0.75-0.88 and outperforming the strongest baseline in event prediction with an average C-index of 0.672 versus 0.648. Finally, TwinWeaver enables an interpretable clinical reasoning extension, providing a scalable and transparent foundation for longitudinal clinical modeling.

TwinWeaver: An LLM-Based Foundation Model Framework for Pan-Cancer Digital Twins

TL;DR

TwinWeaver enables LLM-based patient digital twins by serializing heterogeneous longitudinal EHR data into text prompts for joint biomarker forecasting and landmark-event prediction across 20 cancers. The Genie Digital Twin (GDT) demonstrates strong real-world and clinical-trial generalization, outperforming baselines on forecasting accuracy () and risk ranking (-index), while enabling an interpretable reasoning extension grounded in clinical concepts. The framework achieves pan-cancer transfer benefits, improves performance in low-data settings, and supports a reasoning-informed pipeline through distillation and GRPO optimization. Open-source and scalable, TwinWeaver offers a practical pathway to interpretable, data-efficient trajectory modeling in precision oncology, with future directions including additional modalities and rigorous prospective validation.

Abstract

Precision oncology requires forecasting clinical events and trajectories, yet modeling sparse, multi-modal clinical time series remains a critical challenge. We introduce TwinWeaver, an open-source framework that serializes longitudinal patient histories into text, enabling unified event prediction as well as forecasting with large language models, and use it to build Genie Digital Twin (GDT) on 93,054 patients across 20 cancer types. In benchmarks, GDT significantly reduces forecasting error, achieving a median Mean Absolute Scaled Error (MASE) of 0.87 compared to 0.97 for the strongest time-series baseline (p<0.001). Furthermore, GDT improves risk stratification, achieving an average concordance index (C-index) of 0.703 across survival, progression, and therapy switching tasks, surpassing the best baseline of 0.662. GDT also generalizes to out-of-distribution clinical trials, matching trained baselines at zero-shot and surpassing them with fine-tuning, achieving a median MASE of 0.75-0.88 and outperforming the strongest baseline in event prediction with an average C-index of 0.672 versus 0.648. Finally, TwinWeaver enables an interpretable clinical reasoning extension, providing a scalable and transparent foundation for longitudinal clinical modeling.
Paper Structure (71 sections, 12 equations, 16 figures, 2 tables, 2 algorithms)

This paper contains 71 sections, 12 equations, 16 figures, 2 tables, 2 algorithms.

Figures (16)

  • Figure 1: The TwinWeaver framework serializes longitudinal patient histories into text to train the Genie Digital Twin (GDT) pan-cancer foundation model.a) The TwinWeaver framework b) serializes multi-modal EHR data (history, genetics) into text. c) We use this to develop GDT on 93,054 real-world patients across 20 cancer indications (counts shown in parentheses). GDT jointly d) forecasts continuous biomarkers and e) predicts landmark clinical events. f) The model can be further trained for interpretable predictions using reasoning-based outputs.
  • Figure 2: GDT achieves reduced error in highly dynamic blood biomarker forecasting across the majority of cancer indications.a) Heatmap of the median Mean Absolute Scaled Error (MASE - lower is better). GDT shows lower error (darker blue) compared to baselines for the top 30 most time-changing variables per indication. b) Aggregated performance of the top 30 most changing variables shows GDT achieves a median MASE of 0.830, significantly outperforming the second-best baseline, TiDE multivariate ($p < 0.001$, Wilcoxon signed-rank test). Error bars and numbers in parentheses denote the Interquartile Range (IQR) across variables. ZS denotes zero-shot, FT is fine tuned, Uni is univariate input, Multi is multivariate input.
  • Figure 3: GDT demonstrates improved risk stratification in predicting survival, progression, and switching therapy, while metastasis prediction remains constrained by limited data availability. We report the mean IPCW C-Index (higher is better) and standard error across 20 indications for a) survival, b) disease progression, c) switching therapy, and d) metastasis. GDT demonstrates robust ranking capabilities, outperforming the strongest baselines in 12 of 16 evaluated time points. Lower performance is seen in predicting metastasis outcomes, likely due to low data availability ($N=3$ indications).
  • Figure 4: GDT with supervised fine-tuning (SFT) outperforms baselines on out-of-distribution clinical trial tasks. The model is evaluated on the unseen trials a-c) POPLAR and d-f) IMpower130. GDT (SFT) achieves the lowest MASE (Mean Absolute Scaled Error - lower is better; IQR error bars across 17 variables) in blood biomarker forecasting (a, d) and highest C-Indexes (higher is better) for survival (b, e) and progression (c, f) events, demonstrating strong generalization in cold start scenarios where historical data is sparse. ZS denotes zero-shot predictions, FT means the model is fine-tuned, whilst Uni is univariate input, Multi is multivariate input, RSF is Random Survival Forest.
  • Figure 5: Forecasting error as a function of training sample size. Evaluated on the test set of the POPLAR trial, using Mean Absolute Scaled Error (MASE), relative to training samples from the OAK trial (log X-axis; error bars denote IQR across 17 variables). Zero-shot performance is competitive, while low-data fine-tuning shows an initial error increase before stabilizing and improving at higher counts ($all \approx 880$/variable).
  • ...and 11 more figures