Paper commentary
Decision Transformer: Reinforcement Learning via Sequence Modeling
- Problem Offline RL from fixed, suboptimal trajectories is hard for TD-based methods, which bootstrap value estimates, propagate credit step by step and can overestimate values.
- Method The method treats trajectories as token sequences of returns-to-go, states and actions, and trains a GPT-style causal Transformer to predict actions, so generation is conditioned on a desired return.
- Results Reached an average normalized score of 74.7 on the D4RL datasets excluding Reacher, against 63.9 for CQL.
Why offline RL is hard for TD methods
The setting is offline RL, where a policy must be learned from a fixed set of trajectories produced by arbitrary behavior policies, with no further interaction with the environment. Standard value-based methods rely on temporal difference learning, which bootstraps value estimates from successor estimates. The authors name a combination of bootstrapping and off-policy learning the deadly triad, which is known to destabilize RL.
Discounting future rewards, the usual companion of TD learning, can also push learned behavior toward short-sighted choices. Learning from fixed data adds error propagation and value overestimation on top of these problems.
The proposed alternative is to train a transformer on collected trajectories with a sequence modeling objective, which avoids bootstrapping and discounting entirely. The authors also argue that self-attention can assign credit directly across a sequence, while Bellman backups carry reward information slowly and can be misled by distractor signals.
This is the hypothesis the experiments are meant to test.
Returns-to-go as the conditioning signal
A trajectory is a sequence of states, actions and rewards, and the return at timestep t is the sum of rewards from that step to the end. Rewards are not fed in directly. The model receives returns-to-go, so that actions are generated from a desired future return rather than from past rewards. The return-to-go at timestep t is defined as follows.
\[ \hat R_t = \sum_{t'=t}^{T} r_{t'} \]
The resulting trajectory representation interleaves returns-to-go, states and actions in time order, which makes both training and generation autoregressive. \[ \tau = (\hat R_1, s_1, a_1, \hat R_2, s_2, a_2, \ldots, \hat R_T, s_T, a_T) \] Because the desired return is placed before the state and action it should explain, the model can be prompted with a target return before any action is produced.
Tokens and the GPT backbone
The model takes the last K timesteps, which gives 3K tokens, one each for return-to-go, state and action. Figure 1 shows this pipeline, with modality-specific embeddings feeding a causal GPT that predicts actions.
One learned embedding per timestep is added to all three tokens of that step. This differs from the per-token positional embedding of standard transformers, because one timestep spans three tokens. The tokens pass through a GPT model with a causal self-attention mask, so each position attends only to earlier tokens. GPT replaces the softmax sum over all n tokens with a sum over the previous tokens in the sequence, which is what enables autoregressive generation.
Training loss and run-time generation
Training samples minibatches of length K from the offline dataset. The prediction head on each state token is trained to predict the action at that timestep. Discrete actions use cross-entropy loss and continuous actions use mean-squared error, and the per-timestep losses are averaged. The pseudocode for continuous actions uses the following averaged squared error.
The authors did not find that predicting states or returns-to-go improved performance. Only the action predictions therefore supervise training. At test time, the model is given a target return and the starting state. After each action, the target return is reduced by the reward received, and generation repeats until the episode ends. Only the last K timesteps are kept as context during generation.
Shortest path from random walks
Figure 2 shows the random-walk training graph with per-node returns-to-go, and the generated path from the start node to the goal.
A prior over returns favors shorter paths, and it is multiplied with the return probabilities produced by the GPT model. The prior is written as follows. \[ P_{\text{prior}}(\hat R = k) \propto T + 1 - k \]
The transformer's paths closely match the optimal paths in number of steps to the goal, improving on random walks. The authors report that 15.8% of generated paths were not copied from training trajectories, and were instead stitched from sub-optimal segments.
Atari results at 1% of replay data
Scores are means and standard deviations over 3 seeds, normalized so that 100 corresponds to a professional gamer and 0 to a random policy. Context lengths are K = 30, and K = 50 for Pong. CQL, REM and QR-DQN numbers were taken from their original papers, while behavior cloning uses the same architecture and hyperparameters as Decision Transformer but without return-to-go conditioning.
On Breakout, Decision Transformer scores 267.5 ± 97.5, against 211.1 for CQL. On Pong it scores 106.1 ± 8.1, against 111.9 for CQL. On Qbert it scores 15.4 ± 11.4, well below CQL's 104.2. On Seaquest it scores 2.5 ± 0.4, against 1.7 for CQL. Decision Transformer is therefore close to CQL on three of the four games, as the authors state, but its Qbert score is below both CQL and behavior cloning.
The authors also tried an MLP with K = 1, as in prior work, and found it worse than the transformer. The Atari table reports only these four games and one data fraction, so the comparison covers that setting.
D4RL continuous-control results
The continuous tasks come from the D4RL benchmark on HalfCheetah, Hopper and Walker, plus a 2D reacher that the authors generated with a similar procedure. The medium dataset holds 1 million timesteps from a medium policy at about one-third of expert score. Medium-replay uses the replay buffer of that agent, and medium-expert concatenates medium and expert data.
Scores are normalized so that 100 represents an expert policy, and table results are means and variances over 3 seeds.
Averaged over all settings including Reacher, it reaches 69.2, against 54.2 for CQL. The CQL numbers come from the original paper, while the behavior cloning numbers were run by the authors and the other baselines were taken from the D4RL paper.
Row by row, the method is highest on most settings. On Medium-Expert Walker it scores 108.1 ± 0.2, against 98.7 for CQL.
Imitation on a return-selected subset
To test this, the authors define Percentile Behavior Cloning, which clones only the top X% of timesteps ordered by episode return. X = 100% is standard behavior cloning on the full dataset, and small X moves toward cloning only the best trajectory. The sweep uses X in 10%, 25%, 40% and 100%.
Choosing the subset requires rollouts from the environment, so %BC is a diagnostic rather than a practical method. The authors read the closeness of the best %BC and Decision Transformer as evidence that the method can concentrate on a subset after training on the whole distribution.
In the low-data Atari setting, %BC is weak. 10%BC scores 28.5 ± 8.2 on Breakout and 2.5 ± 0.2 on Pong, against 267.5 ± 97.5 and 106.1 ± 8.1 for Decision Transformer. The authors attribute this to Decision Transformer using all trajectories, including ones unlike the return target, to improve generalization.
Return conditioning and context length
Figure 4 varies the target return and compares sampled returns with the oracle line for each task. On every task the target and observed returns are highly correlated. On Pong, HalfCheetah and Walker the trajectories almost match the desired returns. On Seaquest, the model can be prompted with returns above the maximum episode return in the dataset, which the authors describe as some extrapolation.
Reducing the context to K = 1 cuts Breakout from 267.5 to 73.9 ± 10 and Pong from 106.1 to 2.5 ± 0.2. The context ablation table lists Qbert at 15.1 ± 11.4, while the main Atari table lists 15.4 ± 11.4 for the same method; K = 1 gives 13.6 ± 11.3 on Qbert. The authors hypothesize that a longer context lets the transformer identify which policy produced the actions.
This is a hypothesis and was not separately tested.
Long-term credit assignment in Key-to-Door
Key-to-Door is a grid environment with three phases: a room with a key, an empty room, and a room with a door. The binary reward at the door is given only if the agent picked up the key earlier, so credit must cross the middle phase. Training uses trajectories from random actions, and for this environment the whole episode serves as context rather than a fixed window.
The authors attribute the gap to hindsight return information, which the two methods using it exploit, while TD learning struggles to propagate Q-values over long horizons.
Transformer as a critic
The model is modified to output return tokens as well as action tokens on Key-to-Door, and the first return token is predicted instead of given. Figure 5 shows averaged running reward probabilities for three types of episode outcome on the left, and attention weights from all timesteps for one successful episode on the right.
The predicted reward probability keeps updating during the episode, and the attention concentrates on picking up the key and reaching the door. The authors link this to state-reward associations, which they say enable accurate value prediction. The attention plot comes from a single successful episode.
Delayed rewards on Hopper
The delayed version gives the cumulative reward of each trajectory only at the final timestep, so no dense reward is seen along the way.
The authors explain that imitation-based methods are reward agnostic, and that Decision Transformer makes minimal assumptions about reward density. The delayed test covers only Hopper datasets, so it does not show the same effect on HalfCheetah or Walker.
Why no pessimism or regularization
The authors conjecture that TD-based methods learn an approximate value function and then optimize it, which can exploit inaccuracies and cause failures in policy improvement. Decision Transformer does not optimize a learned function as its objective, so the authors expect it to need no regularization or conservatism. This remains a conjecture in the paper.
Prior offline methods mitigate distribution shift by constraining the policy action space, by value pessimism, or by pessimism in learned dynamics models. The Trajectory Transformer, which the paper describes as concurrent work, adds state and return prediction and discretization, so it includes model-based components.
Limitations
For Reacher, only the CQL baseline was run, because CQL was judged the strongest TD learning method. Reacher is goal-conditioned and has sparse rewards, so it differs from the locomotion tasks.
On Qbert, Decision Transformer is below CQL and behavior cloning. The context-length ablation covers only Atari, and only K = 1 versus the main setting.
The Key-to-Door results come from one environment with random-action training trajectories. The delayed-reward test covers only Hopper. Percentile Behavior Cloning needs environment rollouts to choose the subset, so it is not a practical baseline.
Predicting states or returns-to-go was not found to help, and the authors leave self-supervised pretraining and stochastic return distributions to future work. The claim that Decision Transformer can improve online RL is a conjecture, which the authors connect to likelihood-based approaches in the offline-to-online transition.
Paper info
- Authors
- Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Michael Laskin, Pieter Abbeel, Aravind Srinivas, Igor Mordatch
- Venue
- arXiv · Preprint
- First published
- 2021-6-2
- Added
- 2026-10-20
- Updated
- 2021-6-24
- Version
- v2
- arXiv
- 2106.01345
- Category
- cs.LG · cs.AI
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Michael Laskin, Pieter Abbeel, Aravind Srinivas, Igor Mordatch (2021). Decision Transformer: Reinforcement Learning via Sequence Modeling. arXiv:2106.01345v2. https://arxiv.org/abs/2106.01345v2
BibTeX
@misc{chen2021decision,
title = {{Decision Transformer: Reinforcement Learning via Sequence Modeling}},
author = {Lili Chen and Kevin Lu and Aravind Rajeswaran and Kimin Lee and Aditya Grover and Michael Laskin and Pieter Abbeel and Aravind Srinivas and Igor Mordatch},
year = {2021},
eprint = {2106.01345},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2106.01345v2}
}