Supervised Pretraining Can Learn In-Context Reinforcement Learning

Paper · arXiv 2306.14892 · Published June 26, 2023
Training and Fine-TuningReinforcement Learning

Large transformer models trained on diverse datasets have shown a remarkable ability to learn in-context, achieving high few-shot performance on tasks they were not explicitly trained to solve. In this paper, we study the in-context learning capabilities of transformers in decision-making problems, i.e., reinforcement learning (RL) for bandits and Markov decision processes. To do so, we introduce and study Decision-Pretrained Transformer (DPT), a supervised pretraining method where the transformer predicts an optimal action given a query state and an in-context dataset of interactions, across a diverse set of tasks. This procedure, while simple, produces a model with several surprising capabilities. We find that the pretrained transformer can be used to solve a range of RL problems in-context, exhibiting both exploration online and conservatism offline, despite not being explicitly trained to do so. The model also generalizes beyond the pretraining distribution to new tasks and automatically adapts its decision-making strategies to unknown structure. Theoretically, we show DPT can be viewed as an efficient implementation of Bayesian posterior sampling, a provably sample-efficient RL algorithm.

Introduction. For supervised learning, transformer-based models trained at scale have shown impressive abilities to perform tasks given an input context, often referred to as few-shot prompting or in-context learning [1]. In this setting, a pretrained model is presented with a small number of supervised inputoutput examples in its context, and is then asked to predict the most likely completion (i.e. output) of an unpaired input, without parameter updates. Over the last few years in-context learning has been applied to solve a range of tasks [2] and a growing number works are beginning to understand and analyze in-context learning for supervised learning [3, 4, 5, 6]. In this work, our focus is to study and understand in-context learning applied to sequential decision-making, specifically in the context of reinforcement learning (RL) settings. Decision-making (e.g. RL) is considerably more dynamic and complex than supervised learning.

Discussion / Conclusion. In this paper, we studied the problem of in-context decision-making. We introduced a new pretraining method and transformer model, DPT, which is trained via supervised learning to predict optimal actions given an in-context dataset of interactions. Through in-depth evaluations in classic decision problems in bandits and MDPs, we showed that this simple objective naturally gives rise to an in-context RL algorithm that is capable of online exploration and offline decision-making, unlike other algorithms that are explicitly trained or designed to do these. Our empirical and theoretical results provide first steps towards understanding these capabilities that arise from DPT and what factors are important for it to succeed. The inherent strength of pretraining lies in its simplicity–we can sidestep the complexities of hand-designing exploration or conservatism in RL algorithms and while simultaneously allowing the transformer to derive novel strategies that best leverage problem structure.

Lines of inquiry this paper opens 24

Research framings built by reading the notes related to this paper — the questions it feeds into.

Does encoded knowledge in language models causally influence their outputs? How should training curricula adapt difficulty as models improve? Why does task-specific specialization harm generalization and future learning? Do foundation models build genuine world models or task-specific shortcuts? How does semantic diversity affect reasoning quality and training stability? How do neural networks internally organize representations and reasoning? Does reinforcement learning discover novel reasoning strategies or refine existing ones? Can agents autonomously develop skills through experience and feedback? How does entropy convergence constrain model expressiveness across training and domains? Can prompting alone inject genuinely new knowledge into trained models? Does prompt engineering fix reasoning problems or only shift systematic biases? How should agents consolidate and manage memory across sessions? How do memory systems overcome context length constraints in language models? Do structured representations outperform end-to-end vision for GUI agents? Can behavioral steering through simulation guide LLM improvements without costly retraining? How do representation structure properties emerge and change in neural networks? How should LLM systems manage conversation history and dialogue memory? What reward signal properties actually drive reasoning improvements? What should reliable agent evaluation measure beyond task success?