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

## Abstract

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 ≤ 50 𝑇 50 T\leq 50 italic_T ≤ 50 , it behaves more greedy and enjoys much better regret than the structured algorithms designed for asymptotic optimality.

## 1 Introduction

In recent years, transformer-based models (Vaswani et al., ) have achieved great success in a wide range of tasks such as natural language processing (Radford et al., ; Bubeck et al., ), computer vision (Dosovitskiy et al., ), and also reinforcement learning (RL) (Chen et al., ). In particular, an offline RL problem can be framed as a sequence prediction problem (Ding et al., ) that predicts the optimal/near-optimal/human action based on the observed history. Chen et al. (); Janner et al. () pioneer this approach with the Decision Transformer (DT), which leverages the auto-regressive nature of transformers to maximize the likelihood of trajectories in offline datasets. In this paper, we focus on a subset class of reinforcement learning problems, which we call sequential decision-making problems, that has no transition probability matrix compared to a general RL problem. This subset of problems are general enough to capture a wide range of applications including stochastic and linear bandit problems (Lattimore and Szepesvári, ), dynamic pricing (Den Boer, ; Cohen et al., ), and newsvendor problem (Levi et al., ; Besbes and Muharremoglu, ). Most importantly, the structure brings two benefits: (i) pre-training – the optimal action is either in closed form or efficiently solvable and thus the optimal action can be used as the prediction target in the pre-training data and (ii) understanding – the setting is more aligned with the existing study (Xie et al., ; Garg et al., ) on the in-context learning ability of the transformer which gives more insight to the working machinery of transformer on decision-making tasks. Moreover, as a side product, our paper extends pre-trained transformers to the application contexts of business, economics, and operations research which are less studied by the existing works.

Figure: Figure 1: Comparison between the pre-trained transformer framework and traditional sequential decision-making methods (such as the structured algorithm of UCB and Thompson sampling). For traditional methods, the decision-making agent (or policy) interacts directly with a single environment sampled from the real environment distribution, focusing on exploration and exploitation within that specific environment. In contrast, the pre-trained transformer is trained across multiple environments sampled from a simulator distribution. During pre-training, the transformer collects trajectories and updates its parameters by interacting with diverse environments. Once pre-trained, the transformer functions works as an algorithm and can be applied effectively in the real environment just as the structured algorithms. But unlike the structured algorithms, the pre-trained transformer leverages the huge amount of pre-training data sampled from the simulation environment.
Refer to caption: extracted/5895775/new_figs/flow.jpg

To summarize, we work on the following aspects in this paper:

- The pre-training procedure (Section 3): We mathematically formulate the learning setup of supervised pre-trained transformer for sequential decision-making problems, and propose a standardized procedure to generate the pre-training data. In addition, for the training process, we identify an out-of-distribution (OOD) issue largely ignored or unsolved by the existing literature. Specifically, the pre-training data involves two streams of actions – one is the actions in the history (features), and the other is the action to predict (target).
Lin et al. () show that when both streams are generated by one structured algorithm (say UCB or Thompson sampling), the pre-training of the transformer will result in an imitation learning procedure that imitates the structured algorithm at best. If one desires to obtain a better algorithm than the structured algorithm, like using the optimal action (Lee et al., ) as the target to predict in our case, this will cause the OOD issue (reflected by an $\Theta(\exp T)$ factor in the regret bound of Lin et al. ()). To resolve this matter, we propose an algorithmic solution by injecting the transformer-generated action sequence into the pre-training data, and this also draws a connection with the problem of performative prediction (Perdomo et al., ).

- Understanding transformers as decision makers (Section 4): The structure of sequential decision-making problems enables the usage of optimal actions in pre-training data, and as noted earlier and will be exemplified throughout our paper, this brings benefits for both training and theoretical understanding. First, we connect the pre-trained transformer with the existing literature studying in-context learning (Xie et al., ; Zhang et al., ; Bai et al., ) and we establish the pre-trained transformer as a near Bayes-optimal predictor for the optimal action in a Bayesian sense. Next, we show that (i) why the transformer model exhibits a lack of exploration and (ii) how it achieves a paramount or better performance than the structured algorithms. Other than these, an important aspect is that the problem structure of sequential decision-making renders the setup of our pre-trained transformer different from the existing works that also involve interactions with the underlying environment under the general RL setup. For example, the Online Decision Transformer (ODT) (Zheng et al., ) lets the transformers interact with the underlying environment during the training phase, but the interactions are limited to a single environment and are designed to explore better trajectories or policies within that environment than the given offline data. We defer a more detailed comparison between the existing usage of pre-trained transformers on general RL problems and our framework to Appendix A.2.

- Numerically, when and why the pre-trained transformer is better than the structured algorithms (Section 5): While there are many structured algorithms such as UCB and Thompson sampling for each of the decision-making problems that the transformer model is applied to, the question is whether and when the transformer can achieve a better performance than these algorithms. We use numerical experiments to attribute the advantage of the pre-trained transformer into three scenarios: (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\leq 50$ or $100$, it behaves more greedy and enjoys much better regret than the structured algorithms which are designed for asymptotic optimality.

We defer more discussions on the related works to Section A.

## 2 Problem Setup

In this section, we introduce a general formulation for sequential decision-making and describe the setup of supervised pre-training. An agent (decision maker) makes decisions in a sequential environment. The full procedure is described by the sequence

$$ $(X_{1},a_{1},o_{1},X_{2},a_{2},o_{2},\ldots,X_{T},a_{T},o_{T}).$ $$

Here $T$ is the horizon. At each time $t=1,\ldots,T$, the agent first observes a context vector $X_{t}\in\mathcal{X}\subset\mathbb{R}^{d}$ and takes the action/decision $a_{t}\in\mathcal{A}$, and then observes an outcome $o_{t}\in\mathcal{O}\subset\mathbb{R}^{k}$. Define the history

$$ $H_{t}\coloneqq(X_{1},a_{1},o_{1},\ldots,X_{t-1},a_{t-1},o_{t-1},X_{t}),$ $$

and the agent’s decision $a_{t}$ is based on $H_{t}$, i.e., non-anticipatory. In this light, we can model the decision as a function of $H_{t}$,

$$ $a_{t}=\texttt{TF}_{\theta}(H_{t})$ $$

where $\theta$ encapsulates all the parameters of the function. That is, the agent learns from the past interactions with the underlying environment – tuples of $(X_{t},a_{t},o_{t})$’s to optimize future decisions, and this process that transfers the past knowledge to the future is described by the function $\texttt{TF}_{\theta}$. The function $\texttt{TF}_{\theta}$ can take as inputs a variable-length sequence ($H_{t}$ can be of variable length), which is the case for the generative pre-trained transformers (Radford et al., ).

### 2.1 Environment and performance metrics

The function $\texttt{TF}_{\theta}$ describes how the actions $a_{t}$’s are generated. Now we describe how $X_{t}$’s and $o_{t}$’s are generated. Assume the context $X_{t}$’s are i.i.d. and $o_{t}$ follows a conditional distribution given $X_{t}$ and $a_{t}$

$$ $X_{t}\overset{\text{i.i.d.}}{\sim}\mathbb{P}_{\gamma}(\cdot),\ o_{t}\overset{ \text{i.i.d.}}{\sim}\mathbb{P}_{\gamma}(\cdot|X_{t},a_{t})$ (1) $$

where $\gamma$ encapsulates all the parameters for these two probability distributions. In particular, we emphasize that the parameter $\gamma$ is unknown to the agent.

At each time $t$, the agent collects a random reward $R_{t}=R(X_{t},a_{t})$ which depends on $X_{t}$, $a_{t},$ and also some possible exogenous randomness. The observation $o_{t}$ includes $R_{t}$ as its first coordinate. The expected reward is defined by $r(X_{t},a_{t})=\mathbb{E}[R(X_{t},a_{t})|X_{t},a_{t}]$. Specifically, this reward function $r(\cdot,\cdot)$ is unknown to the agent and it also depends on the underlying environment $\gamma$.

The performance of the agent, namely, the decision function $\texttt{TF}_{\theta}$, is usually measured by the notion of regret, which is defined by

$$ $\text{Regret}(\texttt{TF}_{\theta};\gamma)\coloneqq\mathbb{E}\left[\sum_{t=1}^ {T}r(X_{t},a_{t}^{*})-r(X_{t},a_{t})\right]$ (2) $$

where the action $a_{t}^{*}$ is the optimal action that maximizes the reward

$$ $a_{t}^{*}\coloneqq\operatorname*{arg\,max}_{a\in\mathcal{A}}\ r(X_{t},a)$ (3) $$

and the optimization assumes the knowledge of the underlying environment, i.e., the parameter $\gamma$. In the regret definition (2), the expectation is taken with respect to the underlying probability distribution (1) and possible randomness in the agent’s decision function $\texttt{TF}_{\theta}$. We use the arguments $\texttt{TF}_{\theta}$ and $\gamma$ to reflect the dependency of the regret on the decision function $\texttt{TF}_{\theta}$ and the environment $\gamma.$ Also, we note that the benchmark is defined as a dynamic oracle where $a_{t}^{*}$ maybe different over time. Regret is not a perfect performance measure for the problem, and we also do not believe the algorithm design for sequential decision-making problems should purely aim for getting a better regret bound. Despite this, it serves as a good monitor for the effectiveness of the underlying learning and the optimization procedure.

### 2.2 Supervised pre-training

In the classic study of these sequential decision-making problems, the common paradigm is to assume some structure for the underlying environment and/or the reward function, and to design algorithms accordingly. These algorithms are often known as online or reinforcement learning algorithms and are usually hard to combine with prior knowledge such as pre-training data. Comparatively, the supervised pre-training formulates the decision-making problem as a supervised learning prediction task that predicts the optimal or a near-optimal action, and thus it can utilize the vast availability of pre-training data that can be generated from simulated environments.

Specifically, the supervised pre-training first constructs a pre-training dataset

$$ $\mathcal{D}_{\text{PT}}\coloneqq\left\{\left(H_{1}^{(i)},a_{1}^{(i)*}\right), \left(H_{2}^{(i)},a_{2}^{(i)*}\right),\ldots,\left(H_{T}^{(i)},a_{T}^{(i)*} \right)\right\}_{i=1}^{n}.$ $$

In particular, we assume the parameter $\gamma$ (see (1)) that governs the generation of $X_{t}$ and $o_{t}$ are generated from some environment distribution $\mathcal{P}_{\gamma}$. Then, we first generate $n$ environments denoted by $\gamma_{1},\ldots,\gamma_{n}.$ Then there are two important aspects with regard to the generation of $\mathcal{D}_{\text{PT}}$:

- Action $a_{t}^{(i)*}$: For this paper, we generate $a_{t}^{(i)*}$ as the optimal action specified by (3) and this requires the knowledge of the underlying environment $\gamma_{i}.$ A common property of all these sequential decision-making problems is that the optimal action can be easily or often analytically computed. Other option is also possible, say, $a_{t}^{(i)*}$ can be generated based on some expert algorithms such as Thompson sampling or UCB algorithms. In this case, the action $a_{t}^{(i)*}=\texttt{Alg}(H_{t}^{(i)})$ where $\texttt{Alg}(\cdot)$ represents the algorithm that maps from $H_{t}^{(i)}$ to the action without utilizing knowledge of $\gamma_{i}.$

- History $H_{t}^{(i)}=\left(X_{1}^{(i)},a_{1}^{(i)},o_{1}^{(i)},\ldots,X_{t-1}^{(i)},a_{
t-1}^{(i)},o_{t-1}^{(i)},X_{t}^{(i)}\right).$ Note that $X_{t}^{(i)}$’s and $o_{t}^{(i)}$’s are generated based on the parameter $\gamma_{i}$ following (1). The action $a_{t}^{(i)}$ is generated based on some pre-specified decision function $f$ in a recursive manner:

$$ $a_{t}^{(i)}=f\left(H_{t}^{(i)}\right),\ \ H_{t+1}^{(i)}=\left(H_{t}^{(i)},a_{t }^{(i)},o_{t}^{(i)},X_{t+1}^{(i)}\right)$ (4) $$

for $t=1,\ldots,T.$

Formally, we define a distribution $\mathcal{P}_{\gamma,f}$ that generates $H_{t}$ and $a_{t}^{*}$ as

$$ $X_{\tau}\sim\mathbb{P}_{\gamma}(\cdot),\ a_{\tau}=f(H_{\tau}),\ o_{\tau}\sim \mathbb{P}_{\gamma}\left(\cdot|X_{\tau},a_{\tau}\right),\ H_{\tau+1}=\left(H_{ \tau},a_{\tau},o_{\tau},X_{\tau+1}\right).$ (5) $$

for $\tau=1,\ldots,t-1$ and $a_{t}^{*}$ is specified by (3).
The parameter $\gamma$ and the function $f$ jointly parameterize the distribution $\mathcal{P}_{\gamma,f}$. The parameter $\gamma$ governs the generation of $X_{t}$ and $o_{t}$ just as in (1). The decision function $f$ maps from the history to the action and it governs the generation of $a_{\tau}$’s in the sequence $H_{t}$. In this way, the pre-training data is generated with the following flow:

$$ $\mathcal{P}_{\gamma}\rightarrow\gamma_{i}\rightarrow\mathcal{P}_{\gamma_{i},f} \rightarrow\left\{\left(H_{1}^{(i)},a_{1}^{(i)*}\right),\ldots,\left(H_{T}^{(i )},a_{T}^{(i)*}\right)\right\}$ $$

where $f$ is a prespecified decision function used to generate the data.

Based on the dataset $\mathcal{D}_{\text{PT}}$, the supervised pre-training refers to the learning of the decision function $\texttt{TF}_{\theta}$ through minimizing the following empirical loss

$$ $\hat{\theta}\coloneqq\operatorname*{arg\,min}_{\theta}\frac{1}{nT}\sum_{i=1}^{ n}\sum_{t=1}^{T}l\left(\texttt{TF}_{\theta}\left(H_{t}^{(i)}\right),a_{t}^{(i) *}\right)$ (6) $$

where the loss function $l(\cdot,\cdot):\mathcal{A}\times\mathcal{A}\rightarrow\mathbb{R}$ specifies the prediction loss. Thus the key idea of supervised pre-training is to formulate the sequential decision-making task as a sequence modeling task that predicts the optimal action $a_{t}^{(i)*}$ given the history $H_{t}^{(i)}$.

In the test phase, a new environment parameter $\gamma$ is generated from $\mathcal{P}_{\gamma}$ and we apply the learned decision function $\texttt{TF}_{\hat{\theta}}$. Specifically, the procedure is described by

$$ $X_{\tau}\sim\mathbb{P}_{\gamma}(\cdot),\ a_{\tau}=\texttt{TF}_{{\hat{\theta}}} (H_{\tau}),\ o_{\tau}\sim\mathbb{P}_{\gamma}\left(\cdot|X_{\tau},a_{\tau} \right),\ H_{\tau+1}=\left(H_{\tau},a_{\tau},o_{\tau},X_{\tau+1}\right).$ (7) $$

The only difference between the test dynamics (7) and the training dynamics (5) is that the action $a_{t}$ (or $a_{\tau}$) is generated by $\texttt{TF}_{{\hat{\theta}}}$ instead of the pre-specified decision function $f$. In this way, we can write $(H_{t},a_{t}^{*})\sim\mathcal{P}_{\gamma,\texttt{TF}_{\theta}}$ for the test phase. Accordingly, we can define the expected loss of the decision function $\texttt{TF}_{\theta}$ under the environment specified by $\gamma$ as

$$ $L\left(\texttt{TF}_{\theta};\gamma\right)\coloneqq\mathbb{E}_{(H_{t},a_{t}^{*} )\sim\mathcal{P}_{\gamma,\texttt{TF}_{\theta}}}\left[\sum_{t=1}^{T}l\left( \texttt{TF}_{\theta}\left(H_{t}\right),a_{t}^{*}\right)\right]$ (8) $$

where the expectation is taken with respect to $X_{t}$, $o_{t}$ and the possible randomness in $a_{t}.$ As before, $a_{t}^{*}$ are the optimal action defined by (3) and obtained from the knowledge of $\gamma$.

We defer discussions on how various sequential decision-making problems can be formulated under the general setup above and how the pre-training loss is related to the regret to Section B.

## 3 Pre-training and Generalization

We first point out a subtle point of the supervised pre-training setting presented in the previous section. Unlike supervised learning, the expected loss (8) may not be equal to the expectation of the empirical loss (6).
As noted earlier, this is because in the sequence $H_{t}$, the action $a_{t}=\texttt{TF}_{{\hat{\theta}}}(H_{t})$ as in (7) during the test phase as opposed to that $a_{t}=f(H_{t})$ as in (5) for the pertraining data $\mathcal{D}_{\text{PT}}$. Taking expectation with respect to $\gamma$ in (8), we can define the expected loss as

$$ $L(\texttt{TF}_{\theta})\coloneqq\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}} \left[L(\texttt{TF}_{\theta};\gamma)\right].$ $$

However, the expectation of the empirical loss (6) is

$$ $L_{f}(\texttt{TF}_{\theta})\coloneqq\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma} }\left[L_{f}(\texttt{TF}_{\theta};\gamma)\right]$ (9) $$

where

$$ $L_{f}(\texttt{TF}_{\theta};\gamma)\coloneqq\mathbb{E}_{(H_{t},a_{t}^{*})\sim \mathcal{P}_{\gamma,f}}\left[\sum_{t=1}^{T}l\left(\texttt{TF}_{\theta}\left(H_ {t}\right),a_{t}^{*}\right)\right].$ $$

Here $f$ is the pre-specified decision function used in generating the pre-training data $\mathcal{D}_{\text{PT}}$. We note that the discrepancy between $L(\texttt{TF}_{\theta})$ and $L_{f}(\texttt{TF}_{\theta})$ is caused by the difference in the generations of the samples $(H_{t},a_{t}^{*})$, namely, $\mathcal{P}_{\gamma,\texttt{TF}_{\theta}}$ versus $\mathcal{P}_{\gamma,f}$; which essentially reduces to how the actions $a_{t}$’s are generated in $H_{t}$. In the training phase, this is generated based on $f$, while measuring the test loss requires that the actions to be generated are based on the transformer $\texttt{TF}_{\theta}.$ This discrepancy is somewhat inevitable because when generating the training data, there is no way we can know the final parameter $\hat{\theta}.$ Consequently, there is no direct guarantee on the loss for $L(\texttt{TF}_{\hat{\theta}};\gamma)$ or $L(\texttt{TF}_{\hat{\theta}})$ with $\hat{\theta}$ being the final learned parameter. This out-of-distribution (OOD) issue motivates the design of our algorithm.

Figure: Algorithm 1 Supervised pre-training transformers for sequential decision making

Algorithm 1 describes our algorithm to resolve the above-mentioned OOD issue between training and test. It consists of two phases, an early training phase and a mixed training phase. For the early training phase, the data are generated from the distribution $\mathcal{P}_{\gamma_{i},f}$, while for the mixed training phase, the data are generated from both $\mathcal{P}_{\gamma_{i},f}$ and $\mathcal{P}_{\gamma_{i},\texttt{TF}_{\theta_{t}}}$ with a ratio controlled by $\kappa$. The decision function $f$ can be chosen as a uniform distribution over the action space as in the literature (Chen et al., ; Zhang et al., ; Lee et al., ), or other more complicated options (details on the $f$ used in our experiments are provided in Appendix E.1.2). When there is no mixed phase, i.e., $M_{0}=M$, the algorithm recovers that of (Lee et al., ). Intuitively, the benefits of involving the data generated from $\mathcal{P}_{\gamma_{i},\texttt{TF}_{\theta_{t}}}$ is to make the sequences $H_{t}^{(i)}$’s in the training data closer to the ones generated from the transformer. For the mixed training phase, a proportion of the data is still generated from the original $\mathcal{P}_{\gamma_{i},f}$ because the generation from $\mathcal{P}_{\gamma_{i},\texttt{TF}_{\theta_{t}}}$ costs relatively more time. For our numerical experiments, we choose $\kappa=1/3.$

