Reinforcement Learning Gradients as Vitamin for Online Finetuning Decision Transformers

Kai Yan, Alex Schwing, Yu-Xiong Wang

TL;DR

Decision Transformers (DTs) are powerful for offline reinforcement learning but often stall during online finetuning, especially when initialized with low-quality data. This paper proposes adding standard reinforcement learning gradients (from the TD3 algorithm) as a "vitamin" to provide the local guidance DTs lack. This hybrid approach leads to state-of-the-art performance in complex offline-to-online transitions.

The Challenge of Online Finetuning for Decision Transformers

In the realm of Reinforcement Learning (RL), the Decision Transformer (DT) represents a significant paradigm shift. Instead of the traditional approach of estimating "value functions" (i.e., calculating how good a specific state is), DTs treat RL as a sequence modeling problem. Given a history of states and a target "Return-To-Go" (RTG), the transformer predicts the most likely action to achieve that return.

While DTs excel at learning from fixed offline datasets, they struggle with online finetuning—the phase where the agent interacts with an environment to further improve its policy. This problem is particularly acute when the initial offline data is of low quality. If a DT has only ever seen low-reward trajectories, it lacks the knowledge to "reach" for a high target return. It essentially misses a local "compass" to indicate which direction in the action space leads to better outcomes. Consequently, existing state-of-the-art methods like the Online Decision Transformer (ODT) often fail to improve when pretrained on mediocre data.

Methods: Adding the RL "Vitamin"

To address this, the authors introduce a simple but highly effective remedy: TD3+ODT. They argue that while the Transformer architecture is excellent at capturing global trajectory patterns, it desperately needs the "local" guidance provided by traditional actor-critic gradients.

  1. The "Vitamin" (RL Gradients): The researchers incorporate gradients from TD3 (Twin Delayed Deep Deterministic Policy Gradient). While the Transformer backbone handles the policy, two MLP-based "critics" ($Q$-functions) are added to estimate the expected return for specific state-action pairs.
  2. Hybrid Objective: During finetuning, the model minimizes a combined loss:
  3. A standard Supervised Learning loss (predicting the action from the dataset).
  4. A TD3 Actor loss, which pushes the policy to choose actions that the critics believe will yield higher rewards.
  5. Reflexive Critics: To maintain stability and efficiency, the method uses "reflexive" critics that only evaluate the current state and action, rather than the entire historical sequence. This provides an "average" guidance across different possible context lengths.

Key Insights: The Gradient Direction Mismatch

Conceptual diagram illustrating how ODT struggles with unreachable target RTGs due to missing gradients, and how adding TD3 provides the necessary local Q-function gradients for improvement.
  • The Gradient Direction Mismatch: A standard DT naturally provides the gradient $\partial \text{action} / \partial RTG$ (how the action changes if the target return changes). However, to actually improve a policy, the agent needs $\partial RTG / \partial \text{action}$ (which action will increase the return). Because Transformers are not easily invertible, they cannot find this "direction of improvement" independently.
  • The "Unreachable Target" Problem: The authors mathematically prove that if the target RTG is far outside the distribution of the training data, the performance bound for a standard DT becomes extremely loose. In simpler terms: if the model hasn't seen high rewards, prompting it with a high RTG target is likely to result in gibberish or failure.
  • Theoretical Connection to AWAC: The paper provides a mathematical link demonstrating that under certain conditions (such as Laplace distributions of returns), the Decision Transformer update is equivalent to Advantage-Weighted Actor-Critic (AWAC).

Key Results and Performance

Performance comparison showing reward curves, rollout distributions, and critic estimations. ODT+DDPG significantly outperforms standard ODT.

The researchers evaluated their method on several standard RL benchmarks, including Adroit (complex robotic manipulation), Antmaze (navigation), and MuJoCo (classic continuous control).

  • Superiority on Low-Quality Data: On the "random" MuJoCo datasets—where standard ODT typically scores near zero—TD3+ODT achieved remarkably high scores (e.g., 76.1 on Hopper-random compared to ODT's 29.1).
  • Stability on Complex Tasks: In the highly complex Adroit "Hammer" environment, TD3+ODT reached a score of 126.4, while the previous state-of-the-art (PDT) only managed 0.7.
  • Efficiency: Adding the TD3 "vitamin" only increases training time by approximately 20%. This is a small computational price to pay for massive jumps in performance and stability.
  • Outperforming Baselines: The proposed method consistently beat other popular offline-to-online algorithms, such as IQL and TD3+BC, across almost all tested environments.

Limitations and Future Work

  • Theoretical Assumptions: The formal proofs rely on assumptions like the Lipschitz continuity of the return distribution, which might not hold perfectly in all real-world environments.
  • Hyperparameter Tuning: The weight $\alpha$, which dictates how much to trust the RL gradient versus the supervised data, introduces a new hyperparameter that requires careful balancing.
  • Image-Based Inputs: This study focused primarily on state-vector inputs. Extending this "vitamin" approach to vision-based RL—where Transformers are increasingly popular—is a logical and exciting next step.

Summary updated

BibTeX
@inproceedings{yan2024reinforcement,
  author = {Kai Yan and Alex Schwing and Yu-Xiong Wang},
  title = {{Reinforcement Learning Gradients as Vitamin for Online Finetuning Decision Transformers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=5l5bhYexYO},
}
Figure