TL;DR
This paper introduces CALM-DT (Context-Adaptive Language Model-based Digital Twin), a novel framework that frames digital twinning as an in-context learning problem using Large Language Models (LLMs). By leveraging natural language as a flexible interface, CALM-DT can seamlessly adapt to new variables, data, and actions at inference time without requiring architectural redesigns or model retraining.
What Problem Does This Paper Address?
Digital Twins (DTs)—computational models that simulate real-world system dynamics—are highly valuable for scenario planning in fields like manufacturing, climate science, and medicine. However, traditional DTs are notoriously rigid. Whether they are built on expert-derived mechanistic equations or data-driven deep learning architectures, they operate within fixed state-action dimensions.
In dynamic, real-world settings, the environment constantly evolves. For instance, in clinical medicine, a breakthrough drug might suddenly be approved, or new patient registries might release fresh data. Traditional DTs cannot easily absorb these changes; incorporating a new variable or treatment option requires human experts to manually rewrite equations or completely retrain neural networks. This paper tackles the challenge of building a DT that can continuously update and adapt on the fly.
Methods
The authors propose CALM-DT, an LLM-agnostic framework that treats digital twinning as an in-context learning task. Because LLMs process free-form text, they decouple the DT from rigid numerical schemas, satisfying the need for flexible dimensionality.
To make this work effectively over long simulation horizons without overloading the LLM's finite context window, CALM-DT uses a three-stage iterative loop:
- Information Retrieval: A fine-tuned bi-encoder framework filters a dataset of related trajectories ($D_\tau$) and extracts relevant domain knowledge ($K_\tau$). To help the encoder recognize temporal patterns in raw numbers, the authors use an LLM to generate natural language trend summaries (e.g., "increasing", "stable") and append them to the trajectories. The encoders are fine-tuned via contrastive learning using InfoNCE loss, driven by LLM performance feedback.
- Prompt Formulation: The retrieved text descriptions, historical context samples, and the target system's history are structured into a natural language prompt.
- Generation: The LLM estimates the transition distribution, predicting the next state in natural language. An inverse mapping function converts this text back into a structured state representation, an action is sampled from a policy, and the history is updated.
Crucially, if a new action is taken or a resampling buffer is exceeded, CALM-DT dynamically adjusts the context mid-generation to ensure maximum relevance to the current simulation state.
Datasets
The framework was evaluated across multiple distinct environments:
- Cystic Fibrosis (CF) Progression: Real-world patient data from the 2008-2013 UK CF Registry (1,000 training trajectories) tracking critical health metrics like lung function ($\text{FEV}_1\text{PP}$), weight, and height under treatment.
- Tumor Growth (NSCLC): 500 synthetic trajectories of non-small cell lung cancer progression under combined chemo- and radiotherapy, generated from a standard pharmacokinetic-pharmacodynamic model.
- Ecological Dynamics: Small-data benchmarks tracking ditrophic Hare-Lynx and tritrophic Algae-Flagellate-Rotifer population dynamics to test performance under simple, action-free settings.
Key Insights and Ideas
- Natural Language as a Universal Interface: By mapping arbitrary state-action spaces to text, LLMs can simulate systems without being bound to fixed vector dimensions.
- Zero-Retraining Adaptation: Because the model relies entirely on in-context learning, updating the digital twin with a new drug or new data simply requires updating the text prompt or the retrieval database—no weights are changed.
- Textual Anchors for Time-Series Retrieval: Purely numerical time-series data can lead encoders to latch onto spurious correlations during fine-tuning. Appending high-level semantic summaries (e.g., "variable X is decreasing") acts as a crucial anchor that significantly boosts retrieval quality.
Key Results
- State-of-the-Art Performance: In fixed environments, CALM-DT achieved the best overall ranking against traditional baselines (including Transformers, RNNs, Neural ODEs, and mechanistic discovery methods like SINDy), achieving the lowest Mean Squared Error (MSE) and Mean Absolute Error (MAE) on the CF dataset.
- Scaling and Context Saturation: Ablation studies showed that simulation accuracy scales robustly with base LLM capacity (e.g., GPT-4o outperforming GPT-4o Mini and GPT-3.5 Turbo). Performance gains peaked at around $c=5$ context samples, showing that overloading the context window degrades simulation quality.
- Seamless Adaptation to Novel Actions: When simulating the introduction of the real-world CF drug Ivacaftor (blinded as Drug X), CALM-DT successfully leveraged natural language clinical trial descriptions and newly available post-treatment data to improve its three-year simulation accuracy without any parameter updates.
Limitations and Future Work
Despite its strong performance, CALM-DT has a few notable limitations:
- Inference Speed & Cost: Calling encoders and LLMs multiple times mid-generation makes inference significantly slower and potentially more expensive (via API costs) than traditional models.
- LLM Artifacts: The framework remains susceptible to standard LLM weaknesses, such as hallucinations (unlikely spikes/dips violating domain constraints) and tokenization issues with high-precision numerical tasks.
Future Directions: The authors suggest integrating causal graphs to enforce known physical or biological relationships and expanding the retrieval mechanism to ingest large, unstructured text corpora.
Summary updated