Figure: (a) Training dynamics
Refer to caption: extracted/5895775/figs/DP.png

As far as we know, this OOD matter is largely ignored in the existing empirical works on supervised pre-training transformers. Theoretically, Lee et al. () directly assumes the pre-trained transformer learns (for discrete action space) the optimal decision function $\texttt{Alg}^{*}$ defined in the next section and develops their theoretical results accordingly. Lin et al. () show that when (i) $a_{t}^{(i)*}$’s in the training data are no longer the optimal actions $a_{t}^{*}$ in our setting but generated from some algorithm Alg and (ii) the decision function $f=\texttt{Alg}$ in the distribution $\mathcal{P}_{\gamma_{i},f}$, the pre-trained transformer $\texttt{TF}_{\hat{\theta}}\rightarrow\texttt{Alg}$ as the number of training samples goes to infinity. We note that this only implies that the transformer model can imitate an existing algorithm $\texttt{Alg}.$ In other words, setting $f=\texttt{Alg}$ brings the theoretical benefits of consistency, but it excludes the possibility of using the optimal $a_{t}^{*}$ in the pre-training and thus makes it impossible for the pre-trained transformer $\texttt{TF}_{\hat{\theta}}$ to perform better than the algorithm Alg. When $f\neq\texttt{Alg}$, the OOD issue is reflected by the distribution ratio in Definition 5 of Lin et al. (); the ratio can be as large as $\Theta(\exp{T})$ and thus renders the regret bound to be a vacuous one on the order of $\Theta(\exp{T})$. Compared to these works, our algorithm provides an algorithmic approach to resolve the OOD issue.

Algorithm 1 from an optimization perspective can be viewed as an iterative procedure to optimize

$$ $\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}}\left[\mathbb{E}_{(H_{t},a_{t}^{*}) \sim\kappa\mathcal{P}_{\gamma,f}+(1-\kappa)\mathcal{P}_{\gamma,\texttt{TF}_{ \theta}}}\left[\sum_{t=1}^{T}l\left(\texttt{TF}_{\theta}\left(H_{t}\right),a_{ t}^{*}\right)\right]\right]$ $$

where both the input data pair $(H_{t},a_{t}^{*})$ and the prediction function involve the parameter $\theta$. This falls into the paradigm of performative prediction (Perdomo et al., ; Izzo et al., ; Mendler-Dünner et al., ) where the prediction model may affect the data generated to be predicted. In the literature of performative prediction, a critical matter is the instability issue which may cause the parameter $\theta_{m}$ to oscillate and not converge. Perdomo et al. () shows that the matter can be solved with strong conditions such as smoothness and strong convexity on the objective function. However, we do not encounter this instability in our numerical experiment, and we make an argument as the following claim. That is, when the underlying function class, such as $\{\texttt{TF}_{\theta}:\theta\in\Theta\}$ is rich enough, one does not need to worry about such instability.

###### Claim 3.1 .

The instability of a performative prediction algorithm and the resultant non-convergence does not happen when the underlying prediction function is rich enough.

The claim will be further reinforced by the optimal decision function $\texttt{Alg}^{*}$ and Proposition 4.1 in the next section. We also defer more discussions on the claim to Section D.1. While it brings a peace of mind from the optimization perspective, the following proposition justifies the mixed training procedure from a statistical generalization perspective.

###### Proposition 3.2 .

Suppose $\hat{\theta}$ is determined by (6) where $\kappa n$ data sequences are from $\mathcal{P}_{\gamma,f}$ and $(1-\kappa)n$ data sequences are from $\mathcal{P}_{\gamma,\texttt{TF}_{\tilde{\theta}}}$ for some parameter $\tilde{\theta}$.
For a Lipschitz and bounded loss $l$,
the following generalization bound holds with probability at least $1-\delta$,

$$ $\displaystyle L(\texttt{TF}_{\hat{\theta}})$ $\displaystyle\leq\hat{L}(\texttt{TF}_{\hat{\theta}})+\sqrt{\frac{\mathrm{Comp} (\{\texttt{TF}_{\theta}:\theta\in\Theta\})}{nT}}$ $\displaystyle+O\left(\kappa T\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}}\left[ W_{1}\left(\mathcal{P}_{\gamma,f},\mathcal{P}_{\gamma,\texttt{TF}_{\hat{\theta }}}\right)\right]+(1-\kappa)T\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}}\left[ W_{1}\left(\mathcal{P}_{\gamma,\texttt{TF}_{\tilde{\theta}}},\mathcal{P}_{ \gamma,\texttt{TF}_{\hat{\theta}}}\right)\right]+\sqrt{\frac{\log\left(\frac{1 }{\delta}\right)}{nT}}\right)$ $$

where $\mathrm{Comp}(\cdot)$ denotes some complexity measure and $W_{1}(\cdot,\cdot)$ is the Wasserstein-1 distance. The notation $O(\cdot)$ omits the boundedness parameters.

The proof of Proposition 3.2 is not technical and follows the standard generalization bound (Mohri et al., ) together with the OOD analysis (Ben-David et al., ). We hope to use the result to provide more insights into the training procedure. The parameter $\tilde{\theta}$ can be interpreted as close to $\hat{\theta}$ as in the design of our algorithm. This will result in the term related to the distance between $\mathcal{P}_{\gamma,\texttt{TF}_{\tilde{\theta}}}$ and $\mathcal{P}_{\gamma,\texttt{TF}_{\hat{\theta}}}$ small. At the two ends of the spectrum, when $\kappa=1$, it will result in a large discrepancy between the training and the test data and thus the right-hand-side will explode; when $\kappa=0$, this will result in the tightest bound but it will cause more computational cost in the training procedure.

###### Claim 3.1 .

###### Proposition 3.2 .

## 4 Learned Decision Function as an Algorithm

In the previous section, we discuss the training and generalization aspects of the pre-trained transformer. Now, we return to the perspective of sequential decision-making and discuss the properties of the decision function when it is used as an algorithm.

In the ideal case, we define the Bayes-optimal decision function as follow

$$ $\displaystyle\texttt{Alg}^{*}(H)$ $\displaystyle\coloneqq\operatorname*{arg\,min}_{a\in\mathcal{A}}\mathbb{E} \left[l(a,a^{*}(H,\gamma))|H\right]$ $\displaystyle=\operatorname*{arg\,min}_{a\in\mathcal{A}}\int_{\gamma}l(a,a^{*} (H,\gamma))\mathbb{P}(H|\gamma)\mathrm{d}\mathcal{P_{\gamma}}$ $$

where $\mathcal{P}_{\gamma}$ is the environment distribution that generates the environment parameter $\gamma$, the optimal action $a^{*}(H,\gamma)$ depends on both the history $H$ and the environment parameter $\gamma$ (as defined in (3)), and $\mathbb{P}(H|\gamma)$ is proportional to the likelihood of observing the history $H$ under the environment $\gamma$

$$ $\mathbb{P}(H|\gamma)\propto\prod_{t=1}^{\tau}\mathbb{P}_{\gamma}(X_{t})\cdot \prod_{t=1}^{\tau-1}\mathbb{P}_{\gamma}(o_{t}|X_{t},a_{t})$ $$

where $H=(X_{1},a_{1},o_{1},\ldots,X_{\tau-1},a_{\tau-1},o_{\tau-1},X_{\tau})$ for some $\tau\in\{1,\ldots,T\}$ and the distributions $\mathbb{P}_{\gamma}(\cdot)$ and $\mathbb{P}_{\gamma}(\cdot|X_{t},a_{t})$ are as in (1). In the definition, the integration is with respect to the environment distribution $\mathcal{P}_{\gamma}$, and each possible environment $\gamma$ is weighted with the likelihood $\mathbb{P}(H|\gamma)$.

The following proposition relates $\texttt{Alg}^{*}(H)$ with the pre-training objective which justifies why it is called the optimal decision function. The loss function $L_{f}(\texttt{Alg})$ is defined as (9); recall that the decision function $f$ is used to generate the actions in $H_{t}$ and the decision function Alg is used to predict $a_{t}^{*}.$

###### Proposition 4.1 .

The following holds for any distribution $\mathcal{P}_{\gamma,f}$:

$$ $\texttt{Alg}^{*}(\cdot)\in\operatorname*{arg\,min}_{\texttt{Alg}\in\mathcal{F} }\ L_{f}(\texttt{Alg})=\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}}\left[ \mathbb{E}_{(H_{t},a_{t}^{*})\sim\mathcal{P}_{\gamma,f}}\left[\sum_{t=1}^{T}l \left(\texttt{Alg}\left(H_{t}\right),a_{t}^{*}\right)\right]\right]$ $$

where $\mathcal{F}$ is the family of all measurable functions (on a properly defined space that handles variable-length inputs). In particular, we can choose the decision function $f$ properly to recover the test loss $L(\texttt{TF}_{\theta})$ or the expected training loss $L_{f}(\texttt{TF}_{\theta})$ in Section 3.

Figure: (a) Dynamic pricing
Refer to caption: extracted/5895775/figs/DP/_4env_4d_132_Act_match_2.png

Proposition 4.1 states that the function $\texttt{Alg}^{*}$ is one minimizer of the expected loss under any distribution $\mathcal{P}_{\gamma,f}.$ To see this, $\texttt{Alg}^{*}$ is defined in a pointwise manner for every possible $H.$ The probability $\mathcal{P}_{\gamma,f}$ defines a distribution over the space of $H$. The pointwise optimality of $\texttt{Alg}^{*}$ easily induces the optimality of $\texttt{Alg}^{*}$ for any $\mathcal{P}_{\gamma,f}$. Furthermore, this implies that $\texttt{Alg}^{*}$ is also the optimal solution to the expected test loss and the expected training loss. This means that if the transformer class of $\texttt{TF}_{\theta}$ is rich enough to cover $\texttt{Alg}^{*}$, and with an infinite amount of data, the supervised pre-training will result in $\texttt{Alg}^{*}$ at best. Thus we can interpret the property of the supervised pre-trained transformer by $\texttt{Alg}^{*}$ as a proxy. Such a Bayes-optimal function and the Bayesian perspective have been discussed under various settings in the in-context learning literature (Xie et al., ; Zhang et al., ; Jeon et al., ).

###### Example 4.2 .

$\texttt{Alg}^{*}$ behaves as (a) posterior sampling under the cross-entropy loss; (b) posterior averaging under the squared loss; (c) posterior median under the absolute loss;
where the posterior distribution is with respect to $\gamma$ and it is defined by $\mathcal{P}(\gamma|H)\propto\mathbb{P}(H|\gamma)\cdot\mathcal{P}_{\gamma}(\gamma)$.

We defer more details for Example 4.2 to Appendix D.4. Part (a) has been directly employed as Assumption 1 in Lee et al. () for their theoretical developments. Indeed, part (a) corresponds to a discrete action space such as multi-armed bandits while part (b) and part (c) correspond to the continuous action space such as linear bandits, pricing, and newsvendor problems.

###### Proposition 4.3 .

There exist a linear bandits problem instance and a dynamic pricing problem instance, i.e., an environment distribution $\mathcal{P}_{\gamma}$, such that the optimal decision function learned under the squared loss incurs a linear regret for every $\gamma$, i.e., $\mathrm{Regret}(\texttt{Alg}^{*};\gamma)=\Omega(T)$ for every $\gamma$.

Proposition 4.3 states a negative result that the optimal decision function $\texttt{Alg}^{*}$, albeit being optimal in a prediction sense (for predicting the optimal action), does not serve as a good algorithm for sequential decision-making problems. To see the intuition, the decision function is used recursively in the test phase (see (7)). While it gives the best possible prediction, it does not conduct exploration which is critical for the concentration of the posterior measure. This highlights one key difference between the sequential decision-making problem and the regression problem (Garg et al., ) when applying the pre-trained transformer. For the regression problem, the in-context samples (in analogy context-action-observation tuples in $H_{t}$) are i.i.d. generated, and this results in a convergence/concentration of the posterior to the true model/environment $\gamma$ (Ghosal et al., ). Yet for sequential decision-making problems, the dynamics (7) induces a dependency throughout $H_{t}$, and it may result in a non-concentration behavior for the posterior. And this is the key for constructing the linear-regret example in Proposition 4.3 and the examples are also inspired from and share the same spirit as the discussions in (Harrison et al., ). Such lack of exploration does not happen for discrete action space (Lee et al., ); this is because for discrete action space, the output $\texttt{TF}_{\hat{\theta}}$ gives the posterior distribution as a distribution over the action space. The distribution output will lead to a randomized action and thus automatically perform exploration.

###### Proposition 4.4 .

Consider a finite prior $\mathcal{P}_{\gamma}$ supported on $\Gamma=\{\gamma_{1},...,\gamma_{k}\}$. Suppose there exists constants $\Delta_{\text{Exploit}}$ and $\Delta_{\text{Explore}}$ such that for any $\gamma\in\Gamma$ and $H_{t}$, $\texttt{TF}_{\hat{\theta}}$ and $\texttt{Alg}^{*}(H_{t})$ satisfies

- •
$\mathbb{E}[r(X_{t},\texttt{Alg}^{*}(H_{t}))-r(X_{t},\texttt{TF}_{\hat{\theta}}
(H_{t}))|H_{t}]\leq\Delta_{\text{Exploit}}$, where the expectation is taken with respect to the possible randomness in $\texttt{Alg}^{*}$ and $\texttt{TF}_{\hat{\theta}}$.
- •
The KL divergence
$\text{KL}\left(\mathbb{P}_{\gamma}(\cdot|X_{t},\texttt{TF}_{\hat{\theta}}(H_{t
}))\|\mathbb{P}_{\gamma^{\prime}}(\cdot|X_{t},\texttt{TF}_{\hat{\theta}}(H_{t}
))\right)\geq\Delta_{\text{Explore}}$
for any $\gamma^{\prime}\in\Gamma$, and the log-likelihood ratio between $\mathbb{P}_{\gamma}(\cdot|X_{t},\texttt{TF}_{\hat{\theta}}(H_{t}))$ and $\mathbb{P}_{\gamma^{\prime}}(\cdot|X_{t},\texttt{TF}_{\hat{\theta}}(H_{t}))$ is $C_{\sigma^{2}}\Delta_{\text{Explore}}$-sub-Gaussian for any $\gamma^{\prime}\in\Gamma$.

Then under conditions on the boundedness of the reward and environment parameters, we have

$$ $\displaystyle\mathrm{Regret}(\texttt{TF}_{\hat{\theta}};\gamma)\leq O\left( \Delta_{\text{Exploit}}T+\frac{\log k}{\Delta_{\text{Explore}}}\right)$ $$

for any $\gamma\in\Gamma$, where the notation $O(\cdot)$ omits logarithm terms in $T$ and the parameters in the boundedness assumptions.

There are simple remedies to the linear regret behavior of the Bayes-optimal decision function, for example, using an $\epsilon$-greedy version of $\texttt{Alg}^{*}$ (and $\texttt{TF}_{\hat{\theta}}$). Numerically, we do not observe such behavior for any experiment even without any further modification of the pre-trained transformer $\texttt{TF}_{\hat{\theta}}$. Proposition 4.4 provides a simple explanation for why one does not have to be too pessimistic. Intuitively, the pre-trained model $\texttt{TF}_{\hat{\theta}}$ can be viewed as the optimal decision function $\texttt{Alg}^{*}$ plus some random noise, and the random noise actually plays the role of exploration and helps the posterior to concentration. Proposition 4.4 materializes such an intuition and it involves two conditions. The first condition is that $\texttt{TF}_{\hat{\theta}}$ behaves closely to $\texttt{Alg}^{*}$ and the (reward) deviation between these two is captured by $\Delta_{\text{Exploit}}$. This condition can be justified by Figure 3. The second condition characterizes the KL divergence between the conditional distribution of the observation $o_{t}$ for two environments: the true testing environment $\gamma$ and any other one $\gamma^{\prime}\in\Gamma$. Note that this KL divergence critically depends on $\texttt{TF}_{\hat{\theta}}$ because the ability to distinguish between two environments depends on the intensity of exploration of the underlying algorithm. These conditions work more like a stylized model to understand the behavior of the transformer. It is a largely simplified model; say, the parameter $\Delta_{\text{Explore}}$ should have a dependency on $t$ for many online learning algorithms such as UCB or Thompson sampling. Nevertheless, the conditions give us a perspective to understand how the transformer works as an online algorithm. In particular, $\texttt{TF}_{\hat{\theta}}$ deviates from $\texttt{Alg}^{*}$ by an amount of $\Delta_{\text{Exploit}}$ in terms of the reward, and this deviation accumulates over time into the first term in the regret bound. On the other hand, this deviation also gives an exploration whose intensity is measured by $\Delta_{\text{Explore}}$, and the second term captures the regret caused during the concentration of the posterior onto the true environment. In Appendix D.7, we provide some further justifications for these conditions. We also note that the finiteness of $\Gamma$ is not essential. The KL divergence condition can be modified for a continuous $\Gamma$ and combined with a covering argument to obtain the bound accordingly.

###### Proposition 4.1 .

###### Example 4.2 .

###### Proposition 4.3 .

###### Proposition 4.4 .

## 5 Numerical Experiments and Discussions

The following figure summarizes the experiments for our model against benchmarks for each task. We note that the prior environment distribution $\mathcal{P}_{\gamma}$ takes an infinite support which means the environment $\gamma$ in the test phase is different from the environment $\gamma_{i}$’s used for training with probability 1. This provides a fair and possibly more challenging setup to examine the ability of the transformer.

Figure: (a) Multi-armed bandits
Refer to caption: extracted/5895775/figs/MAB/_inf_20dT_False_Reg.png

We make the following observations on the numerical experiment. The transformer achieves a better performance than the structured algorithms for each task. This result is impressive to us in that the transformer is not replicating/imitating the performance of these benchmark algorithms but it discovers a new and more effective algorithm. This in fact shows the effectiveness of using the optimal actions $a_{t}^{*}$ as the target variable for training the transformer. Moreover, we attribute the advantage of the transformer against the benchmark algorithms to two aspects: prior knowledge from pre-training data and more greedy exploitation. First, the transformer well utilizes the pre-training data and can be viewed as tailored for the pre-training distribution. Comparatively, all the benchmark algorithms are cold-start. Second, the benchmark algorithms are all designed in ways to cater for asymptotic optimality and thus may sacrifice short-term rewards. Comparatively, the transformer behaves more greedy; just like $\texttt{Alg}^{*}$ is a decision function that does not explicitly encourage exploration. And such greedy behavior brings better reward when $T$ is small such as $T\leq 100.$

