Understanding the Training and Generalization of Pretrained Transformer for Sequential Decision Making

Hanzhao Wang, Yu Pan, Fupeng Sun, Shang Liu, Kalyan Teja Talluri, Guanting Chen, Xiaocheng LiSubmission to ICLR 2025 · Rejected

TL;DR

Transformers can learn effective sequential decision-making algorithms directly from simulated data by framing the problem as supervised learning with ground-truth optimal actions. To prevent severe out-of-distribution (OOD) shift between training and test rollouts, the authors introduce a mixed-training strategy that injects transformer-generated trajectories during pre-training, resulting in models that substantially outperform classical algorithms like UCB and Thompson sampling—especially on short horizons and under model misspecification.

What Problem Does This Paper Address?

Applying Decision Transformers (DT) to reinforcement learning often relies on imitation learning or conditioning on cumulative "returns-to-go." In stochastic environments, these approaches frequently degrade due to survival bias and compounding distribution shifts.

This paper investigates stateless sequential decision problems—such as multi-armed bandits, contextual linear bandits, dynamic pricing, and newsvendor inventory control. In these settings, environments lack complex state transition matrices, allowing the exact Bayes-optimal action to be computed in simulation.

However, two major challenges arise when training transformers to predict optimal actions:

  1. The Out-of-Distribution (OOD) Shift: During training, past actions in the prompt history are drawn from a fixed behavioral policy ($f$). At test time, past actions are generated autoregressively by the transformer itself ($TF_\theta$). This mismatch can cause theoretical performance guarantees to collapse exponentially in the horizon ($T$).
  2. The Exploration Dilemma: Purely predicting the Bayes-optimal action creates an algorithm that purely exploits, which can cause the policy to get stuck and suffer linear regret ($\Omega(T)$) due to lack of exploration.

Methods

  • Surrogate Loss Framework: The authors establish that minimizing standard supervised losses serves as a rigorous upper bound on cumulative regret (cross-entropy for discrete bandits, squared error for dynamic pricing, and absolute error for linear bandits/newsvendor).
  • Two-Phase Mixed Pre-Training (Algorithm 1):
  • Phase 1 (Early Training): The transformer is trained on simulated trajectories where historical actions are generated by a baseline heuristic $f$ with decaying noise.
  • Phase 2 (Mixed Training): The training batches blend trajectories generated by $f$ with rollouts generated autoregressively by the current model checkpoint $TF_{\theta_m}$ (at a ratio of $\kappa : 1-\kappa$, with $\kappa = 1/3$).
  • Curriculum Learning: Models are trained using progressively longer sequence lengths (starting at $T=20$ and scaling up to $T=100$).
  • Architecture: A 12-layer GPT-2 backbone (16 heads, 256 embedding dimension) taking interleaved context/observation and action tokens as inputs.

Datasets

The authors evaluate on four canonical synthetic sequential decision tasks generated from continuous parameter priors $P_\gamma$:

  • Stochastic Multi-Armed Bandits: 20 arms with Gaussian reward noise.
  • Linear Bandits: 2-dimensional unit-sphere action space.
  • Contextual Dynamic Pricing: 6-dimensional context vectors with unknown linear and quadratic demand functions.
  • Contextual Newsvendor: 4-dimensional context with censored demand and asymmetric inventory costs.

Experiments test both seen finite environment pools (4, 16, or 100 environments) and infinite continuous environment distributions where every test task is strictly unseen.

