Skip to content
DraconiticResearch
Search Sources API
276,906 studies31 sourcesUpdated 19 min ago
PreprintarXiv licencearXiv

Transformers Provably Implement In-Context Reinforcement Learning with Policy Improvement

Abstract

We investigate the ability of transformers to perform in-context reinforcement learning (ICRL), where a model must infer and execute learning algorithms from trajectory data without parameter updates. We show that a linear self-attention transformer block can provably implement policy-improvement methods, including semi-gradient SARSA and actor-critic, via explicit parameter constructions. Beyond existence, we design a teacher-mimicking training procedure, analyze its gradient-flow dynamics, and establish the first convergence guarantee in the ICRL literature: under suitable richness conditions on the training MDP distribution, gradient flow converges locally and exponentially to an optimal parameter manifold corresponding to the desired RL update. Empirically, training transformers on randomly generated tabular MDPs confirms these predictions: the learned models recover the parameter structure of our explicit constructions and, when deployed on unseen MDPs, deliver strong in-context control performance. Together, these results illuminate how transformer architectures internalize and execute classical reinforcement learning algorithms in context, bridging mechanistic understanding and training dynamics in ICRL.

Related

  1. Reinforcement Learning Agent Embedded in Roadside Units to Implement an Adaptive Variable Speed Limit System in a Cooperative Intelligent Transportation Systems Environment
    Eléonore Fauchet, Pierre-Antoine Laharotte, Nour-Eddin El Faouzi
    Journal of Intelligent and Connected VehiclesPeer-reviewedCC BY 4.0Full textStatisticsHAL
  2. Provably Efficient Federated Reinforcement Learning with Linear Function Approximation and Logarithmic Communication Cost
    Zihang Liang, Haochen Zhang, Lingzhou Xue
    arXivPreprintCC BY 4.0Full textStatisticsarXiv
  3. Provably Efficient Q-learning for Robust Reinforcement Learning
    Yuchen Jiao, Gen Li
    arXivPreprintCC BY 4.0Full textStatisticsarXiv
  4. Provably Efficient Risk-Sensitive Offline Reinforcement Learning via Optimized Certainty Equivalents
    Hanzhen Wang, Boxiang Lyu, Zhongxiang Dai +3
    arXivPreprintarXiv licenceFull textOptimisation & controlStatisticsarXiv
  5. Reinforcement Learning for Hierarchical Reasoning Rewards: Minimax-Optimal Rates with Transformers
    Naoki Nishikawa, Taiji Suzuki
    arXivPreprintarXiv licenceFull textStatisticsarXiv
BibTeX
@misc{liang2026transformers,
  title = {{Transformers Provably Implement In-Context Reinforcement Learning with Policy Improvement}},
  author = {Haodong Liang and Lifeng Lai},
  howpublished = {arXiv},
  year = {2026},
  month = nov,
  doi = {10.48550/arxiv.2605.05755},
  eprint = {2605.05755},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.05755},
}
RIS
TY  - UNPB
TI  - Transformers Provably Implement In-Context Reinforcement Learning with Policy Improvement
AU  - Haodong Liang
AU  - Lifeng Lai
PY  - 2026
DA  - 2026/11/07
PB  - arXiv
DO  - 10.48550/arxiv.2605.05755
UR  - https://arxiv.org/abs/2605.05755
AB  - We investigate the ability of transformers to perform in-context reinforcement learning (ICRL), where a model must infer and execute learning algorithms from trajectory data without parameter updates. We show that a linear self-attention transformer block can provably implement policy-improvement methods, including semi-gradient SARSA and actor-critic, via explicit parameter constructions. Beyond existence, we design a teacher-mimicking training procedure, analyze its gradient-flow dynamics, and establish the first convergence guarantee in the ICRL literature: under suitable richness conditions on the training MDP distribution, gradient flow converges locally and exponentially to an optimal parameter manifold corresponding to the desired RL update. Empirically, training transformers on randomly generated tabular MDPs confirms these predictions: the learned models recover the parameter structure of our explicit constructions and, when deployed on unseen MDPs, deliver strong in-context control performance. Together, these results illuminate how transformer architectures internalize and execute classical reinforcement learning algorithms in context, bridging mechanistic understanding and training dynamics in ICRL.
ER  -