We provide more numerical experiments to Section C. In Section C.1, we present additional experiments on training dynamics, including an ablation study on $f$ and $\kappa$ as well as further results extended from Figure 2 (a). Section C.2 provides more results regarding the alignment of $\texttt{TF}_{\hat{\theta}}$ and $\texttt{Alg}^{*}$. Section C.3 compares the performance of $\texttt{TF}_{\hat{\theta}}$ and $\texttt{Alg}^{*}$, showing that $\texttt{TF}_{\hat{\theta}}$ can outperform $\texttt{Alg}^{*}$ in certain scenarios. In Section C.4, we demonstrate that $\texttt{TF}_{\hat{\theta}}$ can be a solution to model misspecifications. We also evaluate the performance of $\texttt{TF}_{\hat{\theta}}$ under environments with varying levels of problem complexity (Section C.5), longer testing horizons (Section C.6), and the case of model misspecification when the test environment is sampled from a distribution different from pre-training (i.e., its OOD performance) (Section C.7). Finally, we conduct an ablation study on the model architecture, model size, and task complexity in Section C.8 and Section C.9.

## 6 Conclusion

In this paper, we study the pre-trained transformer for sequential decision-making problems. Such problems enable using the optimal action as the target variable for training the transformer. We mathematically formulate the setup of the training pipeline and propose a way to utilize simulation environments to generate pre-training data. We investigate the training and generation aspect of the transformer and identify an OOD issue that is largely ignored by the existing literature. Theoretically, we interpret how the transformer works as an online algorithm through the lens of the Bayes-optimal decision function. The numerical experiments are encouraging in that the trained transformer learns a decision function significantly better than all the benchmark algorithms.

## Appendix A Related Works

### A.1 Literature Review

In this section, we discuss more related works which complement our discussions in Section 1. In particular, we elaborate the literature in three streams.

##### Understanding transformer and in-context learning.

A remarkable characteristic of pre-trained transformers is their ability to perform in-context learning (ICL). Once pre-trained on a vast corpus, transformers can solve new tasks with just a few examples, without updating their parameters. ICL has captured the attention of the theoretical machine learning community, leading to considerable efforts into understanding ICL from different theoretical perspectives [Xie et al., , Akyürek et al., , Von Oswald et al., , Lin et al., ]. A stream of literature that is related to our work explains the transformer’s behavior as Bayesian inference. See Xie et al. [], Zhang et al. [] for the Bayesian argument in regression context, Müller et al. [] for approximating a large set of posteriors, and Lee et al. [] for the Bayesian analysis in decision-making. Another stream of literature aims to develop generalization bound or other types of convergence results. See Jeon et al. [], Bai et al. [] for such results in the regression context and Lin et al. [] in the decision-making context.

##### Pre-trained transformer for RL.

The earliest effort of applying transformers to reinforcement learning lies in the area of offline RL [Janner et al., , Chen et al., ]. By autoregressively maximizing the likelihood of trajectories in the offline dataset, this paradigm essentially converts offline RL to a supervised learning problem. When evaluating the policy, the actions are sampled according to the likelihood of PT conditioned on the so called “return-to-go”, which is commonly chosen to be the cumulative reward of “good” trajectories in the dataset. By doing so, PT retrieves information from trajectories in training data with similar return-to-go values and performs imitation learning to high-reward offline trajectories. Based on this observation, several works further examine the validity of return-to-go conditioning [Emmons et al., , Ajay et al., , Brandfonbrener et al., ] and propose alternative methods that improve this approach or extend to other settings [Laskin et al., , Badrinath et al., , Zheng et al., , Wu et al., ]. For example, one of the drawbacks of the return-to-go conditioning is that it often fails in trajectory-stitching when offline data comes from sub-optimal policies. One recent work [Park et al., ] finds that pre-trained LLMs, although trained by text data, can behave like a follow-the-perturbed-leader (FTPL) algorithm in bandits and games. It further introduces a regret-based training loss, through which transformers can be trained in an unsupervised way.

##### Sequential decision-making.

We carry out experiments involving some stylized sequential decision-making models including dynamic pricing and inventory management. Dynamic pricing entails setting prices to discern the underlying revenue function, usually defined as the product of demand and price [Den Boer, ]. Algorithms that purely exploit based on historical data tend to be suboptimal and have been found converging to non-optimal prices with a positive probability [Lai and Robbins, , Keskin and Zeevi, ]. Therefore, random exploration is essential for a more accurate understanding of the demand function and to avoid settling on suboptimal prices. See Harrison et al. [], Den Boer and Zwart [], Besbes and Zeevi [], Cohen et al. [] for algorithms that tackle this exploration-exploitation trade-off and achieving near-optimal regret under different settings.

For inventory management, demand estimation is different from that in dynamic pricing due to the censored demand [Huh and Rusmevichientong, ]. When demand exceeds inventory levels, the unmet demand is not observed, leading to lost sales. The optimal decision-making policy must balance exploration and exploitation, which involves occasionally setting inventory levels higher than usual to gather more demand data, but not so high that the additional costs of exploration become prohibitive. Regarding near-optimal policies, various works [Huh et al., , Zhang et al., , Agrawal and Jia, ] have developed algorithms that achieve an $O(\sqrt{T})$ regret bound with different assumptions about lead times.

### A.2 TF θ ^ subscript TF ^ 𝜃 \texttt{TF}_{\hat{\theta}} TF start_POSTSUBSCRIPT over^ start_ARG italic_θ end_ARG end_POSTSUBSCRIPT v.s. Online Decision Transformer

In this section, we compare $\texttt{TF}_{\hat{\theta}}$ with online decision transformer (ODT) [Zheng et al., ]. As shown in Figure 5, although both approaches involve a pre-training phase and an (online) interaction phase, they are indeed very different and designed to address different problems. Specifically:

- •
ODT interacts with a specific testing environment to fine-tune the policy, whereas $\texttt{TF}_{\hat{\theta}}$ (with Algorithm 1) interacts with different environments and does the learning in the pre-training stage. As a result, ODT is tailored to optimize performance in a single test environment, while $\texttt{TF}_{\hat{\theta}}$ learns various policies across different environments during pre-training, enabling it to perform well in online evaluations across different environments.
- •
ODT has been shown to underperform in stochastic environments. Although some RL environments—such as Atari and Gym—are relatively less stochastic, sequential decision-making often involves more stochasticity. This is why ODT has rarely been applied to sequential decision-making problems like bandit problems. More specifically, ODT, along with its precursor Decision Transformer (DT) [Chen et al., ], belongs to the class of “return-conditioned supervised learning” methods, which are not suitable even for offline reinforcement learning in stochastic environments. In such cases, the transformers (ODT or DT) is prone to learning from a “survival bias”, as demonstrated in Brandfonbrener et al. [], leading to suboptimal performance.

Figure: (a) Online Decision Transformer (ODT)
Refer to caption: extracted/5895775/new_figs/WechatIMG3167.jpg

We further conduct an experiment comparing our framework with ODT as shown in Figure 6 to highlight their differences. Specifically, we use a noiseless linear bandits task (i.e., no reward noise) with dimension $d=2$ and a horizon of $T=20$, where the test environments are entirely unseen during the training phase, including the online fine-tuning phase for ODT. It is important to emphasize that this problem setting differs from the one for which ODT is designed (as shown in Figure 5(a), where the test environment is identical to the environment used during online fine-tuning), and aligns with the setting we study in this work. We set fair configurations for training ODT and $\texttt{TF}_{\hat{\theta}}$ (which will be specified later). As expected, Figure 6 demonstrates that ODT fails in this setting, performing no better than a random policy that uniformly samples actions.

Figure: Figure 6: We test the ODT and our method in a same linear bandits task, where test environments are unseen before the evaluation phase. The ODT fails in the test environments, which are different from the online fine-tuning phase’s.
Refer to caption: extracted/5895775/new_figs/reward.png

Setup: for both ODT and $\texttt{TF}_{\hat{\theta}}$, we set the transformer architecture with 4 layers, 4 heads, 512 embedding dimensions, and a 20-length context window, which are the same as in Zheng et al. []. For the offline dataset, we sample 100,000 environments by the same method in our paper, and then use Thompson sampling to generate trajectories for each environment. And for the online interactions, the environments are sampled from the same distribution as the offline data. The testing environments are still sampled from the same distribution. We set the offline training phase (pre-training stage for ODT and stage 1 for $\texttt{TF}_{\hat{\theta}}$) with 20 iterations (each iteration has 500 updates/gradient descents on parameters), and set the online interaction phase (online fine-tuning for ODT and stage 2 for $\texttt{TF}_{\hat{\theta}}$) with 30 iterations (each iteration has 50 updates/gradient descents on parameters). The other training parameters (e.g., learning rate) are set the same as in Zheng et al. [] except the return-to-go (RTG): we set the eval RTG as 55, which is the maximum RTG observed in the offline dataset, and online RTG as 110, which doubles the eval RTG as used in Zheng et al. [].

## Appendix B Problem Examples for the General Setup in Section 2

Throughout the paper, we make the following boundedness assumption.

###### Assumption B.1 .

Assume the context space $\mathcal{X}$, the action space $\mathcal{A},$ and the observation space $\mathcal{O}$ is bounded (under the Euclidean norm) by $D$.

We provide a few examples as special cases of the framework in Section 2. We hope these examples make the actions, observations, and context in the general setup more tangible.

- •
Stochastic multi-armed bandits : There is no context, $X_{t}=\text{null}$ for all $t.$ The action $a_{t}\in\mathcal{A}=\left\{1,2,\ldots,k\right\}$ denotes the index of the arm played at time $t$. The observation (also the random reward) is generated following the distribution $P_{a_{t}}$. The parameter $\gamma$ encapsulates the distributions $P_{1},\ldots,P_{k}.$
- •
Linear bandits: There is no context, $X_{t}=\text{null}$ for all $t.$ The action $a_{t}\in\mathcal{A}\in\mathbb{R}^{d}$ is selected from some pre-specified domain $\mathcal{A}$. The random reward $R(X_{t},a_{t})=w^{\top}a_{t}+\epsilon_{t}$ where $\epsilon_{t}$ is some noise random variable and $w$ is a vector unknown to the agent. The observation $o_{t}=R(X_{t},a_{t})$ and the expected reward $r(X_{t},a_{t})=\mathbb{E}\left[R(X_{t},a_{t})|X_{t},a_{t}\right]=w^{\top}a_{t}$. The parameter $\gamma$ encapsulates the vector $w$ and the noise distribution.
- •
Dynamic pricing: The context vector $X_{t}$ describes the market-related information at time $t$. Upon the reveal of $X_{t}$, the agent takes the action $a_{t}$ as the pricing decision. Then the agent observes the demand $d_{t}=d(X_{t},a_{t})+\epsilon_{t}$ where $\epsilon_{t}$ is some noise random variable and $d(\cdot,\cdot)$ is a demand function unknown to the agent. The random reward $R_{t}(X_{t},a_{t})=d_{t}\cdot a_{t}$ is the revenue collected from the sales at time $t$ (which equals the demand times the price), and the observation $o_{t}=d_{t}$. The expected reward $r(X_{t},a_{t})=\mathbb{E}\left[R(X_{t},a_{t})|X_{t},a_{t}\right]=d(X_{t},a_{t}
)\cdot a_{t}.$ The parameter $\gamma$ governs the generation of $X_{t}$’s and also contains information about the demand function $d$ and the noise distribution.
- •
Newsvendor problem: As the dynamic pricing problem, the context vector $X_{t}$ describes the market-related information at time $t$. Upon its reveal, the agent takes the action $a_{t}$ which represents the number of inventory prepared for the sales at time $t$. Then the agent observes the demand $d_{t}=d(X_{t},a_{t})+\epsilon_{t}$ where $\epsilon_{t}$ is some noise random variable and $d(\cdot,\cdot)$ is a demand function unknown to the agent. The observation $o_{t}=d_{t}$, and the random reward is the negative cost $R(X_{t},a_{t})=-h\cdot(a_{t}-d_{t})^{+}-l\cdot(d_{t}-a_{t})^{+}$ where $(\cdot)^{+}$ is the positive-part function, $h$ is the left-over cost, and $l$ is the lost-sale cost. The expected reward $r(X_{t},a_{t})=\mathbb{E}\left[R(X_{t},a_{t})|X_{t},a_{t}\right]$ with the expectation taken with respect to $\epsilon_{t}$. The parameter $\gamma$ governs the generation of $X_{t}$’s and encodes the demand function $f$ and the noise distribution.

For the general problem setup in Section 2, the following proposition relates the pre-training and the regret through the lens of loss function.

###### Proposition B.2 (Surrogate property) .

We say the loss function $l(\cdot,\cdot)$ satisfies the surrogate property if there exists a constant $C>0$ such that

$$ $\mathrm{Regret}(f;\gamma)\leq C\cdot L\left(f;\gamma\right)$ $$

holds for any $f$ and $\gamma$. We have

- (a)
The cross-entropy loss satisfies the surrogate property for the multi-armed bandits problem.
- (b)
The squared loss satisfies the surrogate property for the dynamic pricing problem.
- (c)
The absolute loss satisfies the surrogate property for the linear bandits and the newsvendor problem.

Proposition B.2 gives a first validity of the supervised pre-training approach. The surrogate property is a property of the loss function and it is not affected by the distribution or the decision function $\texttt{TF}_{\theta}.$ Specifically, it upper bounds the regret with the action prediction loss. It is also natural in that a closer prediction of the optimal action gives a smaller regret. One implication is that the result guides the choice of the loss function for different underlying problems.

###### Assumption B.1 .

###### Proposition B.2 (Surrogate property) .

### B.1 Proof of Proposition B.2

To prove Proposition B.2, we assume the following mild conditions. First, for all these problems, the noise random variable $\epsilon_{t}$ has mean 0, is i.i.d. across time, and is independent of the action $a_{t}$. Second, for the linear bandits problem, the $L_{\infty}$ norm of the unknown parameter $w$ is bounded by $D$. Third, for the dynamic pricing problem, we assume the demand function is differentiable with respect to the action coordinate, and both the absolute value of the first- and second-order derivatives is bounded by $D$. Further details regarding the problem formulations can be found in Appendix E.2.

###### Proof.

Since both the regret $\text{Regret}(f;\gamma)$ and the prediction error $L(f;\gamma)$ are the sums of single-step regret and prediction error over the horizon, it is sufficient to prove the single-step surrogate property of the loss function. Therefore, in the following proof, we will focus on proving the single-step surrogate property and omit the subscript $t$ for simplicity.

- •
For the multi-arm bandits problem, without loss of generality, we assume $\mathcal{A}=\{a_{1},\ldots,a_{J}\}$ and the optimal arm is $a_{1}$. For $1\leq i\leq J$, let $\mu_{j}$ be the mean of the reward distribution for arm $j$, and define $\Delta_{j}=\mu_{1}-\mu_{j}$ as the reward gap for arm $j$. Define $\Delta_{\max}=\max\left\{\Delta_{1},\cdots,\Delta_{J}\right\}$ as the maximum action gap. Under cross-entropy loss, we denote the output distribution of decision function $f$ is $(p_{1},\ldots,p_{J})$. Then the single-step regret can be bounded by:
$\mathbb{E}\left[r\left(X,a^{*}\right)-r\left(X,f(H)\right)|H\right]=\mu_{1}-
\sum_{j=1}^{J}p_{j}\mu_{j}=\sum_{j=2}^{J}p_{j}\Delta_{j}\leq\Delta_{\max}(1-p_
{1})\leq-\Delta_{\max}\cdot\log(p_{1}),$
where the last step is by the inequality $1-x\leq-\log(x)$ for $0<x\leq 1$. Then by the definition of cross-entropy loss, we finish the proof.
- •
For the dynamic pricing problem, we have
$r(X,a^{*})-r(X,f(H))=\nabla_{a}r(X,a^{*})(a^{*}-f(H))+\nabla_{a}^{2}r(X,\tilde
{a})|f(H)-a^{*}|^{2}\leq D|f(H)-a^{*}|^{2}$
where $\tilde{a}$ is in the line of $f(H)$ and $a^{*}$. Here, the first step is by the Taylor expansion, and the second step is by the first order condition of $a^{*}$ and the assumption. Then by noting $|f(H)-a^{*}|^{2}$ is the square loss, we finish the proof.
- •
For the linear bandits problem, we have
$r(X,a^{*})-r(X,f(H))=w^{\top}a^{*}-w^{\top}f(H)\leq||w||_{\infty}||f(H)-a^{*}|
|_{1}\leq D||f(H)-a^{*}||_{1},$
where the second step is by the Holder’s inequality and the last step is by the assumption. Then by noting $||f(H)-a^{*}||_{1}$ is the absolute loss, we finish the proof.
- •
For the newsvendor problem, we have
$\displaystyle r(X,a^{*})-r(X,f(H))$
$\displaystyle\leq\max\left\{h,l\right\}\mathbb{E}_{X}\left[|a^{*}-d(X)-f(H)+d(
X)|\right]$
$\displaystyle=\max\left\{h,l\right\}|a^{*}-f(H)|$
where the first line is because the (random) reward function is $\max\left\{h,l\right\}$-Lipschitz in $a-d(X)$. Then by noting $|f(H)-a^{*}|$ is the absolute loss, we finish the proof.

∎

###### Proof.

## Appendix C More Experiments

### C.1 More experiments on training dynamics

#### C.1.1 Ablation study on f 𝑓 f italic_f and κ 𝜅 \kappa italic_κ

In this section, we present ablation studies to explore the impact of two key factors: the decision function $f$ used for generating pre-training data, and the mix ratio $\kappa$ applied in Algorithm 1. Figure 7 summarizes the results, where we pre-train and test models in multi-armed bandits problems defined in Appendix E.2, and only tune $f$ or $\kappa$ during the pre-training and keep all other parameters the same as in Appendix E.1.2.

- •
Effect of $f$:
We evaluate the influence of different decision functions $f$ on the performance of the transformer in a multi-armed bandit task. Three types of decision functions are considered: the one we designed, as defined in Appendix E.1.2 , the UCB algorithm for multi-armed bandits [Lattimore and Szepesvári, ], and a 50/50 mixture of both. The training dynamics for each function are shown in Figure 7(a). We observe that all three approaches achieve similar final performance once training ends. While it is possible that some decision functions could lead to faster convergence or better performance after pre-training, we did not encounter any training failures due to the choice of $f$.
- •
Effect of $\kappa$:
We also conduct an experiment to numerically investigate the impact of different mix ratios $\kappa$. The results are presented in Figure 7(b). We test four values of $\kappa$ $(10\%,33\%,66\%,90\%)$, keeping all other hyperparameters constant for a multi-armed bandit task. The findings show that transformer’s performance remains robust across different values of $\kappa$, except when $\kappa=0.9$, where performance declines. This supports our earlier discussion in Algorithm 1, highlighting the importance of mixing a non-trivial amount of self-generated data (i.e., non-trivial value for $1-\kappa$).

Figure: (a) Impact of $f$
Refer to caption: extracted/5895775/new_figs/f.png

#### C.1.2 Additional results on Figure 2 (a)

In addition to Figure 2 (a), we further evaluate the effectiveness of Algorithm 1 across various tasks and architectures, as illustrated in Figure 8.

Figure: (a) Linear bandits
Refer to caption: extracted/5895775/figs/LinB.png