Key Insights and Ideas

  • Framing as Performative Prediction: Training an autoregressive policy alters the distribution of future inputs. The authors show that when the transformer model class is sufficiently expressive, the optimization landscape avoids the typical oscillatory instability of performative prediction.
  • Serendipitous Exploration via Imperfection: The theoretical ideal Bayes-predictor $\text{Alg}^*$ strictly exploits and can suffer linear $\Omega(T)$ regret. Crucially, the slight neural network prediction errors ($\Delta_{\text{Exploit}}$) introduce stochastic perturbation ($\Delta_{\text{Explore}}$), inadvertently providing the exact exploration needed for posterior environment identification.
  • Greedy Dominance on Short Horizons ($T \le 100$): Classical algorithms (LinUCB, Thompson Sampling) are engineered for asymptotic optimality ($\sqrt{T}$ or $\log T$), often over-exploring early on. Transformers leverage pre-trained prior distributions to exploit immediately.
  • Robustness to Misspecification: When tested on mixtures of linear and quadratic demand, traditional parametric algorithms degrade because their structural assumptions are violated. The transformer handles both seamlessly because its pre-training spans multiple model classes.

Key Results

At test horizon $T = 100$ on unseen environments, the pre-trained transformer achieves lower cumulative regret than standard algorithms across the board:

Task Pre-trained Transformer ($TF_{\hat{\theta}}$) Strongest Benchmark Regret
Multi-Armed Bandits (20 arms) 44.42 71.76 (UCB) / 127.3 (TS)
Linear Bandits ($d=2$) 7.67 10.44 (LinUCB) / 30.01 (LinTS)
Dynamic Pricing ($d=6$) 8.46 20.99 (CILS) / 21.25 (ILSE)
Newsvendor ($d=4$) 3.44 26.11 (ERM) / 32.91 (FAI)

Under severe model misspecification (quadratic pricing demand), benchmark algorithms exploded to regrets between $636$ and $946$, whereas the transformer achieved $204.04$. Comparisons with Online Decision Transformer (ODT) demonstrated that ODT fails entirely when deployed across unseen test environments, performing on par with random action selection.

Limitations and Future Work

  • Absence of State Transitions: The framework explicitly relies on problems where the current action does not change future environmental states (ruling out general Markov Decision Processes like robotics or navigation).
  • Computation in Training: Generating self-rollouts during the mixed-training phase adds noticeable computational overhead during pre-training.
  • Stylized Theoretical Assumptions: The regret bound in Proposition 4.4 relies on uniform KL divergence and sub-Gaussian margin conditions across the environment support, which acts as a simplified theoretical model rather than a fully general bound. Extending this framework to continuous latent environments via non-parametric covering remains an open direction.

Summary updated

Abstract

In this paper, we consider the supervised pre-trained transformer for a class of sequential decision-making problems. The class of considered problems is a subset of the general formulation of reinforcement learning in that there is no transition probability matrix; though seemingly restrictive, the subset class of problems covers bandits, dynamic pricing, and newsvendor problems as special cases. Such a structure enables the use of optimal actions/decisions in the pre-training phase, and the usage also provides new insights for the training and generalization of the pre-trained transformer. We first note the training of the transformer model can be viewed as a performative prediction problem, and the existing methods and theories largely ignore or cannot resolve an out-of-distribution issue. We propose a natural solution that includes the transformer-generated action sequences in the training procedure, and it enjoys better properties both numerically and theoretically. The availability of the optimal actions in the considered tasks also allows us to analyze the properties of the pre-trained transformer as an algorithm and explains why it may lack exploration and how this can be automatically resolved. Numerically, we categorize the advantages of pre-trained transformers over the structured algorithms such as UCB and Thompson sampling into three cases: (i) it better utilizes the prior knowledge in the pre-training data; (ii) it can elegantly handle the misspecification issue suffered by the structured algorithms; (iii) for short time horizon such as $T\le50$, it behaves more greedy and enjoys much better regret than the structured algorithms designed for asymptotic optimality.
BibTeX
@misc{wang2024understanding,
  author = {Hanzhao Wang and Yu Pan and Fupeng Sun and Shang Liu and KALYAN TEJA TALLURI and Guanting Chen and Xiaocheng Li},
  title = {{Understanding the Training and Generalization of Pretrained Transformer for Sequential Decision Making}},
  year = {2024},
  eprint = {2405.14219},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.14219},
}
Figure