Offline Reinforcement Learning as One Big Sequence Modeling Problem

Michael Janner, Qiyang Li, Sergey Levine

Overview

This paper reframes offline reinforcement learning (RL) as a pure sequence modeling problem, stripping away standard RL components like separate actors, critics, and dynamics models. By training a GPT-style Transformer on discretized sequences of states, actions, and rewards, and repurposing beam search for planning, the authors achieve state-of-the-art results on offline RL benchmarks. It demonstrates that high-capacity sequence models from natural language processing can effectively solve complex control and planning tasks through sheer representational power.

The Problem

Standard reinforcement learning relies heavily on the Markov property to break long-horizon problems into smaller, single-step subproblems. This usually requires a complex web of distinct algorithmic components: model-free methods need separate actor and critic networks, model-based methods need single-step predictive dynamics models, and offline RL methods require complex conservatism mechanisms to prevent the agent from taking out-of-distribution actions.

The authors ask a provocative question: what if we bypass this algorithmic complexity entirely? Given the massive success of high-capacity sequence models (like Transformers) in NLP, the authors investigate whether we can treat RL simply as a sequence generation problem—predicting a sequence of actions that leads to a sequence of high rewards—using the exact same tools used to generate text.

Methods: The Trajectory Transformer

The authors introduce the Trajectory Transformer, which treats environment trajectories as flat, unstructured sequences of tokens: (state_1, action_1, reward_1, state_2, action_2, reward_2, ...).

Trajectory Transformer Architecture
  • Discretization: Because standard Transformers operate on discrete tokens, continuous states and actions are discretized independently per dimension. The authors test uniform binning and quantile binning (which ensures equal probability mass per bin to handle outliers).
  • Architecture: The model is a standard GPT-style Transformer decoder that predicts the next token autoregressively using teacher-forcing.
  • Planning via Beam Search: Instead of standard trajectory optimizers, the authors repurpose beam search (a standard heuristic decoding algorithm in NLP) for control.
  • Imitation Learning: Standard beam search is used to maximize the likelihood of the sequence.
  • Goal-Conditioned RL: The model is conditioned on a desired future state (anti-causal conditioning) to find a path to a goal.
  • Offline RL: The training data is augmented with a "reward-to-go" token. During beam search, the algorithm filters for sequences that maximize cumulative reward plus the predicted reward-to-go.
  • Sparse-Reward RL: The Monte Carlo reward-to-go estimate is replaced with a learned Q-function to guide the beam search.

Datasets

  • D4RL (Datasets for Deep Data-Driven Reinforcement Learning): The primary benchmark used for offline RL evaluation, specifically the continuous locomotion environments (HalfCheetah, Hopper, Walker2d) and the sparse-reward AntMaze navigation tasks.
  • Humanoid: Used to evaluate the long-horizon predictive accuracy of the model compared to standard dynamics models.
  • Continuous Four-Rooms: A custom continuous variant of the classic gridworld environment, used to test goal-reaching and anti-causal conditioning.

Key Insights and Ideas

  • Simplicity over algorithmic complexity: By jointly modeling states and actions, the Trajectory Transformer naturally stays within the distribution of the training data. This entirely avoids the need for explicit pessimism or behavior policy estimation, which are major pain points in standard offline RL.
  • Solving the compounding error problem: Standard single-step dynamics models suffer from compounding errors, quickly diverging from reality. The Trajectory Transformer produces visually indistinguishable, physically plausible rollouts even 100 steps into the future, far outperforming standard probabilistic ensembles.
Humanoid Rollout Comparison
  • Non-Markovian attention patterns: Visualizing the Transformer's attention heads reveals that it learns both Markovian strategies (looking only at the immediate past) and complex, multi-step dependencies. Interestingly, predicted actions often depend heavily on past actions, acting as an implicit action-smoothing filter.
  • A unified framework: The exact same architecture can perform imitation learning, goal-conditioned RL, and reward-maximizing offline RL simply by tweaking the beam search conditioning.

Key Results

  • Offline RL (Locomotion): The Trajectory Transformer (Quantile variant) achieves an average normalized return of 78.9 across D4RL locomotion tasks. This matches or outperforms state-of-the-art model-free methods like CQL (77.6) and concurrent sequence-modeling approaches like Decision Transformer (74.7).
  • Sparse Reward (AntMaze): In tasks requiring temporal compositionality (stitching together sub-optimal trajectories to reach a goal), return-conditioning methods like Decision Transformer fail (11.8 average). However, the Trajectory Transformer guided by a Q-function heuristic achieves an 84.0 average, crushing prior state-of-the-art methods like IQL (63.2).
  • Prediction Accuracy: In the complex Humanoid environment, the Transformer maintains high log-likelihood for predicted trajectories up to 50+ timesteps, whereas standard feedforward models degrade almost immediately.

Limitations and Future Work

  • Inference Speed: Transformers are computationally heavy. Autoregressive generation and beam search take up to multiple seconds per action, making this approach currently unsuitable for high-frequency, real-time control.
  • Discretization Limits: Forcing continuous spaces into discrete tokens fundamentally caps the precision of the model's predictions and actions.
  • Future Directions: The authors suggest that combining this sequence-modeling approach with dynamic programming techniques (like the Q-guided planning demonstrated) is the most practical path forward. Additionally, adopting computationally efficient Transformer architectures could help alleviate the current speed bottlenecks.

Summary updated

BibTeX
@inproceedings{janner2021offline,
  author = {Michael Janner and Qiyang Li and Sergey Levine},
  title = {{Offline Reinforcement Learning as One Big Sequence Modeling Problem}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=zDE7M2exTVs},
}
Figure