Figure 8 presents comparisons of the transformer’s testing regret (see definition and implementation in Appendix E.1) with and without self-generated data (i.e., using Algorithm 1 or not) during the training, colored by blue and orange respectively. The comparisons are conducted on (a) linear bandits and (b) newsvendor tasks. Additionally, (c) includes a similar comparison conducted in a model with different architecture, the Decision Pre-trained Transformer (DPT) Lee et al. [], on the multi-armed bandits task. The results consistently demonstrate the same pattern observed in Figure 2 (a): incorporating transformer-generated data significantly reduces the testing regret loss at each iteration $m>50$ compared to not using it. This shows the effectiveness of Algorithm 1 (i) across different tasks and (ii) for various model architectures.

Setup. In Figure 8 (a) and (b), we consider two tasks: a linear bandits task (with $2$-dimensional action space) and a newsvendor task (with $4$-dimensional contexts). Both tasks have infinite support of the prior environment distribution $\mathcal{P}_{\gamma}$ (i.e., infinite possible environments in both the pre-training and testing). The details of the tasks can be found in Appendix E.2. For each task, we independently train two transformer models by Algorithm 1. For both models, the training parameters are identical except for the $M_{0}$: the first curve (blue, thick line) uses $M_{0}=50$, while the second curve (orange, dashed line) uses $M_{0}=130$, meaning no transformer-generated data is utilized during training. All other parameters follow the configuration detailed in Appendix E.1. The figure shows the mean testing regret at each training iteration across 128 randomly sampled environments from $\mathcal{P}_{\gamma}$, with the shaded areas representing the standard deviation. We conduct the same experiment on the multi-armed bandits task (with infinite possible environments and $20$ arms) for a different architecture for sequential decision making, Decision Pre-trained Transformer (DPT) [Lee et al., ], in Figure 8 (c). We refer to the original paper for details on the DPT’s architecture.

### C.2 More experiments on matchings of TF θ ^ subscript TF ^ 𝜃 \texttt{TF}_{\hat{\theta}} TF start_POSTSUBSCRIPT over^ start_ARG italic_θ end_ARG end_POSTSUBSCRIPT and Alg ∗ superscript Alg \texttt{Alg}^{*} Alg start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT

This section provides more results regarding the matching of $\texttt{TF}_{\hat{\theta}}$ and $\texttt{Alg}^{*}$ across different tasks: Figure 9 provides more examples comparing decisions made by $\texttt{TF}_{\hat{\theta}}$ and $\texttt{Alg}^{*}$ at sample path levels, while Figure 10 compares them at population levels.

Figure: (a) Dynamic pricing, $100$ environments, linear demand type
Refer to caption: extracted/5895775/figs/DP/_100env_4d_123_Act_match_0.png

Figure: (a) Multi-armed bandits, 4 environments
Refer to caption: extracted/5895775/figs/MAB/_4env_20d_Act_diff.png

We plot the actions generated from $\texttt{TF}_{\hat{\theta}}$ and $\texttt{Alg}^{*}$ on the same environment with the same contexts in Figure 9 across dynamic pricing and newsvendor tasks. Each subfigure has a different number of possible environments or possible demand types (which are shared in both the pre-training and testing phases). The population-level differences $\{\texttt{TF}_{\hat{\theta}}(H_{t})-\texttt{Alg}^{*}(H_{t})\}_{t=1}^{T}$ are presented in Figure 10. We observe that across different tasks: (1) $\texttt{TF}_{\hat{\theta}}$ nearly matches $\texttt{Alg}^{*}$, but (2) the matchings are not perfect. The actions from $\texttt{TF}_{\hat{\theta}}$ and $\texttt{Alg}^{*}$ are not exactly the same, and their differences increase as the underlying problems become more complex, as seen by comparing the first and second rows in Figure 10. This latter observation numerically supports the conditions in Proposition 4.4.

Setup.
For Figure 9, each subfigure is based on a sampled environment with a sampled sequence of contexts $\{X_{t}\}_{t=1}^{30}$ from the corresponding task. For tasks in (a),(c), the data generation process follows the description detailed in Appendix E.2, and the architecture of $\texttt{TF}_{\hat{\theta}}$ and the definition of $\texttt{Alg}^{*}$ can be found in Appendix E.1 and Appendix E.3 respectively. For tasks in (b), (d), there are 16 environments included in the support of $\mathcal{P}_{\gamma}$, where 8 environments have demand functions of the linear type and the other 8 have demand functions of the square type (see Appendix E.2 for the definitions of these two types). Both the pre-training and testing samples are drawn from $\mathcal{P}_{\gamma}$, i.e., from these 16 environments. The remaining setups for these tasks follow the methods provided in Appendix E.2.

For each task shown in Figure 10, we generate $100$ sequences of $\{\texttt{TF}_{\hat{\theta}}(H_{t})-\texttt{Alg}^{*}(H_{t})\}_{t=1}^{100}$, i.e., each subfigure is based on $10000$ samples of $\texttt{TF}_{\hat{\theta}}(H_{t})-\texttt{Alg}^{*}(H_{t})$. For dynamic pricing and newsvendor, actions are scalars and thus $\texttt{TF}_{\hat{\theta}}(H_{t})-\texttt{Alg}^{*}(H_{t})$ is also a scalar; For multi-armed bandits, the action space is discrete and we use the reward difference associated with the chosen actions (by $\texttt{TF}_{\hat{\theta}}(H_{t})$ or $\texttt{Alg}^{*}(H_{t})$) as the value of $\texttt{TF}_{\hat{\theta}}(H_{t})-\texttt{Alg}^{*}(H_{t})$. We use histograms to summarize the samples from them. For linear bandits, the actions are $2$-dimensional and thus we use the scatters to show $\texttt{TF}_{\hat{\theta}}(H_{t})-\texttt{Alg}^{*}(H_{t})$ in Figure 10 (d) or (h).

### C.3 Regret comparison with Alg ∗ superscript Alg \texttt{Alg}^{*} Alg start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT

In this subsection, we study the behavior of $\texttt{TF}_{\hat{\theta}}$ by comparing regret performances on $\texttt{TF}_{\hat{\theta}}$ and $\texttt{Alg}^{*}$, which utilizes the posterior distribution $\mathcal{P}(\gamma|H)$ of environments. As shown in Section 4, $\texttt{Alg}^{*}$’s are defined as the Bayes-optimal decision functions.

Algorithm 2 presents a general framework for the Bayes-optimal decision functions/algorithms in Example 4.2: posterior averaging, sampling, and median. For simplicity of notation, we omit the subscript $t$ and only consider a finite space $\Gamma$ of environments, while the algorithms can be easily extended to the infinite case. For the posterior median algorithm, we assume the action space $\mathcal{A}\subseteq\mathbb{R}$.

Figure: Algorithm 2 Posterior averaging/sampling/median at time $t$

Figure: (a) Regret for multi-armed bandits
Refer to caption: extracted/5895775/figs/MAB/_4env_20d_slim_Reg_noscale.png

Figure 11 presents the testing regret and action suboptimality for $\texttt{TF}_{\hat{\theta}}$ compared to the Bayes-optimal decision functions/algorithms. Generally, all algorithms exhibit good regret performance. However, we observe that $\texttt{TF}_{\hat{\theta}}$ is (i) superior to posterior sampling in multi-armed bandits, as shown in (a), and (ii) outperforms posterior averaging in linear bandits, as shown in (c).

Specifically, (b) shows that posterior sampling has higher action suboptimality during the initial time steps compared to $\texttt{TF}_{\hat{\theta}}$. This suggests that the exploration inherent in the sampling step of posterior sampling can introduce additional regret, which might be unnecessary for simpler problems. Conversely, (d) indicates that the decisions from posterior averaging do not converge to the optimal action $a^{*}_{t}$ as quickly as those from $\texttt{TF}_{\hat{\theta}}$ and posterior sampling. This suggests that posterior averaging may be too greedy, thus failing to sufficiently explore the environment. This second observation also numerically supports Proposition 4.3.

These observations illustrate that $\texttt{TF}_{\hat{\theta}}$ can outperform Bayes-optimal decision functions in certain scenarios. This further demonstrates that the advantage of $\texttt{TF}_{\hat{\theta}}$ over benchmark algorithms is not solely due to its use of prior knowledge about the task. Rather, $\texttt{TF}_{\hat{\theta}}$ discovers a new decision rule that achieves better short-term regret than oracle posterior algorithms. It can be more greedy than posterior sampling while exploring more than posterior averaging.

Setup. We consider a multi-armed bandits task (with $20$ arms) and linear bandits task (with $2$-dimensional actions) with $4$ environments. The results are based on $100$ runs. The details of tasks with their specific oracle posterior algorithms are provided in Appendix E.2 and Appendix E.3.

### C.4 TF θ ^ subscript TF ^ 𝜃 \texttt{TF}_{\hat{\theta}} TF start_POSTSUBSCRIPT over^ start_ARG italic_θ end_ARG end_POSTSUBSCRIPT as a solution to model misspecification

Most sequential decision-making algorithms, including all the benchmark algorithms in our experiments, rely on structural or model assumptions about the underlying tasks. For instance, demand functions in pricing and newsvendor problems are typically assumed to be linear in context. Applying these algorithms in misspecified environments, where these assumptions do not hold, can lead to degraded performance.

In contrast, $\texttt{TF}_{\hat{\theta}}$ offers a potential solution to model misspecifications. By generating pre-training samples from all possible types of environments (e.g., newsvendor models with both linear and non-linear demand functions), $\texttt{TF}_{\hat{\theta}}$ leverages its large capacity to make near-optimal decisions across different types. Figure 12 demonstrates the performance of $\texttt{TF}_{\hat{\theta}}$ trained on tasks with two types of demand functions: linear and square (definitions provided in Appendix E.2). It compares $\texttt{TF}_{\hat{\theta}}$ with benchmark algorithms designed solely for linear demand cases. The performance is tested in environments where demand functions (i) can be either type with equal probability (first column); (ii) are strictly square type (second column); and (iii) are strictly linear type (third column). The benchmark algorithms face model misspecification issues in the first two cases.

For both pricing and newsvendor tasks, $\texttt{TF}_{\hat{\theta}}$ consistently outperforms all benchmarks across the three scenarios, especially in the first two cases. This result highlights the potential of $\texttt{TF}_{\hat{\theta}}$ to effectively handle model misspecifications.

Figure: (a) Pricing, two demands
Refer to caption: extracted/5895775/figs/DP_2demands/_inf_2d_sq_gen_NoneT_False_Reg.png

Setup. For both the pricing and newsvendor tasks, during the pre-training phase of $\texttt{TF}_{\hat{\theta}}$, the pre-training data are generated from two types of demand functions: linear and square, with each type having a half probability. The support of $\mathcal{P}_{\gamma}$ is infinite, meaning the parameters in the demand functions are not restricted. The context dimension is 6 for the pricing task and 4 for the newsvendor task. The generating details and definitions of these two types of demands are provided in Appendix E.2. Additionally, when generating data using $\texttt{TF}_{\theta_{m}}$ in Algorithm 1, the sampled environment also has an equal probability of having a linear or square demand type.

Each subfigure in Figure 12 is based on 100 runs. We consider three different cases during testing: (i) the environment can have either the square or linear demand type (each with half probability); (ii) the environment can only have the linear demand type; and (iii) the environment can only have the square demand type. In the first case, the testing environment is sampled in the same way as the pre-training environment, while in the other two cases, we only include the sampled environments with the specified demand type until the total testing samples reach 100.

### C.5 Additional results on TF θ ^ subscript TF ^ 𝜃 \texttt{TF}_{\hat{\theta}} TF start_POSTSUBSCRIPT over^ start_ARG italic_θ end_ARG end_POSTSUBSCRIPT performances

This subsection presents further results on the performance of $\texttt{TF}_{\hat{\theta}}$. Specifically, we compare $\texttt{TF}_{\hat{\theta}}$ with benchmark algorithms on (i) simple tasks, which include only 4 possible environments in both pre-training and testing samples (Figure 13), and (ii) more complex tasks, which involve either 100 possible environments (Figure 14 (a), (b)) or 16 environments with two possible types of demand functions (Figure 14 (c), (d)).

Figures 13 and 14 illustrate the consistently and significantly superior performance of $\texttt{TF}_{\hat{\theta}}$ and $\texttt{Alg}^{*}$ across all tasks compared to the benchmark algorithms. These results underscore the advantage of leveraging prior knowledge about the tested environments.

Figure: (a) Multi-armed bandits
Refer to caption: extracted/5895775/figs/MAB/_4env_20dT_False_Reg.png

Figure: (a) Multi-armed bandits, 100 environments, linear demand
Refer to caption: extracted/5895775/figs/MAB/_100env_20dT_False_Reg.png

Setup. All figures are based on 100 runs. We consider four tasks with 4 environments (i.e., the support of $\mathcal{P}_{\gamma}$ contains only 4 environments) in Figure 13 and two tasks with 100 environments in Figure 14 (a), (b). The setup for these tasks follows the generation methods provided in Appendix E.2.

For the tasks in Figure 14 (c), (d), there are 16 environments included in the support of $\mathcal{P}_{\gamma}$, where 8 environments have demand functions of the linear type and the other 8 have demand functions of the square type (see Appendix E.2 for the definitions of these two types). Both the pre-training and testing samples are drawn from $\mathcal{P}_{\gamma}$, i.e., from these 16 environments. The remaining setups for these tasks follow the methods provided in Appendix E.2.

### C.6 Performance on longer testing horizon

Our paradigm can be generalized to a longer testing horizon (beyond the length of the pre-training data) by introducing a context window. Specifically, we define a context window size $W$ and limit the input to the last $\min\{W,t\}$ timesteps of the input sequence $H_{t}$ to predict $a^{*}_{t}$ during both the pre-training and testing phases. By considering only the latest $\min\{W,t\}$ timesteps, we enable the model to handle testing sequences of any length, even when $t>T$. This technique is commonly used in the literature (e.g., Chen et al. []).

In this part, we evaluate $\texttt{TF}_{\hat{\theta}}$’s generalization ability when the testing horizon is longer than that seen during pre-training. As for a shorter testing horizon, $\texttt{TF}_{\hat{\theta}}$ can simply run until the end of the horizon, and previous results demonstrate strong performances in such cases, particularly when the horizon is less than 100. Figure 15 shows the performance when the testing horizon is extended from 100 (pre-training horizon) to 200 in the newsvendor problem. The results demonstrate that $\texttt{TF}_{\hat{\theta}}$ generalizes well in this extended horizon scenario, even in the censored demand setting where exploration is essential. Its actions remain nearly optimal beyond $t=100$, resulting in lower regret compared to benchmark algorithms. For this experiment, all the pre-training and testing setups follow Appendix E, except the testing horizon length.

Figure: (a) Regret
Refer to caption: extracted/5895775/new_figs/NV/_inf_2d_50ctx_horizon_200T_False_Reg.png

### C.7 Out-of-distribution performance

In this section, we evaluate $\texttt{TF}_{\hat{\theta}}$’s generalization ability under out-of-distribution (OOD) conditions, using dynamic pricing problems as the test case.

Figure: (a) $\sigma^{2}=0.1$ ($<$ pre-training)
Refer to caption: extracted/5895775/new_figs/DP/_inf_4d_123_std_0.1_horizon_100T_False_Reg.png

We test $\texttt{TF}_{\hat{\theta}}$ in three different problem settings with varying testing noise variances while keeping the pre-training variance as $0.2$ for all of them: $\sigma^{2}=0.2$, which matches the noise variance used in pre-training; $\sigma^{2}=0.1$, which is smaller than that used in pre-training; and $\sigma^{2}=0.3$, which is larger. Figure 16 provides the results. We do not observe any significant sign of failure in $\texttt{TF}_{\hat{\theta}}$’s OOD performance: across all three settings, the benchmark algorithms consistently incur higher regret than $\texttt{TF}_{\hat{\theta}}$. Although $\texttt{TF}_{\hat{\theta}}$ shows some variation in mean regret across OOD settings (specifically, lower regret when $\sigma^{2}=0.2$ and higher regret when $\sigma^{2}=0.3$), this is partially due to the varying “difficulty” of the underlying tasks. As expected, higher noise variances, which need more data for accurately estimating the demand function compared to lower variance cases, lead to worse performance for all algorithms tested. However, these variations should not be interpreted as evidence of $\texttt{TF}_{\hat{\theta}}$ failing to handle OOD issues. In fact, all benchmark algorithms show similar performance fluctuations under these conditions, further demonstrating $\texttt{TF}_{\hat{\theta}}$’s good OOD performances. For this experiment, all the pre-training and testing setups follow Appendix E, except the noise variance in the testing samples.

### C.8 Impact of network architecture

Here we investigate the effect of different network architectures on performance. Specifically, we replace the transformer/GPT-2 architecture used in $\texttt{TF}_{\hat{\theta}}$ with Long Short-Term Memory (LSTM) [Hochreiter, ].

We maintain the overall architecture of $\texttt{TF}_{\hat{\theta}}$, as described in Appendix E.1 except for replacing the transformer/GPT-2 module with LSTM. We evaluate two LSTM variants: a 5-layer LSTM and a 12-layer LSTM (for comparison, the tested transformer also has 12 layers). Typically, LSTM architectures should be shallower than transformers in practice, which is why we also include the 5-layer version. Other hyperparameters like embedding space dimension are kept the same across all models. We pre-train and test these models on dynamic pricing problems (see Appendix E.2 for the experimental setup), and the pre-training procedure is identical to the one outlined in Appendix 3.

Figure 17 presents the testing regret for the three models. The results indicate no significant difference between the 5-layer and 12-layer LSTM models. However, the transformer consistently performs better than both LSTM variants. This outcome aligns with the transformer’s superior performance in other domains, such as natural language processing, and suggests that transformers are more effective for sequential decision making tasks as well.

Figure: Figure 17: Comparison of the average out-of-sample regret between using the Transformer and LSTM architectures.
Refer to caption: extracted/5895775/new_figs/LSTM_Reg.png

### C.9 Ablation study on model size and task complexity

In this section, we explore the performance changes when tuning both model size and task complexity. Specifically, we adjust the number of layers to control the model size and the problem dimension (the dimension of the context) in a dynamic pricing task to control the task complexity, where the number of unknown parameters is twice the context dimension. Since the optimal reward may scale differently across dimensions, we provide a relatively fair comparison by evaluating the advantage of $\texttt{TF}_{\hat{\theta}}$ relative to the best-performing benchmark algorithm. This advantage is defined as the reward improvement rate of $\texttt{TF}_{\hat{\theta}}$ compared to the best benchmark algorithm (the one among ILSE, CILS, and TS that achieves the highest reward). Thus, a positive value indicates $\texttt{TF}_{\hat{\theta}}$ outperforms all benchmark algorithms, and a larger value indicates a better performance of $\texttt{TF}_{\hat{\theta}}$. We test three model sizes (4, 8, and 12 layers) and three problem dimensions (4, 10, and 20), while keeping other hyperparameters the same. The results are presented in Figure 18.

Figure: Figure 18: The advantage of $\texttt{TF}_{\hat{\theta}}$ compared to the best benchmark algorithm in dynamic pricing, across different model size (number of layers) and problem complexity (problem dimensions).
Refer to caption: extracted/5895775/new_figs/DP_aba_Reg.png

From Figure 18, we observe the following: (i) $\texttt{TF}_{\hat{\theta}}$ consistently outperforms the benchmark algorithms, and this advantage grows as the complexity of the problem increases. (ii) Increasing model size consistently improves the performance of $\texttt{TF}_{\hat{\theta}}$ across all problem dimensions, indicating that larger models are generally preferred. This highlights $\texttt{TF}_{\hat{\theta}}$’s superior ability to handle more complex tasks and these observations align with the scaling law [Kaplan et al., ] for large language models.

