Online Decision Transformer

Qinqing Zheng, Amy Zhang, Aditya Grover

Abstract

Recent work has shown that offline reinforcement learning (RL) can be formulated as a sequence modeling problem and solved via approaches similar to large-scale language modeling. However, any practical instantiation of RL also involves an online component, where policies pretrained on passive offline datasets are finetuned via task-specific interactions with the environment. We propose Online Decision Transformers (ODT), an RL algorithm based on sequence modeling that blends offline pretraining with online finetuning in a unified framework. Our framework uses sequence-level entropy regularizers in conjunction with autoregressive modeling objectives for sample-efficient exploration and finetuning. Empirically, we show that ODT is competitive with the state-of-the-art in absolute performance on the D4RL benchmark but shows much more significant gains during the finetuning procedure.

Introduction

The Decision Transformer (DT) recently shifted the RL paradigm by treating it as a sequence modeling problem—essentially "GPT for RL." While DT excelled at learning from fixed, offline datasets, it faced a significant hurdle: the inability to improve through new experiences. Offline RL is inherently limited by the quality of its training data. To reach expert-level performance, an agent must eventually interact with the environment through online finetuning. However, standard DTs are deterministic and lack a mechanism for exploration, often leading to model collapse or failure to learn when exposed to new data. The Online Decision Transformer (ODT) addresses this by evolving the DT into an active agent capable of online improvement.

Methodology

ODT introduces four key modifications to the original Decision Transformer architecture to enable effective online learning:

  1. Stochastic Policies: Instead of predicting a single action, ODT outputs a probability distribution (multivariate Gaussian). This allows the agent to sample different actions during online interaction, providing the necessary foundation for exploration.
  2. Max-Entropy Sequence Modeling: ODT incorporates an entropy objective constrained at the sequence level, rather than the timestep level used in traditional RL. This ensures the agent maintains diverse behaviors over an entire trajectory.
  3. Trajectory-Level Replay Buffer: To accommodate the transformer's need for context, ODT utilizes a buffer that stores and samples entire sub-trajectories rather than individual transitions.
  4. Hindsight Return Relabeling: ODT uses a technique to relabel "Return-to-Go" (RTG) tokens in the buffer with the actual returns achieved during rollouts. This teaches the model the true relationship between its actions and the resulting rewards, even when the agent fails to meet its initial target.
Stochasticity is critical for training stability and performance in ODT compared to deterministic variants.

Key Insights

A striking finding in the development of ODT is the role of stochasticity. As shown in the comparison between stochastic and deterministic models, the stochastic ODT is significantly more stable during training. Deterministic models often show high variability and performance degradation as more online data is collected, whereas ODT improves smoothly. Furthermore, the dual variable (λ) in the ODT objective automatically balances matching the offline data (behavior cloning) with exploring for new rewards.

Experimental Results

ODT was evaluated on the D4RL benchmark, focusing on Gym Locomotion and AntMaze tasks. The results highlight ODT's superior ability to bridge the gap between offline pretraining and expert-level online performance.

Performance Gains through Finetuning

In Gym locomotion tasks, ODT's relative performance gains during finetuning were approximately 9x greater than those of Implicit Q-Learning (IQL). For example, in the Hopper-medium task, ODT improved from a normalized score of ~67 (offline) to ~97 (online), effectively reaching expert performance.

Finetuning significantly improves the model's ability to achieve high returns across various Return-to-Go (RTG) targets.

AntMaze Success

ODT achieved a score of 88.5 on AntMaze-umaze, nearly matching IQL (89.5) and vastly outperforming standard online-only methods like SAC, which failed to learn the task entirely within the 200k step budget.

Limitations and Future Work

While ODT represents a significant step forward, several challenges remain. It is designed specifically for the "offline-to-online" transition; whether transformer-based sequence models can be trained effectively from scratch in a purely online setting remains an open question. Additionally, there is a "sweet spot" for pretraining; over-converging on offline data can actually hinder subsequent exploration. Finally, the computational overhead of processing long sequences with transformers remains higher than that of simpler MLP-based RL agents.

Summary updated

Abstract

Recent work has shown that offline reinforcement learning (RL) can be formulated as a sequence modeling problem (Chen et al., 2021; Janner et al., 2021) and solved via approaches similar to large-scale language modeling. However, any practical instantiation of RL also involves an online component, where policies pretrained on passive offline datasets are finetuned via taskspecific interactions with the environment. We propose Online Decision Transformers (ODT), an RL algorithm based on sequence modeling that blends offline pretraining with online finetuning in a unified framework. Our framework uses sequence-level entropy regularizers in conjunction with autoregressive modeling objectives for sample-efficient exploration and finetuning. Empirically, we show that ODT is competitive with the state-of-the-art in absolute performance on the D4RL benchmark but shows much more significant gains during the finetuning procedure.
BibTeX
@inproceedings{zheng2022online,
  author = {Qinqing Zheng and Amy Zhang and Aditya Grover},
  title = {{Online Decision Transformer}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=qTkxIayOb2},
}
Figure