Manuscript Offprint

arXiv:2611.07291

How do Transformers Perform Low-Level Control In-Context?

Ebonye Smith, Aidan Andrews, Phoenix Wilson, Alexis Frias, Ayush Pandey, Gireeja Ranade

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Ebonye Smith¹, Aidan Andrews², Phoenix Wilson¹, Alexis Frias³, Ayush Pandey⁴, and Gireeja Ranade¹

Abstract—One of the remarkable abilities of Transformer-based neural networks is in-context learning. This motivates us to think about “in-context” control. Can we control a system knowing only (1) that it belongs to a particular family of systems and (2) some data on system evolution (provided as the context trajectory) but no specific parameter information? Specifically, we investigate the ability of Transformer-models to perform “in-context” control of unstable, nonlinear dynamical systems, where context consists only of the unforced system dynamics. We leverage a multi-head, GPT-2-style architecture, and we evaluate performance for two classical nonlinear systems – the cartpole system and the two-link acrobot system, where the system parameters are unknown to the Transformer. We consider a setting where trajectories from an expert controller are available at training time but not at inference time. Here, we identify training techniques that are essential to train Transformers to perform low-level control. Through an analysis over checkpoints, we show that in-context control is possible, and the learned policy performance generally improves as context increases. Furthermore, the Transformer models can generalize to stabilize systems that are out-of-distribution.

I. INTRODUCTION

A key property of Transformers driving its performance is in-context learning (ICL), which enables the model to adapt to new tasks at inference time via a context prompt without updating model weights [1]–[4]. While ICL has been studied for linear regression [5], filtering [6], and mid-level robotic control [7], its application to the low-level, closed-loop stabilization of unstable, underactuated, nonlinear systems remains largely unexplored.

Stabilizing an unstable system with partially unknown dynamics traditionally requires system identification [8] or direct synthesis of a data-driven controller [9]. Building on the paradigm of universal control [10], we aim to realize a single policy capable of stabilizing an entire parametric family of systems without explicit parameter estimation or weight updates. Under this setting, parameter identification is

shifted from offline pre-processing to an in-context operation at test time.

Reinforcement learning algorithms are commonly used for tasks like stabilization of underactuated systems [11], [12], however we are interested in investigating how ICL capabilities of Transformers along with architectural and training design choices contribute to similar task success. The primary contributions of this work are¹:

  • Analysis of emergent in-context capabilities: We investigate how stabilization scales with context length and model training demonstrating that ICL emerges as training progresses. Extended training shows evidence of data memorization which contributes to some cases of successful generalization to out-of-distribution data.
  • Robustness via Gaussian perturbations: We inject state-level Gaussian noise during expert data generation. Without this, in-distribution stabilization success on the Cartpole collapses to 5% with 50 context examples (from 86% with perturbation), confirming that exposure to driving disturbances proves essential.
  • Empirical validation on nonlinear benchmarks: We evaluate our architecture on underactuated Cartpole [13] and Acrobot [14] systems, achieving up to 86% (Cart-pole) and 74% (Acrobot) in-distribution stabilization success at the longest context length.

References (37)