Prompt Tuning Decision Transformers with Structured and Scalable Bandits

Finn Rietz, Oleg Smirnov, Sara Karimi, Lele Cao

TL;DR

Prompting Decision Transformers (PDTs) generalize to new reinforcement learning tasks using trajectory prompts, but sampling these prompts randomly often introduces uninformative data that degrades performance. This paper introduces a structured, scalable contextual bandit approach that learns to select the most informative prompt segments at inference time. By scaling linearly instead of combinatorially and leveraging the pre-trained PDT as a feature extractor, this method significantly boosts multi-task and out-of-distribution performance without updating any model weights.

What Problem Does This Paper Address?

Decision Transformers (DTs) treat reinforcement learning (RL) as a sequence modeling problem, predicting actions based on a history of states, actions, and target returns. To handle multi-task settings, the Prompting Decision Transformer (PDT) prepends a "prompt"—a sequence of expert trajectory segments—to the context window, helping the model identify the current task.

However, vanilla PDT assumes all expert trajectories are equally informative and samples them uniformly at random. In reality, many expert segments look identical across different tasks (e.g., a robot arm starting from the exact same position), failing to provide the distinct cues needed for task identification. Existing prompt-tuning methods either rely on continuous optimization that struggles in discrete spaces, or suffer from combinatorial explosion when trying to find the best combination of trajectory segments.

Methods

The authors propose a structured Multi-Armed Bandit (MAB) architecture for test-time prompt optimization:

  • Factorized Reward Modeling: Instead of treating every full prompt combination as a separate arm (which scales combinatorially with the number of segments $J$), the architecture maintains $J$ independent reward models, one for each position in the prompt. This reduces the search space complexity from combinatorial to linear.
  • PDT as a Feature Extractor: To handle high-dimensional state and action spaces, the method passes the trajectory segments through the pre-trained PDT itself, using its internal token embeddings as fixed-size features ($\Psi$) for the bandit.
  • Exploration Strategies: Standard bandit exploration mechanisms like $\epsilon$-greedy, Upper Confidence Bounds (UCB), and Thompson Sampling (TS) are applied to efficiently navigate and select the optimal segments.

The overall architecture of this prompt-tuning framework is illustrated below:

Overview of the bandit-based prompt-tuning framework

Datasets

The method was evaluated on standard multi-task offline RL benchmarks alongside a custom environment:

  1. MuJoCo Half Cheetah: Tasks involving matching varying target velocities.
  2. MuJoCo Ant: Tasks requiring movement along different target directions.
  3. Meta-world Pick-place: Robotic arm manipulation tasks requiring picking objects and placing them at distinct target positions.
  4. Sparse 2D Point: A custom planar navigation environment where an agent must find a hidden goal and execute a 'stop' action, receiving sparse rewards based on final distance.

Environments were split into in-distribution training sets and holdout out-of-distribution (OOD) test sets to rigorously evaluate generalization.

Key Insights and Ideas

  • The Power of Modular Prompts: Attention analysis reveals that PDT naturally focuses on the single most informative segment within a prompt to identify a task. This means prompt segments operate largely independently, validating the authors' core assumption and justifying the linear factorization of the bandit space.
  • Zero-Shot Weight Updates: The method achieves massive performance gains purely by optimizing the input prompt at inference time. This completely avoids the computational cost, infrastructure requirements, and overfitting risks associated with fine-tuning a massive Transformer backbone.
  • Embeddings Over Raw Modalities: Using the pre-trained PDT's internal representations as features for the bandit provides a compact, fixed-dimensional space. This drastically improves wall-clock inference efficiency compared to raw state-action modalities, especially in complex environments.

Key Results

  • In-Distribution Boost: The bandit-tuned PDT consistently outperforms vanilla PDT and competitive baselines like ZORankSGD and Hill-climbing. In the MuJoCo Ant environment, it even beats the single-task Conservative Q-Learning (CQL) oracle.
  • Out-of-Distribution Robustness: On OOD tasks, the structured bandit method significantly improves generalization. In contrast, baseline tuning methods show degraded performance due to their reliance on iterative, noise-driven perturbations that struggle in unfamiliar environments.
  • Inference Efficiency: Using Transformer-encoded features ($\Psi$) maintains high returns while keeping wall-clock inference times low and stable, avoiding the scaling penalties of unencoded segments as prompt lengths increase.

Limitations and Future Work

  • Scaling with Demonstration Size: While the method scales linearly with the prompt length $J$, the search space still grows linearly with the total number of transitions in the demonstration dataset ($|P_i|$). For massive datasets, this could become a bottleneck.
  • Extrapolation Limits: Although prompt tuning maximizes the utility of the pre-trained model, it cannot overcome fundamental extrapolation failures if the underlying PDT completely lacks the capability to generalize to a radically new OOD task.
  • Future Directions: The authors suggest training a dedicated sampler to pre-select high-potential segments or clustering similar prompts to reduce redundancy before running the bandit algorithm.

Summary updated

BibTeX
@inproceedings{rietz2025prompt,
  author = {Finn Rietz and Oleg Smirnov and Sara Karimi and Lele Cao},
  title = {{Prompt Tuning Decision Transformers with Structured and Scalable Bandits}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=yI55mj6anU},
}
Figure