FlashPapers
NeurIPS 2021 Spotlight

Decision Transformer

Reinforcement Learning via Sequence Modeling

Lili Chen*, Kevin Lu*, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Michael Laskin, Pieter Abbeel, Aravind Srinivas†, Igor Mordatch†
* Equal Contribution | † Equal Advising | UC Berkeley, Meta AI, Google Brain

TL;DR "Instead of training a policy through traditional RL algorithms like temporal difference (TD) learning, we cast reinforcement learning as a conditional sequence modeling problem. By conditioning a causally masked GPT architecture on desired returns-to-go, states, and actions, we generate optimal actions autoregressively."

Offline RL No Bootstrapping Hindsight Return Conditioning GPT Architecture

1. Why This Matters

Traditional Reinforcement Learning (RL) has long been plagued by instability. Standard model-free algorithms rely heavily on Temporal Difference (TD) learning and dynamic programming to estimate value functions. This reliance introduces the infamous "deadly triad": the unstable combination of function approximation, bootstrapping, and off-policy training.

In offline RL—where an agent must learn exclusively from a static, pre-collected dataset without environment exploration—these issues exacerbate. TD-learning algorithms often overestimate values for out-of-distribution actions, leading to catastrophic policy degradation. To prevent this, existing offline RL methods like Conservative Q-Learning (CQL) must enforce complex, pessimistic constraints on value functions or policy distributions.

The Core Problem

Why must we painstakingly estimate future values and propagate rewards backwards step-by-step through Bellman backups, when we could instead treat the entire trajectory as a single sequence and learn to complete it?

2. The Big Idea

The Decision Transformer (DT) completely shifts the paradigm. Instead of fitting value functions or computing policy gradients, DT casts reinforcement learning as a conditional sequence modeling problem.

By leveraging the highly scalable, causally masked Transformer architecture (specifically GPT), DT models the joint distribution of states, actions, and returns. At test time, instead of asking "what action maximizes the predicted Q-value?", we simply *prompt* the model with our desired target return (referred to as Return-to-Go) and autoregressively generate the actions required to achieve it.

3. How It Works

To make trajectories amenable to autoregressive sequence prediction, Decision Transformer represents a trajectory $\tau$ as a sequence of three interleaved modalities: Returns-to-Go ($\hat{R}_t$), States ($s_t$), and Actions ($a_t$).

The return-to-go is defined as the sum of future rewards from the current step:

$$\hat{R}_t = \sum_{t'=t}^T r_{t'}$$

This representation is crucial: it conditions the model on *future* desired outcomes rather than past accumulated rewards. The resulting sequence looks like:

$$\tau = \left( \hat{R}_1, s_1, a_1, \hat{R}_2, s_2, a_2, \dots, \hat{R}_T, s_T, a_T \right)$$

Interactive Demo: Graph Shortest Path

Hindsight Conditioning

This replicates the paper's illustrative graph example. The agent was trained on purely random walks (suboptimal data). Select a Target Return-to-Go (RTG) prompt below to see how conditioning guides the Decision Transformer to generate the optimal path.

How it works: The reward is 0 at the Goal, and -1 for every step taken. Prompting with RTG = -2 triggers the model to output actions corresponding to the shortest path.
Start B C D Goal
Generated Path: Start → B → Goal

Modality-Specific Embeddings & Timestep Encoding

Standard Transformers process homogeneous token sequences (like text). To feed heterogeneous RL trajectories into a standard GPT architecture, DT projects each modality to the embedding dimension using a modality-specific linear layer (or a Convolutional Encoder for pixel-based states like Atari):

$$e_{s,t} = W_s s_t, \quad e_{a,t} = W_a a_t, \quad e_{R,t} = W_R \hat{R}_t$$

Importantly, DT adds a learned episodic timestep embedding $e_t$ to each token. This is distinct from standard positional embeddings, as one environment timestep corresponds to three sequential tokens.

Causal Attention Mask Visualizer

Autoregressive

Hover or tap on any token in the sequence below to see the Causal Self-Attention mechanism in action. Notice how future tokens are strictly masked out, and how the model predicts action $a_t$ by attending to past states, returns-to-go, and actions.

t=1
R̂₁
s₁
a₁
t=2
R̂₂
s₂
a₂
t=3
R̂₃
s₃
a₃
Hover over any token to inspect how the self-attention weights propagate credit.

Hopper Return-to-Go Controller

Policy Generation

Adjust the desired Target Return-to-Go slider. Watch how prompting the Decision Transformer with higher target returns changes the agent's simulated gait, velocity, and trajectory in real-time.

3600 (Expert)
1000 (Poor) 3600 (Expert) 6000 (Extrapolated)
Gait Mode: Stable Jump-Run
Simulated Velocity: 3.5 m/s
Extrapolation Risk: Low
Higher target returns condition the attention layers to generate larger, more coordinated torque actions.

4. Headline Results

Despite its extreme simplicity and complete lack of dynamic programming, Decision Transformer matches or exceeds state-of-the-art model-free offline RL baselines on standard benchmarks.

Dataset / Task DT (Ours) CQL (SOTA TD) Behavior Cloning
Atari Breakout (1% dataset) 267.5 ± 97.5 211.1 138.9 ± 61.7
Gym HalfCheetah (Medium-Expert) 86.8 ± 1.3 62.4 59.9
Gym Hopper (Medium-Expert) 107.6 ± 1.8 111.0 79.6
Gym Walker (Medium-Expert) 108.1 ± 0.2 98.7 36.6

5. Limitations & Open Questions

Return Extrapolation Limits

While DT can extrapolate to slightly higher returns than observed in the training set, prompting it with unrealistic, extremely high returns (e.g., 10x the maximum dataset return) often leads to policy collapse, as the model enters unvisited state-action spaces.

Stochastic Environments

In highly stochastic environments, returns-to-go are noisy. A model trained on deterministic sequences might struggle to differentiate between a high return achieved via lucky environment transitions versus one achieved via optimal policy execution.

6. Glossary

Temporal Difference (TD) Learning

A fundamental RL concept where value estimates are updated based on other value estimates (bootstrapping), rather than waiting for the final actual outcome of the trajectory.

Return-to-Go (RTG)

The cumulative sum of future rewards from a specific timestep $t$ to the end of the episode. In Decision Transformer, this acts as the "goal prompt" conditioning the generation.

Conservative Q-Learning (CQL)

A state-of-the-art offline RL baseline that addresses value overestimation by learning a conservative, lower-bound Q-function, penalizing out-of-distribution actions.

7. Citation

@inproceedings{chen2021decision,
  title={Decision Transformer: Reinforcement Learning via Sequence Modeling},
  author={Chen, Lili and Lu, Kevin and Rajeswaran, Aravind and Lee, Kimin and Grover, Aditya and Laskin, Michael and Abbeel, Pieter and Srinivas, Aravind and Mordatch, Igor},
  booktitle={Advances in Neural Information Processing Systems},
  volume={34},
  pages={15084--15097},
  year={2021}
}
Made with Flash Papers — make your own