## Appendix D Proofs

### D.1 Discussions on Claim 3.1

Consider the following setup where a feature-target pair $(X,Y)$ is generated from some distribution $\mathcal{P}_{X,Y}(\theta)$. Then we consider the minimization of the following loss

$$ $\min_{\theta}\mathbb{E}_{\mathcal{P}_{X,Y}(\theta)}[l(f_{\theta}(X),Y)]$ $$

for some loss function $l:\mathbb{R}\times\mathbb{R}\rightarrow\mathbb{R}.$

Under this formulation, both the data generation distribution $\mathcal{P}_{X,Y}(\theta)$ and the prediction function $f_{\theta}$ are parameterized by $\theta$. This describes the performative prediction problem [Perdomo et al., ].

In addition, we note that in our pre-trained transformer setting, the joint distribution can be factorized in

$$ $\mathcal{P}_{X,Y}(\theta)=\mathcal{P}_{X}(\theta)\cdot\mathcal{P}_{Y|X}.$ $$

That is, the parameter $\theta$ only induces a covariate shift by affecting the marginal distribution of $X$, but the conditional distribution $\mathcal{P}_{Y|X}$ remains the same for all the $\theta$. This exactly matches our setting of pre-trained transformer; to see this, different decision functions, $f$ or $\texttt{TF}_{\theta_{m}}$, only differ in terms of the generation of the actions $a_{\tau}$’s in $H_{t}$ (for $\tau=1,...,t-1$) which is the features $X$ in this formulation but the optimal action $a_{t}^{*}$ will only be affected by $X_{t}$ in $H_{t}$.

Also, under this factorization, we define the Bayes-optimal estimator as

$$ $f^{*}(X)=\min_{y}\mathbb{E}_{\mathcal{P}_{Y|X}}[l(y,Y)|X].$ $$

Then it is easy to note that when $f^{*}=f_{\theta^{*}}$ for some $\theta^{*}$, and have

$$ $\theta^{*}\in\operatorname*{arg\,min}_{\theta}\mathbb{E}_{\mathcal{P}_{X,Y}( \theta^{\prime})}[l(f_{\theta}(X),Y)]$ $$

for any $\theta^{\prime}.$

In this light, the oscillating behavior of the optimization algorithms in Perdomo et al. [] will not happen. Because for all the data generation distribution $\mathcal{P}_{X,Y}(\theta^{\prime})$, they all point to one optimal $\theta^{*}$.

Back to the context of the pre-trained transformer, such a nice property is contingent on two factors: (i) the transformer function class is rich enough to cover $f^{*}$; (ii) there are infinitely many samples/we can use the expected loss. Also, the above argument is connected to the argument of Proposition 4.1.

### D.2 Proof of Proposition 3.2

As noted in the proposition, let $b$ denote the bound of the loss function, and let the loss function $l\left(\texttt{TF}_{{\theta}}(H),a\right)$ is $D$-Lipschitz with respect to $H$ and $a$. We remark that the constant $D$ could be very large for the transformer model; the bound derived here serves more to illustrate the relationship between the generalization error and various problem parameters, but not really as an empirical bound to predict the test error of the underlying transformer.

Step 1. We aim to show with probability at least $1-h$,

$$ $\displaystyle\kappa L_{f}(\texttt{TF}_{\hat{\theta}})+(1-\kappa)L_{\texttt{TF} _{\tilde{\theta}}}(\texttt{TF}_{\hat{\theta}})\leq$ $\displaystyle\frac{1}{nT}\mathop{\sum}\limits_{i=1}^{n}\mathop{\sum}\limits_{t =1}^{T}l\left(\texttt{TF}_{\hat{\theta}}\left(H_{t}^{(i)}\right),a_{t}^{(i)*}\right)$ $\displaystyle+\sqrt{\frac{\text{Comp}(\{\texttt{TF}_{\theta}:\theta\in\Theta\} )}{nT}}+\sqrt{\frac{2b^{2}}{nT}\log\left(\frac{4}{h}\right)},$ $$

where $\text{Comp}(\{\texttt{TF}_{\theta}:\theta\in\Theta\})$ is some inherent constant describing the complexity of $\{\texttt{TF}_{\theta}:\theta\in\Theta\}$. Note that when samples follow the generation process (actions are generated by $f$)

$$ $\mathcal{P}_{\gamma}\rightarrow\gamma_{i}\rightarrow\mathcal{P}_{\gamma_{i},f} \rightarrow\left\{\left(H_{1}^{(i)},a_{1}^{(i)*}\right),\ldots,\left(H_{T}^{(i )},a_{T}^{(i)*}\right)\right\},$ $$

and

$$ $L_{f}(\texttt{TF}_{\theta})=\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}}\left[L _{f}(\texttt{TF}_{\theta};\gamma)\right]=\mathbb{E}_{\gamma\sim\mathcal{P}_{ \gamma}}\left[\mathbb{E}_{(H_{t},a_{t}^{*})\sim\mathcal{P}_{\gamma,f}}\left[ \sum_{t=1}^{T}l\left(\texttt{TF}_{\theta}\left(H_{t}\right),a_{t}^{*}\right) \right]\right].$ $$

Since $l\left(\texttt{TF}_{{\theta}}(\cdot),\cdot\right)$ is bounded by $b$, we can apply the McDiarmid’s inequality (see Theorem D.8 in [Mohri et al., ] for more details) with constant $\frac{2b}{nT}$ to $\mathop{\sup}\limits_{\theta\in\Theta}\bigg{|}\frac{1}{nT}\mathop{\sum}\limits
_{i=1}^{n}\mathop{\sum}\limits_{t=1}^{T}l\left(\texttt{TF}_{\theta}\left(H_{t}
^{(i)}\right),a_{t}^{(i)*}\right)-L_{f}(\texttt{TF}_{\theta})\bigg{|}$ such that
with probability at least $1-h$, we have

$$ $\displaystyle\mathop{\sup}\limits_{\theta\in\Theta}\Bigg{|}\frac{1}{nT}\mathop {\sum}\limits_{i=1}^{n}\mathop{\sum}\limits_{t=1}^{T}l\left(\texttt{TF}_{ \theta}\left(H_{t}^{(i)}\right),a_{t}^{(i)*}\right)-L_{f}(\texttt{TF}_{\theta} )\Bigg{|}$ $\displaystyle\leq$ $\displaystyle\mathbb{E}_{(H_{t},a_{t}^{*})\sim\mathcal{P}_{\gamma,f}}\left[ \mathop{\sup}\limits_{\theta\in\Theta}\Bigg{|}\frac{1}{nT}\mathop{\sum}\limits _{i=1}^{n}\mathop{\sum}\limits_{t=1}^{T}l\left(\texttt{TF}_{\theta}\left(H_{t} ^{(i)}\right),a_{t}^{(i)*}\right)-\mathbb{E}_{(H_{t},a_{t}^{*})\sim\mathcal{P} _{\gamma,f}}\left[\mathop{\sum}\limits_{t=1}^{T}l\left(\texttt{TF}_{\theta} \left(H_{t}\right),a_{t}^{*}\right)\right]\Bigg{|}\right]$ (10) $\displaystyle+\sqrt{\frac{2b^{2}}{nT}\log\left(\frac{2}{h}\right)}$ $\displaystyle\leq$ $\displaystyle 2\mathbb{E}_{(H_{t},a_{t}^{*})\sim\mathcal{P}_{\gamma,f},w_{it}} \left[\mathop{\sup}\limits_{\theta\in\Theta}\Bigg{|}\frac{1}{nT}\mathop{\sum} \limits_{i=1}^{n}\mathop{\sum}\limits_{t=1}^{T}w_{it}l\left(\texttt{TF}_{ \theta}\left(H_{t}^{(i)}\right),a_{t}^{(i)*}\right)\Bigg{|}\right]+\sqrt{\frac {2b^{2}}{nT}\log\left(\frac{2}{h}\right)}$ $\displaystyle\leq$ $\displaystyle\sqrt{\frac{\text{Comp}(\{\texttt{TF}_{\theta}:\theta\in\Theta\}) }{nT}}+\sqrt{\frac{2b^{2}}{nT}\log\left(\frac{2}{h}\right)},$ (11) $$

where the second inequality uses the symmetric tricks (see Theorem 3.3 in [Mohri et al., ] for more details), and $w_{it}$, so-called Rademacher variables are independent uniform random variables taking values in $\left\{-1,1\right\}$.

Similarly, when samples follow the generation process (actions are generated by $\text{TF}_{\bar{\theta}}$)

$$ $\mathcal{P}_{\gamma}\rightarrow\gamma_{i}\rightarrow\mathcal{P}_{\gamma_{i}, \texttt{TF}_{\tilde{\theta}}}\rightarrow\left\{\left(H_{1}^{(i)},a_{1}^{(i)*} \right),\ldots,\left(H_{T}^{(i)},a_{T}^{(i)*}\right)\right\},$ $$

by using the same tricks, we can have that with probability at least $1-h$,

$$ $\displaystyle\mathop{\sup}\limits_{\theta\in\Theta}\Bigg{|}\frac{1}{nT}\mathop {\sum}\limits_{i=1}^{n}\mathop{\sum}\limits_{t=1}^{T}l\left(\texttt{TF}_{ \theta}\left(H_{t}^{(i)}\right),a_{t}^{(i)*}\right)-L_{\texttt{TF}_{\tilde{ \theta}}}(\texttt{TF}_{\theta})\Bigg{|}\leq\sqrt{\frac{\text{Comp}(\{\texttt{ TF}_{\theta}:\theta\in\Theta\})}{nT}}+\sqrt{\frac{2b^{2}}{nT}\log\left(\frac{2 }{h}\right)}.$ (12) $$

Since $\hat{\theta}$ is determined by (6) where $\kappa n$ data sequences are from $\mathcal{P}_{\gamma,f}$ and $(1-\kappa)n$ data sequences are from $\mathcal{P}_{\gamma,\texttt{TF}_{\tilde{\theta}}}$, by taking the uniform bound of equations (11) and (12), we have with probability at least $1-h$,

$$ $\displaystyle\kappa L_{f}(\texttt{TF}_{\hat{\theta}})+(1-\kappa)L_{\texttt{TF} _{\tilde{\theta}}}(\texttt{TF}_{\hat{\theta}})\leq$ $\displaystyle\frac{1}{nT}\mathop{\sum}\limits_{i=1}^{n}\mathop{\sum}\limits_{t =1}^{T}l\left(\texttt{TF}_{\hat{\theta}}\left(H_{t}^{(i)}\right),a_{t}^{(i)*}\right)$ $\displaystyle+\sqrt{\frac{\text{Comp}(\{\texttt{TF}_{\theta}:\theta\in\Theta\} )}{nT}}+\sqrt{\frac{2b^{2}}{nT}\log\left(\frac{4}{h}\right)}.$ $$

Step 2. Now we show

$$ $L(\texttt{TF}_{\hat{\theta}})\leq L_{f}(\texttt{TF}_{\hat{\theta}})+TD\cdot \mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}}\left[W_{1}\left(\mathcal{P}_{ \gamma,f},\mathcal{P}_{\gamma,\texttt{TF}_{\hat{\theta}}}\right)\right],$ $$

$$ $L(\texttt{TF}_{\hat{\theta}})\leq L_{f}(\texttt{TF}_{\hat{\theta}})+TD\cdot \mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}}\left[W_{1}\left(\mathcal{P}_{ \gamma,\texttt{TF}_{\tilde{\theta}}},\mathcal{P}_{\gamma,\texttt{TF}_{\hat{ \theta}}}\right)\right],$ $$

where $W_{1}(\cdot,\cdot)$ is the Wasserstein-1 distance.

By Kantorovich-Rubinstein’s theorem, for distributions $\mathcal{D}_{1}$ and $\mathcal{D}_{2}$, we have

$$ $W_{1}(\mathcal{D}_{1},\mathcal{D}_{2})=\sup\left\{\big{|}\mathbb{E}_{X\sim \mathcal{D}_{1}}g(X)-\mathbb{E}_{X\sim\mathcal{D}_{2}}g(X)\big{|}\ \big{|}\ g: \mathbb{R}^{p}\rightarrow\mathbb{R},\ \text{$g$ is 1-Lipschitz}\right\}.$ $$

Since $l\left(\texttt{TF}_{{\theta}}(H),a\right)$ is $D$-Lipschitz with respect to $H$ and $a$ for all $\theta\in\Theta$, we have

$$ $\displaystyle L\left(\texttt{TF}_{\hat{\theta}};\gamma\right)-L_{f}\left( \texttt{TF}_{\hat{\theta}};\gamma\right)$ $\displaystyle=\mathbb{E}_{(H_{t},a_{t}^{*})\sim\mathcal{P}_{\gamma,\texttt{TF} _{\hat{\theta}}}}\left[\sum_{t=1}^{T}l\left(\texttt{TF}_{\hat{\theta}}\left(H_ {t}\right),a_{t}^{*}\right)\right]-\mathbb{E}_{(H_{t},a_{t}^{*})\sim\mathcal{P }_{\gamma,f}}\left[\sum_{t=1}^{T}l\left(\texttt{TF}_{\hat{\theta}}\left(H_{t} \right),a_{t}^{*}\right)\right]$ $\displaystyle\leq TD\cdot W_{1}\left(\mathcal{P}_{\gamma,f},\mathcal{P}_{ \gamma,\texttt{TF}_{\hat{\theta}}}\right),$ $$

which implies that $L(\texttt{TF}_{\hat{\theta}})\leq L_{f}(\texttt{TF}_{\hat{\theta}})+TD\cdot
\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}}\left[W_{1}\left(\mathcal{P}_{
\gamma,f},\mathcal{P}_{\gamma,\texttt{TF}_{\hat{\theta}}}\right)\right]$. Similarly, we have $L(\texttt{TF}_{\hat{\theta}})\leq L_{f}(\texttt{TF}_{\hat{\theta}})+TD\cdot
\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}}\left[W_{1}\left(\mathcal{P}_{
\gamma,\texttt{TF}_{\tilde{\theta}}},\mathcal{P}_{\gamma,\texttt{TF}_{\hat{
\theta}}}\right)\right]$.

Therefore, by combining step 1 and step 2, we can conclude that with probability at least $1-h$,

$$ $\displaystyle L(\texttt{TF}_{\hat{\theta}})\leq$ $\displaystyle\hat{L}(\texttt{TF}_{\hat{\theta}})+\sqrt{\frac{\text{Comp}(\{ \texttt{TF}_{\theta}:\theta\in\Theta\})}{nT}}$ $\displaystyle+\kappa TD\cdot\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}}\left[W _{1}\left(\mathcal{P}_{\gamma,f},\mathcal{P}_{\gamma,\texttt{TF}_{\hat{\theta} }}\right)\right]$ $\displaystyle+(1-\kappa)TD\cdot\mathbb{E}_{\gamma\sim\mathcal{P}_{\gamma}} \left[W_{1}\left(\mathcal{P}_{\gamma,\texttt{TF}_{\tilde{\theta}}},\mathcal{P} _{\gamma,\texttt{TF}_{\hat{\theta}}}\right)\right]+\sqrt{\frac{2b^{2}}{nT}\log \left(\frac{4}{h}\right)},$ $$

which completes the proof.

### D.3 Proof of Proposition 4.1

###### Proof.

The proof can be done with the definition of $\texttt{Alg}^{*}.$ Also, we refer more discussion to Section D.1.
∎

###### Proof.

### D.4 Proof of Example 4.2

###### Proof.

Since $\texttt{Alg}^{*}$ is a function of any possible history $H_{t}$, we omit the subscrpit $t$ for the optimal actions for notation simplicity, and use $a^{(\gamma)*}$ as the optimal action of $\gamma$.

- •
Posterior sampling under the cross-entropy loss. We assume that $\mathcal{A}=\{a_{1},\ldots,a_{J}\}$ and the output of $\texttt{Alg}^{*}$ is a probability vector $(p_{1},\ldots,p_{J})$ such that $\sum_{j=1}^{J}p_{j}=1$, meaning the probability of choosing each action. Then
$\displaystyle\texttt{Alg}^{*}(H)$
$\displaystyle=\operatorname*{arg\,min}_{\sum_{j=1}^{J}p_{j}=1}\int_{\gamma}-
\log\left(p_{a^{(\gamma)*}}\right)\mathbb{P}(H|\gamma)\mathrm{d}\mathcal{P}_{\gamma}$
$\displaystyle=\operatorname*{arg\,min}_{\sum_{j=1}^{J}p_{j}=1}\ \sum_{j=1}^{J}
\left(-\log\left(p_{j}\right)\right)\int_{\left\{\gamma:\ a^{(\gamma)*}=j
\right\}}\mathbb{P}(H|\gamma)\mathrm{d}\mathcal{P}_{\gamma}.$
By nothing $\int_{\left\{\gamma:\ a^{(\gamma)*}=j\right\}}\mathbb{P}(H|\gamma)\mathrm{d}
\mathcal{P}_{\gamma}$ is the probability such that action $j$ is the optimal action conditional on $H$ (i.e., the posterior distribution of the optimal action), we are indeed minimizing the cross-entropy of the posterior distribution of the optimal action relative to the decision variables $p_{j}$. Thus, the optimal solution $p^{*}_{j}=\int_{\left\{\gamma:\ a^{(\gamma)*}=j\right\}}\mathbb{P}(H|\gamma)
\mathrm{d}\mathcal{P}_{\gamma}$ for each $j$ and $\texttt{Alg}^{*}(H_{t})$ behaves as the posterior sampling.
- •
Posterior averaging under the squared loss. By definition,
$\displaystyle\texttt{Alg}^{*}(H)$
$\displaystyle=\operatorname*{arg\,min}_{a\in\mathcal{A}}\int_{\gamma}||a-a^{(
\gamma)*}||^{2}_{2}\mathbb{P}(H|\gamma)\mathrm{d}\mathcal{P_{\gamma}}$
$\displaystyle=\frac{\int_{\gamma}a^{(\gamma)*}\mathbb{P}(H|\gamma)\mathrm{d}
\mathcal{P_{\gamma}}}{\int_{\gamma}\mathbb{P}(H|\gamma)\mathrm{d}\mathcal{P_{
\gamma}}}$
$\displaystyle=\mathbb{E}_{\gamma}[a^{(\gamma)*}|H]$
where the second line is by the first order condition.
- •
Posterior median under the absolute loss. By definition,
$\displaystyle\texttt{Alg}^{*}(H)$
$\displaystyle=\operatorname*{arg\,min}_{a\in\mathcal{A}}\int_{\gamma}|a-a^{(
\gamma)*}|\mathbb{P}(H|\gamma)\mathrm{d}\mathcal{P_{\gamma}}.$
Then by zero-subgradient condition,
we can conclude that $\texttt{Alg}^{*}(H)$ satisfies
$\int_{\left\{\gamma:\ \texttt{Alg}^{*}(H)\leq a^{(\gamma)*}\right\}}\mathbb{P}
(H|\gamma)\mathrm{d}\mathcal{P_{\gamma}}=\int_{\left\{\gamma:\ \texttt{Alg}^{*
}(H)\geq a^{(\gamma)*}\right\}}\mathbb{P}(H|\gamma)\mathrm{d}\mathcal{P_{
\gamma}}.$
Divide both sides of this equation by $\int_{\gamma}\mathbb{P}(H|\gamma)\mathrm{d}\mathcal{P_{\gamma}}$, we can conclude that
$\int_{\left\{\gamma:\ \texttt{Alg}^{*}(H)\leq a^{(\gamma)*}\right\}}\mathrm{d}
\mathcal{P}\left({\gamma}|H\right)=\int_{\left\{\gamma:\ \texttt{Alg}^{*}(H)
\geq a^{(\gamma)*}\right\}}\mathrm{d}\mathcal{P}\left({\gamma}|H\right)$
where $\mathcal{P}\left(\gamma|H_{t}\right)$ is the posterior distribution of $\gamma$. Hence $\texttt{Alg}^{*}(H)$ is the posterior median.

