
Trajectory Transformer
Reinforcement learning and control147 ops1.2M params
A small GPT trained on discretized state, action and reward tokens, with beam search repurposed as the planner.
Reinforcement learning and control · 147 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
About this model's family
The Trajectory Transformer treats reinforcement learning as one big sequence modeling problem: a Transformer is trained to model distributions over trajectories of states, actions and rewards, and beam search is repurposed as the planning algorithm. The pitch is that framing RL this way simplifies a range of design decisions and lets the authors dispense with many of the components common in offline RL algorithms. The paper appeared at NeurIPS 2021 as a spotlight. Two members are captured here: the transformers library's TrajectoryTransformerModel at a small configuration, and the authors' own GPT trajectory model from the code release.
A trajectory is treated as an unstructured sequence of tokens, and continuous states and actions are discretized one dimension at a time. The paper compares a uniform discretization against a quantile scheme that ensures all tokens are represented in the data. The model itself is a Transformer decoder mirroring the GPT architecture, deliberately smaller than language models, with four layers and four self-attention heads. Each token embedding has dimension 128, and dropout is applied at the end of each block with probability 0.1. For offline RL, each transition in the training trajectories is augmented with reward-to-go. Beam search then swaps transition log-probabilities for the predicted reward signal, turning a likelihood-maximizing decoder into a reward-maximizing one.
As a predictor the model holds up over long horizons: its humanoid rollouts remain visually indistinguishable from the ground-truth trajectories even after 100 predicted steps. On D4RL locomotion tasks it performs on par with or better than the best prior offline reinforcement learning algorithms. The attention maps show two patterns, a discovered Markovian strategy in which a state prediction attends overwhelmingly to the previous transition, and a striated one attending to specific dimensions in multiple prior states. The paper notes that concurrent work by Chen and colleagues proposed an RL approach centered on sequence prediction, focusing on reward conditioning rather than beam-search planning. The code release borrows its GPT implementation from Andrej Karpathy's minGPT repo. It ships pretrained models for 16 datasets spanning halfcheetah, hopper, walker2d and ant. Training ran on NVIDIA Tesla V100 GPUs for 80 epochs, taking approximately 6-12 hours per model on one GPU.
Key idea. Recasting offline reinforcement learning as sequence modeling, with a GPT-style Transformer over discretized trajectory tokens and beam search repurposed as the planning algorithm.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{janner2021offlinereinforcementlearningbig,
title={Offline Reinforcement Learning as One Big Sequence Modeling Problem},
author={Michael Janner and Qiyang Li and Sergey Levine},
year={2021},
eprint={2106.02039},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2106.02039},
}