All models

Trajectory Transformer

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

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (27 KB)

Open in a new tab

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.

At a glance

Parameters
1.2M
Operations
147
Framework
PyTorch
Recurrent
No
Published
NeurIPS 2021
Cited by
173 (as of 16 October 2026)
Authors
Michael Janner, Qiyang Li, Sergey Levine
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m3143
Graph hash
5e3205375939c9dfa4abe8e56e303023b3930f3d6d869d1640769604674a96ee
Skeleton hash
ac3cd5c5b5471201504b2cbce833d3bfc56436b4bbcc885d9eab2013ecf81ced
Architecture hash
aa25457fc841378f4fe49a3ace450f1a4728327ec0b9a8875a290dd0670f73dd
Diagram SHA-256
5295ada4b54625fa07493c1ca9c11a553a2cb941dfba9f20f758cd03859635c2
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

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.

  • trajectory transformer
  • TrajectoryTransformer
  • TT
  • offline rl
  • sequence modeling
  • beam search planning
  • d4rl
  • janner
  • gpt for control
  • mingpt

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@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}, 
}