A decision transformer is a model that recasts reinforcement learning as conditional sequence modeling: a causal transformer reads a trajectory of returns-to-go, states and actions and predicts the next action needed to achieve a specified target return. Introduced in 2021, it belongs to the family of offline reinforcement learning methods in artificial intelligence that learn from fixed datasets of logged behavior instead of live interaction.
The approach replaces the usual machinery of value functions, Bellman backups and policy gradients with supervised learning on trajectories. Its appeal lies in simplicity and stability: it inherits the training recipe of language models, scales with data and compute, and avoids the bootstrapping instabilities that make offline value-based methods difficult to tune.
How a decision transformer models trajectories
Each trajectory is converted into a sequence of three token types per time step: the return-to-go, the state and the action. The return-to-go is the sum of future rewards from that step to the end of the episode, so it tells the model how much reward remains to be collected.
Each token type passes through its own linear embedding, receives a learned timestep embedding, and enters a GPT-style transformer with causal masking. The model is trained to predict each action from all earlier tokens, using cross-entropy loss for discrete actions or mean squared error for continuous ones. No reward is maximized directly during training.
| Token | Content | Role in prediction |
|---|---|---|
| Return-to-go | Sum of remaining rewards | Conditions the policy on a desired outcome |
| State | Observation at the current step | Describes the situation to act in |
| Action | Action taken at that step | Prediction target and context for later steps |
| Timestep embedding | Position within the episode | Replaces standard positional encoding |
The context window typically covers 20 to 50 recent time steps, which means the model attends to a short history rather than the full episode. This window size is an important hyperparameter, because tasks with long-horizon dependencies need longer contexts.
Return conditioning at inference time
At deployment the user supplies an initial target return, often set near the best return observed in the dataset. After each step, the environment reward is subtracted from the target, and the reduced value becomes the next return-to-go token. The model thus behaves like a goal-conditioned policy in which the goal is a level of performance.
Setting the target is not trivial. A target that is far above anything in the data usually does not produce better behavior, because the model has no examples of how to reach it. A target that is too low yields deliberately mediocre actions. In practice, practitioners sweep several targets and keep the one with the best evaluated return.
Decision transformer compared with other offline methods
The decision transformer sits between plain imitation and value-based offline reinforcement learning. The table compares it with the methods most often used as baselines.
| Method | Learning signal | Strength | Weakness |
|---|---|---|---|
| Behavior cloning | Imitate all logged actions | Very simple and stable | Copies poor demonstrations as well as good ones |
| Decision transformer | Imitate actions conditioned on return | Stable, scalable, handles mixed-quality data | Weak trajectory stitching |
| Conservative Q-learning | Pessimistic value estimates | Can combine partial good trajectories | Sensitive hyperparameters |
| Implicit Q-learning | In-sample value learning | Strong benchmark results | More complex training pipeline |
A key difference is trajectory stitching, the ability to combine the good first half of one trajectory with the good second half of another. Dynamic programming methods do this naturally through the Bellman equation; a decision transformer does it only weakly, because it imitates whole sequences rather than propagating value backward.
Variants and extensions
Since the original publication, researchers have proposed several extensions that target its known weaknesses or widen its scope. The most cited ones are summarized below.
| Variant | Main change | Purpose |
|---|---|---|
| Online decision transformer | Adds online fine-tuning with exploration | Improves beyond the offline dataset |
| Multi-game decision transformer | Trains one model on many Atari games | Tests scaling and transfer across tasks |
| Q-value regularized variants | Adds a learned value term to the loss | Restores trajectory stitching |
| Elastic decision transformer | Adapts history length during inference | Better stitching with variable context |
| Trajectory transformer | Models states and rewards as well, with beam search | Planning rather than direct action prediction |
These variants show a broader trend: sequence models are converging with planning and value estimation rather than replacing them. The original architecture remains a strong, easy-to-reproduce baseline for offline benchmarks such as D4RL locomotion tasks and Atari datasets.
Limitations and common misconceptions
The method is often misread as a general replacement for reinforcement learning. Its actual guarantees are narrower, and several limitations matter in practice.
- It does not explore. In its offline form, the model cannot discover behavior absent from the dataset.
- Stochastic environments mislead it. A high return in the data may reflect luck, and conditioning on it teaches the model to expect luck.
- Data quality bounds performance. With no good trajectories in the data, high return targets have little effect.
- Context length limits credit assignment. Dependencies longer than the window are invisible to the model.
A frequent misconception is that a decision transformer optimizes reward. It does not; it predicts actions consistent with a requested return, which approximates optimization only when the dataset contains enough high-return behavior to imitate.
A non-technical view
Picture a coach who has watched thousands of recorded games. Each recording shows the moves and the final score. Now you tell the coach the score you want. The coach suggests moves that usually led to that score.
A decision transformer works like that coach. It does not learn by trial and error. It studies records of past behavior and copies the patterns that went with good results. It is simple and reliable. However, it cannot invent a winning plan that never appeared in the recordings.
A concrete example
A warehouse operator wants a robotic arm to pick mixed items from bins, but letting the arm experiment on live orders is too risky. The team has six months of logged data, about 200,000 pick attempts made by a scripted controller and by human teleoperators, each labeled with a reward for successful, gentle and fast picks.
Engineers train a decision transformer with a context of 30 steps on these logs. During testing in a simulator, they sweep target returns and find that a target near the top 10 percent of logged returns gives the best results. The model reaches a success rate close to the best teleoperators and clearly above the scripted controller, because it learns to imitate the high-return episodes instead of the average ones.
The team notes that the model struggles with item shapes absent from the logs. It therefore adds a supervised safety check and plans a short, controlled online fine-tuning phase before full deployment.