∎

###### Proof.

### D.5 Proof of Proposition 4.3

###### Proof.

For the linear bandits problem, we consider the following example. Suppose we have two environments, ${\gamma_{1},\gamma_{2}}$, each with standard normal distributed noise and unknown parameters $w_{\gamma_{1}}=(1,0)$ and $w_{\gamma_{2}}=(0,1)$, respectively. Let the action space be $\mathcal{A}=[-1,1]\times[-1,1]$. The optimal actions for the two environments are
$a^{(1)*}=(1,0)$, $a^{(2)*}=(0,1)$. We assume the prior distribution $\mathcal{P}_{\gamma}$ is given by $\mathcal{P}_{\gamma}(\gamma_{1})=\mathcal{P}_{\gamma}(\gamma_{2})=\frac{1}{2}$.

Then if $\texttt{Alg}^{*}$ is the posterior averaging, we have

$$ $\displaystyle a_{t}=\texttt{Alg}^{*}(H_{t})=\mathcal{P}_{\gamma}\left(\gamma_{ 1}|H_{t}\right)\cdot a^{(1)*}+\mathcal{P}_{\gamma}\left(\gamma_{2}|H_{t}\right )\cdot a^{(2)*},$ $$

where the posterior distribution $\mathcal{P}_{\gamma}\left(\gamma_{i}|H_{t}\right)$ is given by

$$ $\displaystyle\mathcal{P}_{\gamma}\left(\gamma_{i}|H_{t}\right)=\frac{\prod_{ \tau=1}^{t-1}\mathbb{P}_{\gamma_{i}}(o_{\tau}|a_{\tau})}{\sum_{i^{\prime}=1}^{ 2}\prod_{\tau=1}^{t-1}\mathbb{P}_{\gamma_{i^{\prime}}}(o_{\tau}|a_{\tau})}, \quad i=1,2.$ $$

We now use induction to show $\mathcal{P}_{\gamma}\left(\gamma_{i}|H_{t}\right)=\frac{1}{2}$ for any $t\geq 1$ and $i=1,2$, where $H_{t}$ can be generated by either $\gamma_{1}$ or $\gamma_{2}$. This results in $a_{t}=\frac{1}{2}a^{(1)*}+\frac{1}{2}a^{(2)*}=\left(\frac{1}{2},\frac{1}{2}\right)$, which does not change with respect to $t$ and will cause regret linear in $T$.

Step 1. Since $\mathcal{P}_{\gamma}\left(\gamma_{i}|H_{0}\right)=\mathcal{P}_{\gamma}\left(
\gamma_{i}\right)=\frac{1}{2}$, we have $a_{1}=\frac{1}{2}a^{(1)*}+\frac{1}{2}a^{(2)*}=(\frac{1}{2},\frac{1}{2})$, and the conclusion holds for $t=1$.

Step 2. Now assume the conclusion holds for $t$, i.e., $\mathcal{P}_{\gamma}\left(\gamma_{i}|H_{t}\right)=\frac{1}{2}$, and $a_{t}=\left(\frac{1}{2},\frac{1}{2}\right)$. Since $w_{\gamma_{1}}^{T}a_{t}=w_{\gamma_{2}}^{T}a_{t}=\frac{1}{2}$, we have $\mathbb{P}_{\gamma_{i}}(o_{t}|a_{t})=\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{
\left(o_{t}-\frac{1}{2}\right)^{2}}{2}\right)$ for $i=1,2$. Observe that

$$ $\displaystyle\mathcal{P}_{\gamma}(\gamma_{i}|H_{t+1})=\frac{\mathbb{P}_{\gamma _{i}}(o_{t+1}|a_{t+1})\mathcal{P}_{\gamma}(\gamma_{i}|H_{t})}{\sum_{i^{\prime} =1}^{2}\mathbb{P}_{\gamma_{i^{\prime}}}(o_{t+1}|a_{t+1})\mathcal{P}_{\gamma}( \gamma_{i^{\prime}}|H_{t})}=\frac{1}{2},$ $$

which implies $a_{t+1}=\left(\frac{1}{2},\frac{1}{2}\right)$, and the conclusion holds for $t+1$.

Thus, the conclusion holds for all $t\geq 1$. Then the regret is

$$ $\displaystyle\text{Regret}(\texttt{Alg}^{*};\gamma_{i})=\mathbb{E}\left[\sum_{ t=1}^{T}r(X_{t},a_{t}^{*})-r(X_{t},a_{t})\right]=\frac{1}{2}T$ $$

for $i=1,2$.

For the dynamic pricing problem, we can construct a similar example. Suppose we have two environments without context $X_{t}$, denoted by $\gamma_{1},\gamma_{2}$. The demands $o_{t}$ of them are set to be $o_{t}=2-a_{t}+\epsilon_{t}$ and $o_{t}=\frac{4}{5}-\frac{1}{5}\cdot a_{t}+\epsilon_{t}$ respectively, where $\epsilon_{t}\overset{i.i.d.}{\sim}\mathcal{N}(0,1)$ and $a_{t}$ is the price. Accordingly, the optimal actions are then $a^{(1)*}=1$ and $a^{(2)*}=2$.

Then if $\texttt{Alg}^{*}$ is the posterior averaging, we have

$$ $\displaystyle a_{t}=\texttt{Alg}^{*}(H_{t})=\mathcal{P}_{\gamma}\left(\gamma_{ 1}|H_{t}\right)\cdot a^{(1)*}+\mathcal{P}_{\gamma}\left(\gamma_{2}|H_{t}\right )\cdot a^{(2)*},$ $$

where the posterior distribution $\mathcal{P}_{\gamma}\left(\gamma_{i}|H_{t}\right)$ is given by

$$ $\displaystyle\mathcal{P}_{\gamma}\left(\gamma_{i}|H_{t}\right)=\frac{\prod_{ \tau=1}^{t-1}\mathbb{P}_{\gamma_{i}}(o_{\tau}|a_{\tau})}{\sum_{i^{\prime}=1}^{ 2}\prod_{\tau=1}^{t-1}\mathbb{P}_{\gamma_{i^{\prime}}}(o_{\tau}|a_{\tau})}, \quad i=1,2.$ $$

with $\mathbb{P}_{\gamma_{1}}(o_{\tau}|a_{\tau})$ as the normal distribution $\mathcal{N}\left(2-a_{t},1\right)$ and $\mathbb{P}_{\gamma_{2}}(o_{\tau}|a_{\tau})$ as $\mathcal{N}\left(\frac{4-a_{t}}{5},1\right)$.

Observe that $a_{1}=\frac{1}{2}a^{(1)*}+\frac{1}{2}a^{(2)*}=\frac{3}{2}$ satisfies $2-a_{1}=\frac{4-a_{1}}{5}$. Following a similar analysis as in the linear bandits example, we can conclude that $\mathcal{P}_{\gamma}\left(\gamma_{i}|H_{t}\right)=\frac{1}{2}$ for any $t$ and $i=1,2$, where $H_{t}$ can be generated by either $\gamma_{1}$ or $\gamma_{2}$. Therefore, $a_{t}=\frac{3}{2}$ for all $t\geq 1$ and the regret is

$$ $\displaystyle\text{Regret}(\texttt{Alg}^{*};\gamma_{i})=\mathbb{E}\left[\sum_{ t=1}^{T}r(X_{t},a_{t}^{*})-r(X_{t},a_{t})\right]=\frac{1}{4}T\cdot\mathbb{I} \left\{\gamma_{i}=\gamma_{1}\right\}+\frac{1}{20}T\cdot\mathbb{I}\left\{\gamma _{i}=\gamma_{2}\right\},$ $$

for $i=1,2$.

∎

###### Proof.

### D.6 Proof of Proposition 4.4

We make the following additional assumptions:

- •
There exists a constant $\bar{r}$ such that $\sup_{x\in\mathcal{X},a\in\mathcal{A},\gamma\in\Gamma}r(x,a;\gamma)\leq\bar{r}$, where we use $r(x,a;\gamma)$ to denote the reward function of environment $\gamma$.
- •
There exists a constant $C_{r}$ such that $\texttt{Alg}^{*}$ satisfies
$\mathbb{E}[r(X_{t},a^{*}_{t})-r(X_{t},\texttt{Alg}^{*}(H_{t}))|H_{t}]\leq C_{r
}\sum_{\gamma_{i}\neq\gamma}\mathcal{P}(\gamma_{i}|H_{t}),$
where the expectation on the left side is taken with respect to the possible randomness in $\texttt{Alg}^{*}$.
- •
$\mathcal{P}_{\gamma}$ is a uniform distribution over $\Gamma$.

###### Proof.

We first compute a concentration inequality for $\sum_{\tau=1}^{t}\log\left(\frac{\mathbb{P}_{\gamma}(o_{\tau}|X_{\tau},a_{\tau
})}{\mathbb{P}_{\gamma^{\prime}}(o_{\tau}|X_{\tau},a_{\tau})}\right)$. By the Bernstein-type concentration bound for a martingale difference sequence (Theorem 2.19 in [Wainwright, ]), under the given conditions, we have for any $\gamma^{\prime}\in\Gamma$, $t>0$ and $1>\delta>0$ with probability $1-\delta$,

$$ $\sum_{\tau=1}^{t}\log\left(\frac{\mathbb{P}_{\gamma}(o_{\tau}|X_{\tau},a_{\tau })}{\mathbb{P}_{\gamma^{\prime}}(o_{\tau}|X_{\tau},a_{\tau})}\right)-\mathbb{E }\left[\log\left(\frac{\mathbb{P}_{\gamma}(o_{\tau}|X_{\tau},a_{\tau})}{ \mathbb{P}_{\gamma^{\prime}}(o_{\tau}|X_{\tau},a_{\tau})}\right)\right]\geq- \sqrt{2C_{\sigma^{2}}\Delta_{\text{Explore}}t\log(1/\delta)},$ $$

where

$$ $\sum_{\tau=1}^{t}\mathbb{E}\left[\log\left(\frac{\mathbb{P}_{\gamma}(o_{\tau}| X_{\tau},a_{\tau})}{\mathbb{P}_{\gamma^{\prime}}(o_{\tau}|X_{\tau},a_{\tau})} \right)\right]=\sum_{\tau=1}^{t}\text{KL}\left(\mathbb{P}_{\gamma}(\cdot\big{| }X_{\tau},a_{\tau})\|\mathbb{P}_{\gamma^{\prime}}(\cdot\big{|}X_{\tau},a_{\tau })\right)\geq t\Delta_{\text{Explore}}.$ $$

We think about two situations:

- •
If $\sqrt{t\Delta_{\text{Explore}}}\geq 2\sqrt{2C_{\sigma^{2}}\log(1/\delta)}$, then
$\displaystyle\sum_{\tau=1}^{t}\log\left(\frac{\mathbb{P}_{\gamma}(o_{\tau}|X_{
\tau},a_{\tau})}{\mathbb{P}_{\gamma^{\prime}}(o_{\tau}|X_{\tau},a_{\tau})}\right)$
$\displaystyle\geq t\Delta_{\text{Explore}}-\frac{1}{2}t\Delta_{\text{Explore}}$
$\displaystyle=\frac{1}{2}t\Delta_{\text{Explore}}$
$\displaystyle>\frac{1}{2}t\Delta_{\text{Explore}}-4C_{\sigma^{2}}\log(1/\delta).$
- •
If $\sqrt{t\Delta_{\text{Explore}}}<2\sqrt{2C_{\sigma^{2}}\log(1/\delta)}$, then
$\displaystyle\sum_{\tau=1}^{t}\log\left(\frac{\mathbb{P}_{\gamma}(o_{\tau}|X_{
\tau},a_{\tau})}{\mathbb{P}_{\gamma^{\prime}}(o_{\tau}|X_{\tau},a_{\tau})}\right)$
$\displaystyle>t\Delta_{\text{Explore}}-4C_{\sigma^{2}}\log(1/\delta)$
$\displaystyle\geq\frac{1}{2}t\Delta_{\text{Explore}}-4C_{\sigma^{2}}\log(1/
\delta).$

Thus with probability $1-\delta$, we have

$$ $\sum_{\tau=1}^{t}\log\left(\frac{\mathbb{P}_{\gamma}(o_{\tau}|X_{\tau},a_{\tau })}{\mathbb{P}_{\gamma^{\prime}}(o_{\tau}|X_{\tau},a_{\tau})}\right)>\frac{1}{ 2}t\Delta_{\text{Explore}}-4C_{\sigma^{2}}\log(1/\delta).$ $$

Now we apply the union bound to $\gamma_{i}$ for $i=1,\ldots,k$ and for $t=1,\ldots,T$: with probability $1-1/T$, for all $i=1,\ldots,k$, and $t=1,\ldots,T$

$$ $\displaystyle\mathcal{P}(\gamma_{i}|H_{t})$ $\displaystyle\leq\mathcal{P}(\gamma|H_{t})\cdot\exp\left(-\frac{1}{2}t\Delta_{ \text{Explore}}+4C_{\sigma^{2}}\log(1/\delta)\right).$ $$

Now we are ready to prove the regret bound. We first decompose the regret:

$$ $\displaystyle\text{Regret}(\texttt{TF}_{\hat{\theta}};\gamma)$ $\displaystyle=\sum_{t=1}^{T}\mathbb{E}[r(X_{t},\texttt{Alg}^{*}(H_{t}))-r(X_{t },\texttt{TF}_{\hat{\theta}}(H_{t}))]+\sum_{t=1}^{T}\mathbb{E}[r(X_{t},a^{*}_{ t})-r(X_{t},\texttt{Alg}^{*}(H_{t}))]$ $\displaystyle\leq\Delta_{\text{Exploit}}T+C_{r}\mathbb{E}\left[\sum_{t=1}^{T} \sum_{\gamma_{i}\neq\gamma}\mathcal{P}(\gamma_{i}|H_{t})\right].$ $$

Since $\mathcal{P}(\gamma_{i}|H_{t})+\mathcal{P}(\gamma|H_{t})\leq 1$, we have with probability $1-1/T$, for all $i=1,\ldots,k$, and $t=1,\ldots,T$,

$$ $\mathcal{P}(\gamma_{i}|H_{t})\leq\frac{1}{1+\exp\left(\frac{1}{2}t\Delta_{ \text{Explore}}-4C_{\sigma^{2}}\log(kT^{2})\right)}.$ $$

Let $t_{0}=\left\lceil{\frac{16C_{\sigma^{2}}\log(kT^{2})}{\Delta_{\text{Explore}}}
}\right\rceil$, then we have with probability $1-1/T$, for all $i=1,\ldots,k$, and $t=1,\ldots,T$,

$$ $\mathcal{P}(\gamma_{i}|H_{t})\leq\frac{1}{1+\exp\left(\frac{1}{2}t\Delta_{ \text{Explore}}-4C_{\sigma^{2}}\log(kT^{2})\right)}<\exp\left(-\frac{1}{4}t \Delta_{\text{Explore}}\right).$ $$

Thus, we can conclude that

$$ $\displaystyle\mathbb{E}\left[\sum_{t=1}^{T}\sum_{\gamma_{i}\neq\gamma}\mathcal {P}(\gamma_{i}|H_{t})\right]$ $\displaystyle<1+\frac{16C_{\sigma^{2}}\bar{r}\log(kT^{2})}{\Delta_{\text{ Explore}}}+k\mathbb{E}\left[\sum_{t=t_{0}}^{T}\exp\left(-\frac{1}{4}t\Delta_{ \text{Explore}}\right)\right]$ $\displaystyle=O\left(\frac{\log k}{\Delta_{\text{Explore}}}\right)$ $$

and finish the regret bound.

∎

###### Proof.

### D.7 Example/Justification for the conditions in Proposition 4.4

We use a set of linear bandits problems as a an example to illustrate Proposition 4.4. Consider a set of linear bandits problems with $o_{t}=R_{t}=w^{\top}a_{t}+\epsilon_{t}$, where $\epsilon_{t}$ is i.i.d. from a standard Normal distribution. Recall the environment parameter $\gamma=w$ here. We assume it has dimension $d$ and both $\mathcal{A}$ and $\Gamma$ are bounded with respect to the $L2$ norm. Further, we assume $\texttt{Alg}^{*}(H_{t})$ is posterior averaging and for each time $t$,

$$ $\texttt{TF}_{\hat{\theta}}(H_{t})=\texttt{Alg}^{*}(H_{t})+\Delta_{t},$ $$

where $\Delta_{t}$ follows a uniform distribution in $[-1,1]^{d}$, i.i.d. across time and independent of $H_{t}$, $a_{t}$, and $\gamma$. This follows the numerical observations in Figure 3.

In this setting, we verify the conditions in Proposition 4.4. To simplify notations, we denote $\tilde{a}^{*}_{t}=\texttt{Alg}^{*}(H_{t})$.

First condition. Since

$$ $\mathbb{E}[r(X_{t},\texttt{Alg}^{*}(H_{t}))-r(X_{t},\texttt{TF}_{\hat{\theta}} (H_{t}))|H_{t}]=\mathbb{E}[\gamma^{\top}\tilde{a}^{*}_{t}-\gamma^{\top}\tilde{ a}^{*}_{t}-\gamma^{\top}\Delta_{t}|H_{t}]=0,$ $$

we have $\Delta_{\text{Exploit}}=0.$

Second condition. Since $\epsilon_{t}$ is i.i.d. from a standard Normal distribution, we have for $o_{t}=\gamma^{\top}a_{t}+\epsilon_{t}$ and $a_{t}=\texttt{TF}_{\hat{\theta}}(H_{t})$,

$$ $\displaystyle\log\left(\frac{\mathbb{P}_{\gamma}(o_{t}|X_{t},a_{t})}{\mathbb{P }_{\gamma^{\prime}}(o_{t}|X_{t},a_{t})}\right)$ $\displaystyle=\frac{(o_{t}-\gamma^{{}^{\prime}\top}a_{t})^{2}-(o_{t}-\gamma^{ \top}a_{t})^{2}}{2}$ $\displaystyle=\frac{((\gamma-\gamma^{\prime})^{\top}a_{t})^{2}}{2}-(\gamma- \gamma^{\prime})^{\top}a_{t}\epsilon_{t}.$ $$

Thus, the KL divergence, which is the expectation of the above term with respect to $\epsilon_{t}$ and $\Delta_{t}$ (which are independent of $H_{t}$), is

$$ $\mathbb{E}\left[\frac{((\gamma-\gamma^{\prime})^{\top}(\tilde{a}^{*}_{t}+ \Delta_{t}))^{2}}{2}\bigg{|}H_{t}\right]\geq\frac{1}{6}\|\gamma-\gamma^{\prime }\|_{2}^{2}.$ $$

