Transformers for dynamical systems learn transfer operators in-context
Anthony Bao, Jeffrey Lai, William Gilpin
TL;DR
The paper investigates how a small transformer trained on a univariate dynamical trajectory can generalize to forecast unseen dynamical systems without retraining, illuminating the mechanism of in-context learning in physics. It demonstrates that the model spontaneously performs time-delay embedding and implicitly learns a transfer operator (Perron-Frobenius) for the underlying system, matching long-timescale dynamics and metastable structures. By comparing the transformer's inferred operator to fully observed operators via Ulam's method, the study shows that in-context learning yields faithful representations of the system's attractor and dominant modes. These findings reveal a concrete mechanism by which pretrained models generalize to unseen physical systems and underscore the role of global attractor information in short-term forecasting.
Abstract
Large-scale foundation models for scientific machine learning adapt to physical settings unseen during training, such as zero-shot transfer between turbulent scales. This phenomenon, in-context learning, challenges conventional understanding of learning and adaptation in physical systems. Here, we study in-context learning of dynamical systems in a minimal setting: we train a small two-layer, single-head transformer to forecast one dynamical system, and then evaluate its ability to forecast a different dynamical system without retraining. We discover an early tradeoff in training between in-distribution and out-of-distribution performance, which manifests as a secondary double descent phenomenon. We discover that attention-based models apply a transfer-operator forecasting strategy in-context. They (1) lift low-dimensional time series using delay embedding, to detect the system's higher-dimensional dynamical manifold, and (2) identify and forecast long-lived invariant sets that characterize the global flow on this manifold. Our results clarify the mechanism enabling large pretrained models to forecast unseen physical systems at test without retraining, and they illustrate the unique ability of attention-based models to leverage global attractor information in service of short-term forecasts.