And further, for the “noise” term $(\gamma-\gamma^{\prime})^{\top}a_{t}\epsilon_{t}$, since its variance is bounded by $O(\|\gamma-\gamma^{\prime}\|_{2}^{2})$ (due to the assumptions on the boundedness of $a_{t}$ and that $\epsilon_{t}$ follows a standard Normal distribution), we can set $\Delta_{\text{Explore}}=\min_{\gamma^{\prime}\in\Gamma}\|\gamma-\gamma^{\prime
}\|_{2}^{2}.$

Further, since

$$ $\mathbb{E}[r(X_{t},a^{*}_{t})-r(X_{t},\texttt{Alg}^{*}(H_{t}))|H_{t}]\leq\bar{ r}\sum_{\gamma_{i}\neq\gamma}\mathcal{P}(\gamma_{i}|H_{t}),$ $$

we can set $C_{r}=\bar{r}$.

And thus, we can conclude the regret bound is $\text{Regret}(\texttt{TF}_{\hat{\theta}},\gamma)=O\left(\frac{\log k}{\min_{
\gamma^{\prime}\in\Gamma}\|\gamma-\gamma^{\prime}\|_{2}^{2}}\right)$.

## Appendix E Details for Numerical Experiments

### E.1 Transformer Architecture and Algorithm 1 Implementation

#### E.1.1 Transformer for sequential decision making

We adopt the transformer architecture for regression tasks from [Garg et al., ] to solve sequential decision-making tasks, with modifications tailored to our specific setting.

Prompt. At time $t$, the prompt consists of two types of elements derived from the history $H_{t}$: (i) the “feature” elements, which stack the context $X_{\tau}\in\mathbb{R}^{d}$ at each time $\tau\leq t$ and the observation $o_{\tau-1}\in\mathbb{R}^{k}$ from $\tau-1$ (with $o_{0}$ set as a $k$-dimensional zero vector in our experiments), i.e., $\{(X_{\tau},o_{\tau-1})\}_{\tau=1}^{t}\subset\mathbb{R}^{d+k}$. These elements serve as the “features” in the prediction; and (ii) the “label” elements, which are the actions $\{a_{\tau}\}_{\tau=1}^{t-1}$ in $H_{t}$. Therefore, the prompt contains $2t-1$ elements in total.

Architecture. The transformer is based on the GPT-2 family [Radford et al., ]. It uses two learnable linear transformations to map each “feature” and “label” element into vectors in the embedding space respectively (similar to tokens in language models). These vectors are processed through the GPT-2’s attention mechanism, resulting in a vector that encapsulates relevant contextual information. This vector then undergoes another learnable linear transformation, moving from the embedding space to the action $\mathcal{A}$, ultimately resulting in the prediction of $a^{*}_{t}$. In our experiments, the GPT-2 model has 12 layers, 16 attention heads, and a 256-dimensional embedding space. The experiments are conducted on 2 A100 GPUs with DistributedDataParallel method of Pytorch.

#### E.1.2 Algorithm 1 implementation and pre-training details

During pre-training, we use the AdamW optimizer with a learning rate of $10^{-4}$ and a weight decay of $10^{-4}$. The dropout rate is set to 0.05. For implementing Algorithm 1 in our experiments, we set the total iterations $M=130$ with an early training phase of $M_{0}=50$. The number of training sequences per iteration is $n=1500\times 64$, which are randomly split into 1500 batches with a batch size of 64. The transformer’s parameter $\theta$ is optimized to minimize the averaged loss of each batch. As suggested in Proposition B.2, we select the cross-entropy loss for the multi-armed bandits, squared loss for the dynamic pricing, and absolute loss for the linear bandits and newsvendor problem.

To reduce computation costs from sampling histories during the early training phase, instead of sampling a new dataset $D_{m}$ in each iteration (as described in Algorithm 1), we initially sample $10^{6}$ data samples before the pre-training phase as an approximation of $\mathcal{P}_{\gamma,f}$. Each sample in the batch is uniformly sampled from these $10^{6}$ data samples.

To reduce transformer inference costs during the mixed training phase, we reset the number of training sequences to $n=15\times 64$ per iteration and set the ratio $\kappa=1/3$, meaning $10\times 64$ samples are from $\mathcal{P}_{\gamma,\texttt{TF}_{\theta_{m}}}$ and $5\times 64$ samples are from $\mathcal{P}_{\gamma,f}$ (sampled from the pool of pre-generated $10^{6}$ samples as before). Consequently, we adjust the number of batches from 1500 to 50 to fit the smaller size of training samples, keeping the batch size at 64.

Decision Function $f$ in Pre-Training. To mitigate the OOD issue mentioned in Section 3, we aim for the decision function $f$ to approximate $\texttt{Alg}^{*}$ or $\texttt{TF}_{\hat{\theta}}$. However, due to the high computation cost of $\texttt{Alg}^{*}$ and the unavailability of $\texttt{TF}_{\hat{\theta}}$, we set $f(H_{t})=a^{*}_{t}+\epsilon^{\prime}_{t}$, where $\epsilon^{\prime}_{t}$ is random noise simulating the suboptimality of $\texttt{Alg}^{*}$ or $\texttt{TF}_{\hat{\theta}}$ and independent of $H_{t}$. As we expect such suboptimality to decrease across $t$, we also reduce the influence of $\epsilon^{\prime}_{t}$ across $t$. Thus, in our experiments, $\epsilon^{\prime}_{t}$ is defined as:

$$ $\epsilon^{\prime}_{t}\sim\begin{cases}0&\text{w.p.}\ \max\{0,1-\frac{2}{\sqrt{ t}}\},\\ \text{Unif}[-1,1]&\text{w.p.}\ \min\{1,\frac{2}{\sqrt{t}}\},\end{cases}$ $$

where for the multi-armed bandits we replace $\text{Unif}[-1,1]$ by $\text{Unif}\{-2,-1,1,2\}$ and for the linear bandits with dimension $d>1$ we apply the uniform distribution of the set $[-1,-1]^{d}$. We further project $f(H_{t})$ into $\mathcal{A}$ when $f(H_{t})\notin\mathcal{A}$.

Curriculum. Inspired by Garg et al. [] in the regression task, we apply curriculum training to potentially speed up Algorithm 1. This technique uses “simple” task data initially and gradually increases task complexity during the training. Specifically, we train the transformer on samples with a smaller horizon $\tilde{T}=20$ (generated by truncating samples from $\mathcal{P}_{\gamma,f}$ or $\mathcal{P}_{\gamma,\texttt{TF}_{\theta_{m}}}$) at the beginning and gradually increase the sample horizon to the target $T=100$. We apply this curriculum in both the early training phase ($m\leq 50$) and the mixed training phase ($m>50$). The last 30 iterations focus on training with $\tilde{T}=100$ using non-truncated samples from $\mathcal{P}_{\gamma,\texttt{TF}_{\theta}}$ to let the transformer fit more on the non-truncated samples. The exact setting of $\tilde{T}$ is as follows:

$$ $\tilde{T}=\begin{cases}20\times(m\%10+1)&\text{when}\ m=1,\ldots,50,\\ 20\times(m\%10-4)&\text{when}\ m=51,\ldots,100,\\ 100&\text{when}\ m=100,\ldots,130.\end{cases}$ $$

### E.2 Environment Generation

Throughout the paper, we set the horizon $T=100$ for all tasks. The environment distribution $\mathcal{P}_{\gamma}$ is defined as follows for each task:

- •
Stochastic multi-armed bandit: We consider the number of actions/arms $k=20$. The environment parameter $\gamma$ encapsulates the expected reward $r_{a}$ of each arm $a=1,\ldots,20$, where the reward of arm $a$ is sampled from $\mathcal{N}(r_{a},0.2)$. Thus, the environment distribution $\mathcal{P}_{\gamma}$ is defined by the (joint) distribution of $(r_{1},\ldots,r_{20})$. We set $r_{a}\overset{\text{i.i.d.}}{\sim}\mathcal{N}(0,1)$ for each action $a$. The optimal arm is $a^{*}=\operatorname*{arg\,max}_{a}r_{a}$.
- •
Linear bandits: We consider the dimension of actions/arms $d=2$ and $\mathcal{A}=\mathcal{B}(0,1)$, i.e., a unit ball centered at the origin (with respect to the Euclidean norm). The environment parameter $\gamma$ encapsulates the (linear) reward function’s parameter $w\in\{\tilde{w}\in\mathbb{R}^{2}:\|\tilde{w}\|_{2}=1\}$, where the reward of arm $a$ is sampled from $\mathcal{N}(w^{\top}a,0.2)$. Thus, the environment distribution $\mathcal{P}_{\gamma}$ is defined by the distribution of $w$. We set $w$ to be uniformly sampled from the unit sphere, and the corresponding optimal arm being $a^{*}=w$.
- •
Dynamic pricing: We set the noise $\epsilon_{t}\overset{\text{i.i.d.}}{\sim}\mathcal{N}(0,0.2)$ and the context $X_{t}$ to be sampled i.i.d. and uniformly from $[0,5/2]^{d}$, with $d=6$ as the dimension of contexts, and $\mathcal{A}=[0,30]$. We consider the linear demand function family $d(X_{t},a_{t})=w_{1}^{\top}X_{t}-w_{2}^{\top}X_{t}\cdot a_{t}+\epsilon_{t}$, where $w_{1},w_{2}\in\mathbb{R}^{d}$ are the demand parameters. Thus, the environment distribution $\mathcal{P}_{\gamma}$ is defined by the (joint) distribution of $(w_{1},w_{2})$. We set $w_{1}$ to be uniformly sampled from $[1/2,3/2]^{6}$ and $w_{2}$ to be uniformly sampled from $[1/20,21/20]^{6}$, independent of $w_{1}$. The optimal action $a^{*}_{t}=\frac{w_{1}^{\top}X_{t}}{2\cdot w_{2}^{\top}X_{t}}$. We also consider a square demand function family, which will be specified later, to test the transformer’s performance on a mixture of different demand tasks.
- •
Newsvendor problem: We set the context $X_{t}$ to be sampled i.i.d. and uniformly from $[0,3]^{d}$ with $d=4$, and $\mathcal{A}=[0,30]$. We consider the linear demand function family $d(X_{t},a_{t})=w^{\top}X_{t}+\epsilon_{t}$, where $w\in\mathbb{R}^{2}$. The environment parameter $\gamma$ encapsulates (i) the upper bound $\bar{\epsilon}$ of the noise $\epsilon_{t}$, where $\epsilon_{t}\overset{\text{i.i.d.}}{\sim}\text{Unif}(0,\bar{\epsilon})$; (ii) the left-over cost $h$ (with the lost-sale cost $l\text{ being }1$); and (iii) the demand parameter $w$. Accordingly, we set (i) $\bar{\epsilon}\sim\text{Unif}[1,10]$; (ii) $h\sim\text{Unif}[1/2,2]$; and (iii) $w$ uniformly sampled from $[0,3]^{2}$. The optimal action can be computed by $a^{*}_{t}=w^{\top}X_{t}+\frac{\bar{\epsilon}}{1+h}$ [Ding et al., ], which is indeed the $\frac{1}{1+h}$ quantile of the the random variable $w^{\top}X_{t}+\epsilon_{t}$. We also consider a square demand function family, which will be specified later, to test the transformer’s performance on a mixture of different demand tasks.

Finite Pool of Environments. To study the behavior and test the performance of the transformer on finite possible environments (e.g., to see if and how $\texttt{TF}_{\hat{\theta}}$ converges to $\texttt{Alg}^{*}$), we also consider a finite pool of environments as the candidates of $\gamma$. Specifically, for some tasks we first sample finite environments (e.g., $\gamma_{1},\ldots,\gamma_{4}$) i.i.d. following the sampling rules previously described. We then set the environment distribution $\mathcal{P}_{\gamma}$ as a uniform distribution over the pool of sampled environments (e.g., $\{\gamma_{1},\ldots,\gamma_{4}\}$). We should notice this pool of environments does not restrict the context generation (if any): in both the pre-training and testing, contexts are generated following the rules previously described and are independent of the given finite pool.

Tasks with Two Demand Types. To test the transformer’s performance on tasks with a mixture of different demand types, we also consider the square demand function family for the dynamic pricing and newsvendor tasks. Specifically, besides the linear demand function family, we also consider $d^{\text{sq}}(X_{t},a_{t})=(w_{1}^{\top}X_{t})^{2}-(w_{2}^{\top}X_{t})\cdot a_
{t}+\epsilon_{t}$ in dynamic pricing and $d^{\text{sq}}(X_{t},a_{t})=(w^{\top}X_{t})^{2}+\epsilon_{t}$ in the newsvendor problem. Thus, with a slight abuse of notation, we can augment $\gamma$ such that it parameterizes the type of demand (linear or square). In experiments related to multi-type demands, the probability of each type being sampled is $1/2$, while the distributions over other parameters of the environment remain the same as in the linear demand case.

### E.3 Benchmark Algorithms

#### E.3.1 Multi-armed bandits

- •
Upper Confidence Bound (UCB) [Lattimore and Szepesvári, ]: Given $H_{t}$, the action $a_{t}$ is chosen by $a_{t}=\operatorname*{arg\,max}_{a\in\mathcal{A}}\hat{r}_{a}+\frac{\sqrt{2\log T
}}{\min\{1,n_{a}\}}$, where $n_{a}$ is the number of pulling times of arm $a$ before time $t$ and $\hat{r}_{a}$ is the empirical mean reward of $a$ based on $H_{t}$.
- •
Thomspon sampling (TS) [Russo et al., ]: Given $H_{t}$, the action $a_{t}$ is chosen by $a_{t}=\operatorname*{arg\,max}_{a\in\mathcal{A}}\tilde{r}_{a}$, where each $\tilde{r}_{a}\sim\mathcal{N}\left(\hat{r}_{a},\frac{\sqrt{2\log T}}{\min\{1,n_
{a}\}}\right)$ is the sampled reward of arm $a$ and $\hat{r}_{a},n_{a}$ follow the same definitions as in UCB.
- •
$\texttt{Alg}^{*}$: Given $H_{t}$ from a task with a pool of $|\Gamma|$ environments $\{\gamma_{1},\ldots,\gamma_{|\Gamma|}\}$, the action $a_{t}$ is chosen by the posterior sampling defined in Algorithm 2. The posterior distribution can be computed by
$\mathcal{P}(\gamma_{i}|H_{t})=\frac{\exp(-\frac{1}{\sigma^{2}}\sum_{\tau=1}^{t
-1}(o_{\tau}-r^{i}_{a_{\tau}})^{2})}{\sum_{i^{\prime}=1}^{|\Gamma|}\exp(-\frac
{1}{\sigma^{2}}\sum_{\tau=1}^{t-1}(o_{\tau}-r^{i^{\prime}}_{a_{\tau}})^{2})},$
where $r^{i}_{a}$ is the expected reward of $a$ in environment $\gamma_{i}$ and $\sigma^{2}$ is the variance of the noise (which equals to $0.2$ in our experiments).

#### E.3.2 Linear bandits

- •
LinUCB [Chu et al., ]: Given $H_{t}$, we define $\Sigma_{t}=\sum_{\tau=1}^{t-1}a_{\tau}a_{\tau}^{\top}+\sigma^{2}I_{d}$, where $\sigma^{2}$ is the variance of the reward noise. The action $a_{t}$ is chosen by $a_{t}\in\operatorname*{arg\,max}_{a\in\mathcal{A}}\hat{w}_{t}^{\top}a+\sqrt{2
\log T}\|a\|_{\Sigma_{t}^{-1}}$, where $\hat{w}_{t}=\Sigma_{t}^{-1}(\sum_{\tau=1}^{t-1}o_{\tau}\cdot a_{\tau})$ is the current estimation of $w$ from $H_{t}$.
- •
LinTS [Agrawal and Goyal, ]: Given $H_{t}$, the action $a_{t}$ is chosen by $a_{t}=\operatorname*{arg\,max}_{a\in\mathcal{A}}\tilde{w}_{t}^{\top}a$, where $\tilde{w}_{t}\sim\mathcal{N}\left(\hat{w}_{t},\sqrt{2\log T}\Sigma_{t}^{-1}\right)$ as the sampled version of $w$ and $\hat{w}_{t},\Sigma_{t}$ follow the same definitions in LinUCB.
- •
$\texttt{Alg}^{*}$: Given $H_{t}$ from a task with a pool of $|\Gamma|$ environments $\{\gamma_{1},\ldots,\gamma_{|\Gamma|}\}$, the action $a_{t}$ is chosen by the posterior median defined in Algorithm 2. The posterior distribution can be computed by
$\mathcal{P}(\gamma_{i}|H_{t})=\frac{\exp(-\frac{1}{\sigma^{2}}\sum_{\tau=1}^{t
-1}(o_{\tau}-w_{i}^{\top}a_{\tau})^{2})}{\sum_{i^{\prime}=1}^{|\Gamma|}\exp(-
\frac{1}{\sigma^{2}}\sum_{\tau=1}^{t-1}(o_{\tau}-w^{\top}_{i^{\prime}}a_{\tau}
)^{2})},$
where $w_{i}$ is the reward function parameter in environment $\gamma_{i}$ and $\sigma^{2}$ is the variance of the noise (which equals to $0.2$ in our experiments).

#### E.3.3 Dynamic pricing

All the benchmark algorithms presented below assume the demand model belongs to the linear demand function family as defined in Appendix E.2 (which can be mis-specified when we deal with dynamic pricing problems with two demand types).

- •
Iterative least square estimation (ILSE) [Qiang and Bayati, ]: At each $t$, it first estimates the unknown demand parameters $(w_{1},w_{2})$ by applying a ridge regression based on $H_{t}$, and chooses $a_{t}$ as the optimal action according to the estimated parameters and the context $X_{t}$. Specifically, we denote $(\hat{w}_{1,t},-\hat{w}_{2,t})=\Sigma_{t}^{-1}(\sum_{\tau=1}^{t-1}o_{\tau}
\cdot z_{\tau})$ as the estimation of $(w_{1},-w_{2})$ through a ridge regression, where $z_{\tau}=(X_{\tau},a_{\tau}\cdot X_{\tau})$ serves as the “feature vector” and $\Sigma_{t}=\sum_{\tau=1}^{t-1}z_{\tau}z_{\tau}^{\top}+\sigma^{2}I_{d}$ ($\sigma^{2}$ is the variance of the demand noise). Then the action is chosen as the optimal one by treating $(\hat{w}_{1,t},\hat{w}_{2,t})$ as the true parameter: $a_{t}=\frac{\hat{w}_{1,t}^{\top}X_{t}}{2\hat{w}_{2,t}^{\top}X_{t}}$.
- •
Constrained iterated least squares (CILS) [Keskin and Zeevi, ]: It is similar to the ILSE algorithm except for the potential explorations when pricing. Specifically, we follow the notations in ILSE and denote $\hat{a}_{t}=\frac{\hat{w}_{1,t}^{\top}X_{t}}{2\hat{w}_{2,t}^{\top}X_{t}}$ as the optimal action by treating $(\hat{w}_{1,t},\hat{w}_{2,t})$ as the true parameter (the chosen action of ILSE), and denote $\bar{a}_{t-1}$ as the empirical average of the chosen actions so far. Then the CILS chooses
$a_{t}=\begin{cases}\bar{a}_{t-1}+\text{sgn}(\delta_{t})\frac{t^{-\frac{1}{4}}}
{10},&\text{if }|\delta_{t}|<\frac{1}{10}t^{-\frac{1}{4}},\\
\hat{a}_{t},&\text{otherwise },\end{cases}$
where $\delta_{t}=\hat{a}_{t}-\bar{a}_{t-1}$. The intuition is that if the tentative price $\hat{a}_{t}$ stays too close to the history average, it will introduce a small perturbation around the average as price experimentation to encourage parameter learning.
- •
Thomspon sampling for pricing (TS) [Wang et al., ]: Like the ILSE algorithm, it also runs a regression to estimate $(w_{1},w_{2})$ based on the history data, while the chosen action is the optimal action of a sampled version of parameters. Specifically, we follow the notations in ILSE and then TS chooses
$a_{t}=\frac{\tilde{\alpha}}{2\cdot\tilde{\beta}},$
where $(\tilde{\alpha},\tilde{\beta})\sim\mathcal{N}((\hat{w}^{\top}_{1,t}X_{t},\hat{
w}_{2,t}^{\top}X_{t}),\tilde{\Sigma}_{t}^{-1})\in\mathbb{R}^{2}$ are the sampled parameters of the “intercept” and “price coefficient” in the linear demand function and
$\tilde{\Sigma}_{t}=\left(\begin{pmatrix}X_{t}&\bm{0}\\
\bm{0}&X_{t}\end{pmatrix}^{\top}\Sigma_{t}^{-1}\begin{pmatrix}X_{t}&\bm{0}\\
\bm{0}&X_{t}\end{pmatrix}\right)^{-1}$
is the empirical covariance matrix given $X_{t}$.
- •
$\texttt{Alg}^{*}$: Given $H_{t}$ from a task with a pool of $|\Gamma|$ environments $\{\gamma_{1},\ldots,\gamma_{|\Gamma|}\}$, the action $a_{t}$ is chosen by the posterior averaging defined in Algorithm 2. To compute the posterior distribution, we follow the notations in ILSE and denote $w=(w_{1},w_{2})$ as the stacked vector of parameters, then the posterior distribution is
$\mathcal{P}(\gamma_{i}|H_{t})=\frac{\exp(-\frac{1}{\sigma^{2}}\sum_{\tau=1}^{t
-1}(o_{\tau}-w_{i}^{\top}z_{\tau})^{2})}{\sum_{i^{\prime}=1}^{|\Gamma|}\exp(-
\frac{1}{\sigma^{2}}\sum_{\tau=1}^{t-1}(o_{\tau}-w^{\top}_{i^{\prime}}z_{\tau}
)^{2})},$
where $w_{i}$ is the demand function parameter in environment $\gamma_{i}$ and $\sigma^{2}$ is the variance of the noise (which equals to $0.2$ in our experiments).

#### E.3.4 Newsvendor

All the benchmark algorithms presented below assume the demand model belongs to the linear demand function family as defined in Appendix E.2 (which can be mis-specified when we deal with newsvendor problems with two demand types).

- •
Empirical risk minimization (ERM) [Ban and Rudin, ]: Since the optimal action $a^{*}_{t}$ is the $\frac{1}{1+h}$ quantile of the random variable $w^{\top}X_{t}+\epsilon_{t}$ [Ding et al., ], ERM conducts a linear quantile regression based on the observed contexts and demands $\{(X_{\tau},o_{\tau})\}_{\tau=1}^{t-1}$ to predict the $\frac{1}{1+h}$ quantile on $X_{t}$.
- •
Feature-based adaptive inventory algorithm (FAI) [Ding et al., ]: FAI is an online gradient descent style algorithm aiming to minimize the cost $\sum_{t=1}^{T}h\cdot(a_{t}-o_{t})^{+}+l\cdot(o_{t}-a_{t})^{+}$ (we set $l=1$ in our experiments). Specifically, it chooses
$a_{t}=\tilde{w}_{t}^{\top}X_{t}$, where
$\tilde{w}_{t}=\begin{cases}\tilde{w}_{t-1}-\frac{h}{\sqrt{t}}\cdot x_{t-1},&
\text{if }o_{t-1}<a_{t-1},\\
\tilde{w}_{t-1}+\frac{l}{\sqrt{t}}\cdot x_{t-1},&\text{otherwise},\end{cases}$
is the online gradient descent step and $\tilde{w}_{0}$ can be randomly sampled in $[0,1]^{d}$.
- •
$\texttt{Alg}^{*}$: Given $H_{t}$ from a task with a pool of $|\Gamma|$ environments $\{\gamma_{1},\ldots,\gamma_{|\Gamma|}\}$, the action $a_{t}$ is chosen by the posterior median as shown in Algorithm 2. To compute the posterior distribution, we denote $\bar{\epsilon}_{\gamma}$ and $\beta_{\gamma}$ as the noise upper bound and demand function parameter of $\gamma$ at $\tau\leq t-1$, and define the event $\mathcal{E}_{\gamma,\tau}=\left\{0\leq o_{\tau}-\beta_{\gamma}^{\top}X_{\tau}
\leq\bar{\epsilon}\right\}$ to indicate the feasibility of environment $\gamma$ from $(X_{\tau},o_{\tau})$, and denote $\bar{\mathcal{E}}_{\gamma,t}=\bigcap_{\tau=1}^{\tau-1}\mathcal{E}_{\gamma,\tau}$ to indicate the feasibility at $t$. Then the posterior distribution of the underlying environment is
$\mathcal{P}(\gamma_{i}|H_{t})=\frac{\mathbbm{1}_{\bar{\mathcal{E}}_{\gamma_{i}
,t}}\cdot\bar{\epsilon}_{\gamma_{i}}^{1-t}}{\sum_{i^{\prime}=1}^{|\Gamma|}
\mathbbm{1}_{\bar{\mathcal{E}}_{\gamma_{i^{\prime}},t}}\cdot\bar{\epsilon}_{
\gamma_{i^{\prime}}}^{1-t}}.$

### E.4 Details for Figures

#### E.4.1 Details for Figure 2

##### Figure 2 (a).

In Figure 2 (a), we independently implement Algorithm 1 to train two transformer models on a dynamic pricing task, which has an infinite support of the prior environment distribution $\mathcal{P}_{\gamma}$ and $6$-dimensional contexts (more details can be found in Appendix E.2). For both models, the training parameters are identical except for the $M_{0}$ in Algorithm 1: the first curve (blue, thick line) uses $M_{0}=50$, while the second curve (orange, dashed line) uses $M_{0}=130$, meaning no transformer-generated data is utilized during training. All other parameters follow the configuration detailed in Appendix E.1. The figure shows the mean testing regret at each training iteration across 128 randomly sampled environments, with the shaded area representing the standard deviation. We further provide more results in Appendix C.1.2.

##### Figure 2 (b).

In Figure 2 (b), we consider a dynamic pricing task with a pool of $8$ linear demand functions and has $6$-dimensional contexts. We generate $30$ sequences from $\texttt{TF}_{\theta_{m}}$ across different training iterations for this task: before using the transformer-generated data in the training ($m=40,50$) and after using such data ($m=70,80,110,120$). All generated sequences share the same context sequence $\{X_{t}\}_{t=1}^{T}$ to control the effect of contexts on the chosen actions and the resulting observations. We stack the first $20$ actions and observations into a single sample point and use t-SNE method to visualize these high-dimension points as shown in Figure 2 (b). We further apply the same method to generate points from $\texttt{Alg}^{*}$ to study the behavior of TF.

We can observe that: (i) compared to the points from TF which have not been trained on self-generated data (i.e., $\texttt{TF}_{\theta_{40}},\texttt{TF}_{\theta_{50}}$), the points from the trained ones are closer to the $\texttt{Alg}^{*}$’s, i.e., the expected decision rule of a well-trained TF; (ii) When being trained with more self-generated data, the points from $\texttt{TF}_{\theta_{m}}$ get closer to the $\texttt{Alg}^{*}$’s. These observations suggest that utilizing the self-generated data (like in Algorithm 1) can help mitigate the OOD issue as discussed in Section 3: the data from $\texttt{TF}_{\theta_{m}}$ can get closer to the target samples from $\texttt{Alg}^{*}$ during the training and thus the pre-training data is closer to the testing data.

#### E.4.2 Details for Figure 3 .

For Figure 3, subfigure (a) is based on a dynamic pricing task with $6$-dimensional contexts and (b) is based on a newsvendor task with $4$-dimensional contexts. Both tasks have a pool of $4$ environments, i.e., the support of $\mathcal{P}_{\gamma}$ only contains $4$ environments, with linear demand function type. Each subfigure is based on a sampled environment with a sampled sequence of contexts $\{X_{t}\}_{t=1}^{30}$ from the corresponding task. For each task, the data generation process follows the description detailed in Appendix E.2, and the architecture of $\texttt{TF}_{\hat{\theta}}$ and the definition of $\texttt{Alg}^{*}$ can be found in Appendix E.1 and Appendix E.3 respectively. We further provide more results and discussions in Appendix C.2.

## Peer Reviews

confidence: 3
contribution: 3
initial_rating: 6
presentation: 3
questions: 1. How do the authors choose the environments for pre-training, and do variations in the gamma values during training impact the model’s ability to generalize? It would be interesting to know if a big difference between training and testing gamma values affects performance or creates bias.

2. Have the authors thought about using curriculum learning, where self-generated actions gradually increase over time, instead of the two-phase switch? I think it would enjoy less theoretical property, but possibly perform better in numerical experiments.
soundness: 4
strengths: 1. This paper applies transformers in the domain of sequential decision-making, typically dominated by traditional RL approaches. The authors ground their framework with rigorous theoretical proofs, establishing conditions under which the mixed pre-training algorithm minimizes cumulative regret. They also prove that the learned decision function asymptotically matches the Bayes-optimal policy as the data approaches infinity.

2. I like how the authors propose the two-phase training strategy to effectively mitigate out-of-distribution problems by including the model's self-generated actions in the second training phase. This solution is simple yet effective and also maintains theoretical rigor.
summary: This paper presents a supervised training framework for transformers applied to sequential decision-making problems—a subset of reinforcement learning (RL) tasks that lack an explicit transition matrix. In this framework, transformers are pre-trained on the target task class by simulating multiple environments to generate trajectories consisting of states, actions, and rewards. However, a discrepancy exists between action selection during pre-training and at test time, which leads to a gap between the empirical loss observed in training and the expected loss during testing. This gap can cause out-of-distribution issues, as studied by previous literature, causing the regret bound of the model’s performance to increase exponentially over time. To address this, the authors propose a mixed pre-training algorithm, in which the models learn not only from simulated data but also from trajectories generated by their own actions. This hybrid approach reduces the discrepancy between training and testing distributions. The proposed algorithm is theoretically validated and supported by experimental results.
weaknesses: 1. I think the setup in Section 2 goes on a bit too long and could be more concise. A detail: the way f is used in Equation (4) isn’t fully explained until after Equation (5), which makes it hard to follow. Plus, describing f as "a prespecified decision function used to generate the data" is too vague.

2. The framework leans heavily on simulated environments ($gamma_i$ and $f$) for pre-training, which might limit scalability to real-world cases. Generating high-quality simulations can be both costly and challenging.

---

confidence: 2
contribution: 2
initial_rating: 5
presentation: 3
questions: - What is the difference between the setting described in the paper (reinforcement learning/sequential decision-making without transition probabilities) and the stochastic bandit or contextual bandit settings? If it aligns with an existing setting, that should be clarified. The use of reinforcement learning terminology here seems to add more confusion than clarity.

- What are the disadvantages of using pre-trained transformers compared to structured algorithms like UCB and Thompson Sampling? One notable concern could be the computational and memory cost; can this be quantified? For instance, how would the algorithms compare if the x-axis were aligned with computational metrics? What is the computational or memory overhead compared to simpler methods? Given that the proposed method is intended to be practical but lacks theoretical rigour, it is important to assess whether using these algorithms makes sense in practice.

- If UCB/TS had access to the same amount of pretraining data, how would their performance compare to the proposed method?
soundness: 3
strengths: - The paper introduces notation and a framework for studying pre-trained transformers in decision-making tasks.
- It proposes a new algorithm and demonstrates its practical performance.
- The connection to performative prediction is intriguing.
summary: This paper investigates the training and generalization of pre-trained transformers for sequential decision-making tasks without transition probabilities. The authors propose an algorithm that incorporates transformer-generated action sequences during pretraining, establishes a connection to performative prediction, and addresses the challenge of limited exploration. They highlight three advantages of pre-trained transformers over structured algorithms like UCB and TS: improved utilization of pretraining data, robustness to model misspecification, and enhanced short-term performance.
weaknesses: - My biggest concern is the lack of discussion regarding the disadvantages of using transformers for tasks like bandits. The paper does not sufficiently address the computational and memory overhead involved.

- The comparison between the proposed method and UCB/TS seems unfair, as the transformer benefits from extensive prior data while UCB/TS is evaluated in a cold-start setting. Claiming that UCB/TS is less effective at utilizing prior knowledge is misleading since these algorithms aren’t provided with any pre-training data. In fact, UCB/TS algorithms do incorporate observed data as part of their operation, in the form of empirical mean rewards and reward uncertainty. 

- The claimed short-term advantage of the proposed method also seems unconvincing. While it’s true that UCB/TS in their original forms is designed for asymptotic optimality rather than short-term performance, there are likely modifications or more state-of-the-art structured algorithms that can improve short-term performance. For instance, restricting the variance (exploration) in these algorithms could make them more greedy. I’m not convinced that this is an inherent limitation of structured algorithms.

- I am not very familiar with related work on applying deep learning or transformer methods to bandits, so a more comprehensive related work section would be helpful. For example, some studies use generated data as priors for algorithms like TS.

- The clarity and organization of the paper could be improved. For instance, while the paper emphasizes reinforcement learning and sequential decision-making settings, I believe the studied problem is more aligned with the contextual bandit setting. I believe some of the notations on pages 3-5 could be streamlined, and a discussion in the main text about how these settings differ and why the setting studied in the paper is more general would be beneficial.

---

confidence: 2
contribution: 2
initial_rating: 5
presentation: 3
questions: 1.	Do the benchmarks used need pre-training? If not, then what would the authors argue is the benefit of the pre-trained method given the increased computation that is required for the pre-training?
2.     In line 167, it is stated that "...reinforcement learning algorithms and are usually hard to combine with prior knowledge such as pre-training data." However, I believe there are many options to combine prior knowledge in previously collected data: initializing replay buffer, offline learning, transfer learning, ....
soundness: 3
strengths: This paper offers an analytical analysis of using pre-trained transformers on bandit-style problems and demonstrates the benefits exceeding the typical asymtotic optimal regret. Along the way, the paper provides interesting insights, and the resulting algorithm is well-motivated and explained clearly.
summary: The authors explore the implications of using pre-trained transformers on bandit-style decision-making problems. They perform a scientific analysis that yields interesting insights, and provide empirical case studies that show that the use of pre-trained transformers yields competitive results with existing methods.
weaknesses: The main weakness can be the narrow scope of impact as the sequential decision making problem in the paper is very narrowly defined. 

The text does very little to motivate the need for the Learned Decision Function (LDF) described in Section 4. In particular, the relationship between the LDF and the pre-trained methods described in this paper is unclear on a first read. The authors need to better explain why the LDF is necessary. It seems unlikely that there is not an acceptable baseline that can be used from the literature. The confusion is further amplified in the experiments section, where the authors use different baselines to evaluate the pre-trained methods.

Additionally, while the insights generated are interesting, the paper lacks a clear and compelling rationale for why the pre-training is worth the extra computation compared to simpler methods. In particular, the use of a complex transformer architecture on a bandit-style problem would, on the surface, appear to be ‘overkill’, and the paper is not able to clearly articulate a compelling reason that justifies the use of such a complex solution method.

Ovearll, math notation is confusing and seems even incorrect/inconsistent. 

Some minor comments:
•	Figures 1 and 2 are not referenced anywhere in the main text.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 1
questions: See Weakness.
soundness: 2
strengths: By showing that transformers can outperform traditional algorithms in some sequential decision-making contexts, this work contributes to advancing the understanding of transformers.
summary: This paper looks at how supervised pre-trained transformers can be used in sequential decision-making tasks, which is a subfield of reinforcement learning that doesn't involve transition probability matrices. The authors believe that transformers can perform well in tasks like bandits, dynamic pricing, and newsvendor problems if you leverage closed-form or easily computable optimal actions during the pre-training phase. They look at an issue that arises when there are differences between the training and test phases, and suggest an algorithm that lets transformer-generated actions be part of the training, which helps with generalisation. The authors also give some theoretical insights by looking at the transformer model as a near-Bayesian optimal predictor and suggest some numerical experiments comparing its performance against structured algorithms like UCB and Thompson sampling, which show where transformers work well.
weaknesses: **Confusing claims and demonstration:**

- The notations abuse. For example, decision function $f$ generate $a$ or $a^*$. In Eq. 5, the authors claim to generate $a^*$  but there is no $a^*$ in Eq. 5. I can only infer that $f$ generate $a^*$. And then below Eq. 7 it becomes $a_{\tau}$.

- In the paragraph, below Eq. 9, the authors claim that OOD in this setting is because "when generating the training data, there is no way we can know the final parameter. This is not an OOD problem to me. Training on some tasks and testing on other tasks, or changing test-time environmental parameters are more likely to be OOD problem.

- Above Eq. 9, pertraining -> pretraining, and this paragraph is unclearly written. Overly referring to the equation make me hard to follow the idea and intuition.

   

**Lack of Novelty** 

- The theory is comprehensively covered, while simply adding a mixed training phase and testing only on simple experimental setup doesn't seem novel enough to me, given the existing works [1-3]. 

- In addition, given that Transformer is a powerful sequence model, isn't studying pretraining on state-free bandit problems less meaningful? The authors claim that bandit is a special case, but it's to me more like out-of-scope because sequential problems are more related.

  

Since the motivations and clarity are less satisfying, I didn't look into the proof in details. While it's good to see that mixing online and offline data can preserve a theoretical guarantee.



[1] Lee, Jonathan, et al. "Supervised pretraining can learn in-context reinforcement learning." *Advances in Neural Information Processing Systems* 36 (2024).

[2] Laskin, Michael, et al. "In-context reinforcement learning with algorithm distillation." *arXiv preprint arXiv:2210.14215* (2022).

[3] Sodhani, Shagun, Amy Zhang, and Joelle Pineau. "Multi-task reinforcement learning with context-based representations." *International Conference on Machine Learning*. PMLR, 2021.

Meta-review: This paper presents a supervised training framework for transformers applied to sequential decision-making problems—a subset of reinforcement learning (RL) tasks that lack an explicit transition matrix. In this framework, transformers are pre-trained on the target task class by simulating multiple environments to generate trajectories consisting of states, actions, and rewards. However, a discrepancy exists between action selection during pre-training and at test time, which leads to a gap between the empirical loss observed in training and the expected loss during testing. This gap can cause out-of-distribution issues, as studied by previous literature, causing the regret bound of the model’s performance to increase exponentially over time. To address this, the authors propose a mixed pre-training algorithm, in which the models learn not only from simulated data but also from trajectories generated by their own actions. This hybrid approach reduces the discrepancy between training and testing distributions. The proposed algorithm is theoretically validated and supported by experimental results.

The main concern is on the claimed advantage over standard baselines such as UCB or Thompson sampling: (1) UCB and Thompson sampling can also leverage prior information, and (2) no formal theoretical separation between the proposed approach and UCB/TS. Therefore, the AC recommends rejection.

Decision: Reject