H YPER -D ECISION T RANSFORMER FOR E FFICIENT O NLINE P OLICY A DAPTATION
Anonymous authors
Paper under double-blind review
A BSTRACT
Decision Transformers (DT) have demonstrated strong performances in offline reinforcement learning settings, but quickly adapting to unseen novel tasks remains challenging.
To address this challenge, we propose a new framework, called
Hyper-Decision Transformer (HDT), that can generalize to novel tasks from a handful of demonstrations in a data- and parameter-efficient manner.
To achieve such a goal, we propose to augment the base DT with an adaptation module, whose parameters are initialized by a hyper-network.
When encountering unseen tasks, the hyper-network takes a handful of demonstrations as inputs and initializes the adaptation module accordingly.
This initialization enables HDT to efficiently adapt to novel tasks by only fine-tuning the adaptation module.
We validate HDT’s generalization capability on object manipulation tasks.
We find that with a single expert demonstration and fine-tuning only 0 .
5% of DT parameters ,
HDT adapts faster to unseen tasks than fine-tuning the whole DT model.
Finally, we explore a more challenging setting where expert actions are not available, and we show that HDT outperforms state-of-the-art baselines in terms of task success rates by a large margin.
Demos are available on our project page.
I NTRODUCTION
Building an autonomous agent capable of generalizing to novel tasks has been a longstanding goal of artificial intelligence.
Recently, large transformer models have shown strong generalization capability on language understanding when fine-tuned with limited data (Brown et al., 2020; Wei et al., 2021).
Such success motivates researchers to apply transformer models to the regime of offline reinforcement learning (RL) (Chen et al., 2021; Janner et al., 2021).
By scaling up the model size and leveraging large offline datasets from diverse training tasks, transformer models have shown to be generalist agents successfully solving multiple games with a single set of parameters (Reed et al., 2022; Lee et al., 2022).
Despite the superior performance in the training set of tasks, directly deploying these pre-trained agents to novel unseen tasks would still lead to suboptimal behaviors.
One solution is to leverage the handful of expert demonstrations from the unseen tasks to help policy adaptation, and this has been studied in the context of meta imitation learning (meta-IL)
(Duan et al., 2017; Reed et al., 2022; Lee et al., 2022).
In order to deal with the discrepancies between the training and testing tasks, these works focus on fine-tuning the whole policy model with either expert demonstrations or online rollouts from the test environments.
However, with the advent of large pre-trained transformers, it is computationally expensive to fine-tune the whole models, and it is unclear how to perform policy adaptation efficiently (Figure 1 (a)).
We aim to fill this gap in this work by proposing a more parameter-efficient solution.
Moreover, previous work falls short in a more challenging yet realistic setting where the target tasks only provide demonstrations without expert actions.
This is similar to the state-only imitation learning or Learning-from-Observation (LfO) settings (Torabi et al., 2019; Radosavovic et al., 2021), where expert actions are unavailable, and therefore we term this setting as meta Learning-fromObservation (meta-LfO).
As a result, we aim to develop a more general method that can address both meta-IL and meta-LfO settings.
The closest work to ours is Prompt-DT (Xu et al., 2022), which proposes to condition the model behavior in new environments on a few demonstrations as prompts.
While the method is originally evaluated for meta-IL, the flexibility of the prompt design also allows this method to be useful for meta-LfO.
However, we find that Prompt-DT hardly generalizes to novel environments (as is shown empirically in Section 4), since the performance of the in-context learning paradigm, e.g., prompting, is generally inferior to fine-tuning methods (Brown et al., 2020).
The lack of an efficient adaptation mechanism also makes Prompt-DT vulnerable to unexpected failures in unseen tasks.
In order to achieve the strong performance of fine-tuning-based methods as well as maintain the efficiency of in-context learning methods, we propose Hyper-Decision Transformer (HDT) for large pre-trained Decision Transformers (DT) (Chen et al., 2021).
HDT composes of three key components: (1) a multi-task pre-trained DT model, (2) adapter layers that can be updated when solving novel unseen tasks, and (3) a hyper-network that outputs parameter initialization of the adapter layer based on demonstrations.
The pre-trained DT model encodes shared information across diverse training tasks and serves as a base policy.
To mimic the performance of fine-tuning methods, we introduce an adapter layer with a bottleneck structure to each transformer block (Houlsby et al., 2019).
The parameters in the adapter layers can be updated to adapt to a new task.
Moreover, it only adds a small fraction of parameters to the base DT model.
The adapter parameters are initialized by a single hyper-network conditioning on the demonstrations with or without actions.
In such a way, the hyper-network extracts the task-specific information from demonstrations, which is encoded into the adapter’s initialized parameters.
We evaluate HDT in both meta-IL (with actions) and meta-LfO (without actions) settings.
In metaIL, the adapter module could directly fine-tune in a supervised manner as few-shot imitation learning.
In meta-LfO, the agent interacts with the environment and performs RL, while conditioning on the expert states.
We conduct extensive experiments in the Meta-World benchmark Yu et al.
(2020), which contains diverse manipulation tasks requiring fine-grind gripper control.
We train HDT with 43 tasks and test its generalization capability in 5 testing tasks with unseen objects, or seen objects with different reward functions.
Our experiment results show that HDT demonstrates strong data and parameter efficiency when adapting to novel tasks.
We list our contributions as follows:
We propose Hyper-Decision Transformer (HDT), a transformer-based model which generalizes to novel unseen tasks maintaining strong data and parameter efficiency.
In the meta-IL setting with only one expert demonstration , HDT only fine-tunes a small fraction (0.5%) of the model parameters and adapts faster than baselines that fine-tune the whole model, demonstrating strong parameter efficiency.
In the meta-LfO setting with only 20-80 online rollouts, HDT can sample successful episodes and therefore outperforms baselines by a large margin in terms of success rates, demonstrating strong data efficiency.
R ELATED W ORK
Transformers in Policy Learning.
Transformer (Vaswani et al., 2017) has shown success in natural language tasks thanks to its strong sequence-modeling capacity.
As generating a policy in RL is essentially a sequence prediction problem, Chen et al.
(2021) propose Decision Transformer (DT) that adapts the Transformer architecture to solve offline RL problems, achieving performances comparable to traditional offline RL algorithms.
This work also inspires adaptions of Transformer in different RL settings.
Zheng et al.
(2022) propose Online DT, which enables DT to explore online and applies it in an online RL setting.
Xu et al.
(2022) use the prompt in Transformer to provide task information, which makes the DT capable of achieving good performance in different tasks.
Reed et al.
(2022) also exploit the prompt in Transformer and train one Transformer model to solve different games or tasks with different modalities.
Lee et al.
(2022) propose multi-game DT which shows strong performance in the Atari environment (Bellemare et al., 2013).
Furuta et al.
(2021) identify that DT solves a hindsight information matching problem and proposed Generalized DT that can solve any hindsight information matching problem.
One-shot and Meta Imitation Learning.
Traditional imitation learning considers a single-task setting, where the expert trajectories are available for a task and the agent aims the learn an optimal policy for the same task.
One-shot and meta-imitation learning aims to improve the sample efficiency of imitation learning by learning from a set of training tasks and requires the agent to generalize to different tasks.
Duan et al.
(2017) train a one-shot imitator that can generate optimal policies for different tasks given the demonstrations of the corresponding task.
Finn et al.
(2017b) enable a robot to learn new skills using only one demonstration with pixel-level inputs.
James et al.
(2018) first learn task embeddings, and use the task embedding of the test task jointly with test task demonstrations to find the optimal control policy in robotic tasks.
Learning from Observations.
When deployed in a new environment or tested on a new task, it may be challenging for an agent to achieve good performance without any information about the task.
Therefore, the agent can benefit from starting with imitating some expert trajectories (Argall et al., 2009).
Usually, expert trajectories consist of a sequence of state, action pairs rolled out from an expert policy.
However, assuming the availability of both states and actions can prevent the agent from learning from many resources (for example, online video demonstrations).
So we consider a setting where such trajectories may only contain states and rewards rolled out from the expert policies.
This is considered as learning from observations in the literature (Torabi et al., 2019).
Prior work trains an inverse dynamics model and uses it to predict actions based on states (Radosavovic et al., 2021) and enhances learning from observation methods by minimizing its gap to learning from demonstrations (Yang et al., 2019).
Transformers are also applied in this problem to achieve one-shot visual imitation learning (Dasari & Gupta, 2020).
Hyper-networks.
The idea of using one network (the hyper-network) to generate weights for another (the target network) is first introduced in Ha et al.
In the continuing learning setting,
Von Oswald et al.
(2019) proposes generating the entire weights of a target network while conditioned on the task information.
In the robotic setting, Xian et al.
(2021) considers a model-based setting and uses hyper-networks to generate the parameters of a neural dynamics model according to the agent’s interactions with the environment.
Parameter-efficient Adaptation.
When modern neural network models become increasingly large, generating or fine-tuning the full model becomes increasingly expensive.
Lester et al.
(2021) introduces “soft prompts” to alternate the output of a pre-trained transformer model.
Task-specific soft prompts enable the transformer model to output answers for the given task.
Liu et al.
(2022) proposes adding a few controlling vectors in the feedforward and the attention blocks to control the behavior of a pre-trained transformer model.
Mahabadi et al.
(2021) uses a hyper-network to generate task-specific adaptation modules for transformer models from a task embedding.
This method enables efficient adaptation by just learning the task embedding vector.
H YPER D ECISION T RANSFORMER
To facilitate the adaptation of large-scale transformer agents, we propose Hyper-Decision Transformer (HDT), a Transformer-based architecture maintaining data and parameter efficiency during adaptation to novel unseen tasks.
HDT consists of three key modules as in Figure 2: a base DT model encoding shared knowledge across multiple tasks (Section 3.2), a hyper-network representing a taskspecific meta-learner (Section 3.4), and an adaptation module updated to solve downstream unseen tasks (Section 3.3).
After presenting the model details, we summarize the training and adaptation algorithms in Section 3.5.
3. P ROBLEM F ORMULATION : E FFICIENT A DAPTATION FROM O BSERVATIONS
We aim to improve the generalization capability of large transformer-based agents with limited online interactions and computation budgets.
Existing large transformer-based agents have demon- strated strong performances in training tasks, and may have sub-optimal performances when directly deployed in novel tasks (Reed et al., 2022;
Lee et al., 2022; Xu et al., 2022).
Although the discrepancy between the training and testing tasks has been widely studied in meta RL (Finn et al., 2017a;
Duan et al., 2016), efficient adaptations of large transformer-based agents are still non-trivial.
Beyond the data efficiency measured by the number of online rollouts, we further emphasize the parameter efficiency measured by the number of parameters updated during online adaptation.
We formulate the environment as an Markov Decision Process (MDP) represented by a 5-tuple
M = ( S , A , P, R, µ ) .
S and A are the state and the action space, respectively.
P is the transition probability and P : S ×
A × S → R .
R is the reward function where R : S → R .
µ is the initial state distribution.
Following Xu et al.
; Torabi et al.
(2019), we consider efficient adaption from demonstrations with a base policy pre-trained with a set of diverse tasks.
Formally, we assume access to a set of training tasks T train .
Each task T i ∈ T train is accompanied by a large offline dataset D i and a few demonstrations P i , where i ∈ [ | T train | ] .
The dataset D i contains trajectories h collected with an (unknown) behavior policy, where h
= ( s 0 , a 0 , r 0 , · · · , s H , a H , r H ) with s i ∈ S , a i ∈ A , r as the per-timestep reward, and H as the episode length.
We consider the efficient adaptation problem in two settings: meta-imitation learning (meta-IL) and meta-learning from observations (meta-LfO).
In meta-IL, the demonstration dataset P consists of full trajectories with expert actions, ˆ h
= ( s 0 , a 0 , r 0 , · · · , s H , a H , r H ) .
In contrast, in meta-LfO, the demonstration dataset P consists of sequences of state and reward pairs, h o =
( s 0 , r 0 , · · · , s H , r H ) .
We evaluate the generalization capability in a set of testing tasks T test , each accompanied with a demonstration dataset P .
Note that the testing tasks are not identical to the training tasks and may not follow the same task distribution as the training ones.
For instance, in manipulation tasks, the agent may need to interact with unseen objects.
3. D ECISION T RANSFORMER (DT) AS THE P RE - TRAINED AGENT
Large transformer-based agents are highly capable of learning multiple tasks (Lee et al., 2022;
Reed et al., 2022).
They follow offline RL settings and naturally cast RL as sequence modeling problems (Chen et al., 2021; Janner et al., 2021).
By tasking a historical context as input, transformers could leverage more adequate information than the observations in the current timestep, especially when the dataset is diverse and the states are partially observable.
In this work, we follow the formulation of DT (Chen et al., 2021), which autoregressively generates actions based on recent contexts.
At each timestep t , DT takes the most recent K -step trajectory segment τ as input, which contains states s , actions a , and rewards-to-go
[Equation]
DT predicts actions at heads, where action a t is the action the agent predicts in state s t .
The model minimizes the mean squared error loss between the action predictions and the action targets.
In contrast to behavior cloning (BC) methods, the action predictions in DT additionally condition on rewards-to-go and timesteps.
The recent context contains both per-step and sequential interactions with environments, and thus encodes task-specific information.
Indeed, in Lee et al.
(2022), recent contexts could embed sufficient information for solving multiple games in the Atari environment (Bellemare et al., 2013).
While in situations where a single state has different optimal actions for different tasks, additional task-specific information (eg. the demonstration in target tasks) injected into the model further helps improve the multi-task learning performance (Xu et al., 2022).
In this work, we pre-train a DT model with datasets from multiple tasks as the base agent.
It is worth noting that the base DT model could be replaced by any other pre-trained transformer agent.
3. A DAPTATION M ODULE
To enable parameter-efficient model adaptation, we insert task-specific adapter layers to transformer blocks.
Adapter-based fine-tuning is part of parameter-efficient fine-tuning of large language models and generalizes well in NLP benchmarks (Mahabadi et al., 2021).
The adapter layer only contains a small number of parameters compared with the base DT policy.
When fine-tuning on the downstream unseen tasks, HDT only updates the adapter layers with the base DT model’s parameters frozen.
Such a task-wise adaptation mechanism helps maintain parameter efficiency and avoid negative interference where adapting to a new task could lead to decreasing performances in other tasks.
Considering that DT is a decoder-only transformer model, we insert one adapter module into each decoder block and place it before the final residual connection, as shown in Figure 2 (middle).
Let the hidden state be X ∈ R K × d x , where K is the context length and d x is the embedding dimension for each token.
For each decoder block with layer id l , its adapter layer contains a down-projection layer D l ∈ R d x × d h , d h < d x , a GELU nonlinearity, an up-projection layer U l ∈ R d h × d x , and a feature-wise linear modulation (FiLM) layer FiLM l (Perez et al
The bottleneck architecture constructed by the down- and up-projection layers helps reduce the adapter’s parameters.
The
FiLM layer consists of weights γ l ∈ R d x and feature-wise biases β l ∈ R d x , which help selectively manipulate features.
Formally, the adapter layer transforms the hidden state X by
[Equation]
where ⊙ is the Hadamard product.
For each task, we initialize the adapter layer with a shared hyper-network across multiple tasks and encoder layers as described in Section 3.4.
3. H YPER - NETWORK
To promote data-efficient online adaptation, we propose to use a shared hyper-network to generate the adapter layers’ initial parameters.
The hyper-network captures common information across tasks by multi-task training.
It also encodes task-specific information for each task by taking the task demonstration without actions h
o
as input, applicable for both meta-IL and meta-LfO settings.
Given an unseen task, T ∈ T test and its accompanied h o , the trained hyper-network could generate a good parameter initialization that facilitates quick online rollouts.
Motivated by Mahabadi et al.
HDT further utilizes a compact hyper-network for generating adapters of each block and takes the layer id l as the additional input.
The hyper-network module consists of linear layers to get embeddings for each modality, a 2D convolutional module Conv to get a shared task-specific encoding z ∈ R H · d z , where H is the demonstration length, and a set of linear layers to get adapter parameters.
Formally, let the weights of linear embedding layers be L s ∈ R d s × d h , L ˆ r ∈ R 1 × d h , L t ∈ R 1 × d h , L l ∈ R 1 × d h for the state, rewards-to-go, timesteps, and layer id, respectively.
Similar to timesteps representing temporal positions, the layer id represents positional information of decoder blocks.
Hence, we add layer i
d embedding to state, action, and reward-to-go tokens.
There are four types of parameter-generation layers with weights, L D ∈ R d x d h × d z for down-projection layers, L U ∈ R d x d h × d z for up-projection layers, and L γ ∈ R d x × d z , L β ∈ R d x × d z for FiLM layers.
Formally, the hyper-network conducts the following operations.
[Equation]
: ψ ← ψ − α ψ ∇ ψ 1 |B| (cid:80) [Table] , where a refers to actions in τ m [Table]
DT Pre-training.
We first pre-train a DT model with datasets across multiple tasks.
We assume that the datasets do not contain trajectories collected in testing tasks.
We defer the detailed training algorithm in the appendix as in Algorithm 3.
Training Hyper-network.
We train the hyper-networks as shown in Algorithm 1.
For notation simplicity, we denote hyper-network parameters as ϕ .
During hyper-network training, the pre-trained transformer agent’s parameters are frozen.
HDT only updates hyper-network parameters ϕ to make sure the hyper-network copes with the pre-trained agent as well as extracts meaningful task-specific information from demonstrations
h o .
To stabilize training, each gradient update of ϕ is based on a large batch containing trajectory segments in each task.
Following Chen et al.
(2021), we minimize the mean-squared error loss between action predictions and targets.
Fine-tuning on Unseen Tasks.
When fine-tuning in unseen target tasks, HDT first initializes adapter parameters (denoted as ψ ) with the pre-trained hyper-network and then only updates the adapter parameters.
When there only exist demonstrations without actions
h o in the target task ( meta-LfO ),
HDT initializes an empty data buffer and collects online rollouts with ϵ -greedy as in Algorithm 2.
Following Zheng et al.
(2022), we relabel the rewards-to-go of the collected trajectories.
HDT updates adapters with the same mean-squared error loss as training hyper-networks.
When there exist expert actions in the demonstration ( meta-IL ), HDT could omit the online rollout and directly fine-tune the adapter with the expert actions following Algorithm 4 in appendix Section A.
E XPERIMENTAL S ETUP
We conduct extensive experiments to answer the following questions:
• Does HDT adapt to unseen tasks while maintaining parameter and data efficiency?
• How is HDT compared with other prompt-fine-tuning and parameter-efficient fine-tuning methods in the field of policy learning?
• Does the hyper-network successfully encode task-specific information across tasks?
• Does HDT’s adaptivity scale with training tasks’ diversity, the base DT policy’s model size, and the bottleneck dimension?
4. E NVIRONMENTS AND O FFLINE D ATASETS
The Meta-World benchmark (Yu et al., 2020) contains table-top manipulation tasks requiring a
Sawyer robot to interact with various objects.
With different objects, such as a drawer and a window, the robot needs to manipulate them based on the object’s affordance, leading to different reward functions.
At each timestep, the Sawyer robot receives a 4-dimensional fine-grind action, representing the 3D position movements of the end effector and the variation of gripper openness.
We use a training set containing 43 tasks for pre-training DT and hyper-networks.
The testing set consists of 5 tasks involving unseen objects or seen objects but with different reward functions.
For each training task, we collect an offline dataset containing 1000 episodes with the rule-based script policy provided in Yu et al.
and increase the data randomness by adding random noise to action commands.
For each testing task, we collect one demonstration trajectory with the script policy.
Note that the expert rule-based script policy is tailored to each task and has an average success rate of about 1.0 for each task in the training and testing sets.
We set the episode length as 200.
Each episode contains states, actions, and dense rewards at each timestep.
4. B ASELINES
We compare our proposed HDT with six baselines to answer the questions above.
For each method, we measure the task performance in terms of the success rate in each testing task, the parameter efficiency according to the number of fine-tuned parameters during adaptation, and the data efficiency based on the top-2 number of online rollout episodes until a success episode.
All methods except for
SiMPL utilize a base DT model with size [512 , 4 , 8] , which are the embedding dimension, number of blocks, and number of heads, respectively.
• PDT.
Prompt Decision Transformer (PDT) (Xu et al., 2022) generates actions based on both the recent context and pre-collected demonstrations in the target task.
To ensure a fair comparison, we omit the actions in the demonstration when training PDT with T train .
During fine-tuning, we conduct prompt-tuning by updating the demonstration with the Adam optimizer.
PDT helps reveal the difference between parameter-efficient tuning and prompt-tuning in policy learning.
• DT.
We fine-tune the whole model parameters of the pre-trained DT model during online adaptation.
DT helps show the data- and parameter-efficiency of HDT.
• HDT-IA3.
To show the effectiveness of the adapter layer in policy learning, we implement another parameter-efficient fine-tuning method, HDT-IA3, motivated by Liu et al.
HDTIA3 insert weights to rescale the keys and values in self-attention and feed-forward layers.
Both HDT-IA3 and HDT do not utilize position-wise rescaling.
In other words, HDT-IA3 trains hypernetwork to generate rescaling weights shared by all positions in each block.
During fine-tuning, only the rescaling weights are updated.
We detail HDT-IA3’s structure in Section A.3.
• SiMPL.
Skill-based Meta RL (SiMPL) (Nam et al., 2022) follows SPiRL’s setting (Pertsch et al., 2020) and uses online rollouts with RL to fine-tune on downstream unseen tasks.
We pick this additional baseline for the meta-LfO, since this setting can be thought of as meta-RL with observations.
We aim to show the improvements when having access to expert observations.
• HDT-Rand.
To reveal the effect of the adapter initialization with pre-trained hyper-networks, we compare HDT with HDT-Rand, which randomly initializes adapter parameters during fine-tuning.
HDT-Rand only updates the adapter parameters similar to HDT.
• HDT-TrainOnce.
HDT-TrainOnce train the base DT model together with the hyper-network.
It helps reveal the effect of training hyper-network alone.
R ESULTS AND D ISCUSSIONS 5. D OES HDT GENERALIZE TO UNSEEN TASKS WITH PARAMETER AND DATA EFFICIENCY ?
When fine-tuning in unseen tasks with demonstrations containing no expert actions, HDT achieves significantly better performance than baselines in terms of success rate, parameter efficiency (Table 1), and rollout data efficiency (Table 2).
Success Rate.
Without fine-tuning, HDT could only achieve a success rate of around 0.2 in testing tasks.
In the meta-LfO setting, after collecting a handful of episodes in each task, HDT demonstrates a significant improvement to a success rate of around 0.8, as shown in Table 1. In the door-lock [Table]
and door-unlock tasks, where the object already shows up in the training tasks, HDT could fully solve the tasks.
In more challenging tasks where there exist unseen objects, including bin-picking, box-close [Table] and hand-insert, HDT still outperforms baselines by a large margin, as in Table 2 and
Figure 3.
SiMPL, without utilizing the demonstrations, could achieve performance improvements while still underperforming our proposed HDT.
Such observations show the benefit of leveraging prior information from demonstrations.
Parameter Efficiency.
In meta-LfO, fine-tuning the whole parameters of the base DT model (denoted as DT) comes third in terms of the average success rate (Figure 3 (c)).
However, it requires a significantly larger amount of computation budget to fine-tune 13M parameters compared with our proposed HDT, which fine-tunes 69K parameters (0.05% of 13M) as in Table 1.
In the simpler setting with expert actions (meta-IL), all baselines require no online rollouts and update with expert actions.
In this case, HDT converges faster than fine-tuning DT as in Figure 3 (b).
Data Efficiency.
In meta-LfO, we set the online rollout budget as 4000 episodes.
As in Table 2,
HDT could sample a successful episode in around 20 to 80 episodes, much smaller than the number of episodes required by baselines.
Such a comparison shows that the adapter module initialized by the pre-trained hyper-network helps guide the exploration during online rollouts.
5. A DAPTER LAYERS V . S . OTHER EFFICIENT FINE - TUNING METHODS IN POLICY LEARNING
Prompt-tuning and parameter-efficient fine-tuning are two popular paradigms in tuning pre-trained large language models Liu et al.
We are interested in the effectiveness of methods in both regimes when tuning pre-trained transformer agents.
We treat PDT as the representative prompttuning baseline and HDT-IA3 as another baseline in the regime of parameter-efficient fine-tuning.
We show that HDT outperforms both in terms of adaptation performances in both meta-IL and metaLfO settings.
Although PDT could sample successful episodes quickly during online adaptation (Table 2), purely updating the prompt input hardly improves success rates.
We observe similar trends when fine-tuning with expert actions (Figure 3 (b)).
HDT-IA3 could sample success episodes but require a larger number of rollouts than PDT and HDT.
As in Figure 3 (c), fine-tuning HDT-IA could result in success rate improvements, which is much less than our proposed HDT.
5. D OES THE HYPER - NETWORK ENCODE TASK - SPECIFIC INFORMATION ?
HDT relies on the hyper-network to extract task-specific information and utilizes the information by generating the adapter’s parameters.
We hope to investigate whether the hyper-network encodes meaningful task-specific details.
We visualize the adapter’s parameters initialized by the hypernetwork for each task in Figure 8. The detailed visualization process is deferred to Section B.4.
[Table] [Figure] Figure 8 shows that the adapters’ parameters for different tasks could be distinguished from each other, showing that the hyper-network indeed extracts task-specific information.
To support the argument, we further visualize the environment rollouts in the 5 testing tasks in Section B.3.
Compared with HDT-Rand, which randomly initializes adapter layers, HDT has much better adaptation performance with a higher success rate and strong data efficiency (Table 2 and Figure 4).
5. D OES HDT’ S PERFORMANCE SCALE WITH TRAINING TASKS AND MODEL SIZES ?
Lee et al.
(2022) show that the data diversity and model size are crucial when training large transformer-based models in the multi-game setting.
We hope to understand whether similar trends show up when training HDT.
The ablation results are summarized in Table 2 and Figure 4.
To understand the effect of training task diversity , we compare HDT with HDT-small-train, which trains the hyper-network and the base DT model with 10 training tasks.
In meta-LfO, HDT-small-train could not sample successful episodes in 3 out of 5 testing tasks and underperforms HDT in terms of success rates.
Such results show the importance of training task diversity.
It is worth noting that with a smaller DT model size , the transformer agent could hardly sample successful episodes in meta-LfO and thus no improvements during online adaptation (Figure 4 (d)).
The performances also drop with smaller hidden sizes of the adapter layers .
With expert actions in meta-IL, smaller DT model size and bottleneck dimension lead to slower convergence.
C ONCLUSION
We propose Hyper-Decision Transformer (HDT), a transformer-based agent that generalizes to unseen novel tasks with strong data and parameter efficiency.
HDT fine-tunes the adapter layers introduced to each transformer block during fine-tuning, which only occupies 0 .
5% parameters of the pre-trained transformer agent.
We show that in the Meta-World benchmark containing fine-grind manipulation tasks, HDT converges faster than fine-tuning the overall transformer agent with expert actions.
Moreover, HDT demonstrates strong data efficiency by initializing adapter layers’ parameters with a hyper-network pre-trained with diverse tasks.
When expert actions are unavailable,
HDT outperforms baselines by a large margin in terms of success rates.
We attribute the strong performance to good initializations of the adapter layers, which help HDT achieve successful online rollouts quickly.
We hope that this work will motivate future research on how to optimally finetune large transformer models to solve downstream novel tasks.
Interesting future directions include scaling HDT up to handle embodied AI tasks with high-dimensional egocentric image inputs.
A A DDITIONAL A LGORITHM D ESCRIPTIONS
We present the algorithms for pre-training DT models in Section A.1, efficient adaptation of HDT when there exist expert actions in Section A.2, the model architecture of HDT-IA3 in Section A.3.
A. DT PRE - TRAINING
We pre-train a base DT model with large offline datasets collected from training tasks.
Each gradient update of the DT model considers information from each training task.
1: Input: training tasks T train , training task size T train =
| T train | , DT θ , training iterations N , offline dataset D , demonstrations P , per-task batch size M , learning rate α θ 2: for n = 1 to N do 3: for Each task T i ∈ T train do 4:
Sample M trajectory τ i of length K from D i 5:
Get a minibatch B Mi
= { τ i,m ) }
Mm = 6:
Get a batch B =
{B Mi } T train i = 7: a pred =
DT θ
( τ i,m ) , ∀ ( τ i,m )
∈ B 8:
L MSE = 1 |B| (cid:80) h input ∈B ( a − a pred )9: θ ← θ − α θ ∇ θ L MSE
A.
E FFICIENT A DAPTION WITH EXPERT ACTIONS ( META -IL)
With expert actions, the transformer model does not need to conduct online rollouts and updates by fine-tuning with the expert actions.
Sample M m
6: a
HDT ψ ( h o , τ m ) , ∀ ( h oi , τ m ) ∈ B 7:
ψ ←
[Equation]
oi
[Equation]
pred
[Equation]
A. HDT-IA
We show the model architecture of HDT-IA3 in Figure 5.
Compared with our proposed HDT, HDTIA3 has a hyper-network that takes the same encoding of demonstrations as HDT but outputs IA  parameters instead.
The parameter efficient fine-tuning method, IA3, proposed by (Liu et al., 2022), adds position-wise scaling weights to the self-attention and activations between feedforward layers.
Considering that the transformer block in DT only contains one feedforward layer, we rescale the outputs of the feedforward layer instead.
Moreover, to make a fair comparison, we use one set of
IA3 parameters for all positions, similar to the position-agnostic rescaling of HDT.
Formally, the IA3 parameters include l k ∈ R d x , l v ∈ R d x , l ff ∈ R d x .
The key K and the value v of the self-attention module are rescaled by l k and l v , respectively.
The feedforward output is rescaled by l ff .
A. M ODEL SIZES
In this section
[Table]
we describe the model size of different methods to help compare parameter efficiency.
[Table] [Table]
[Table]
B A DDITIONAL RESULTS IN M ETA -W ORLD BENCHMARK B. T ESTING P ERFORMANCES
We provide the quantitative per-task results in the 5 testing tasks in Table 6 and Table 7.
More concretely, Table 6 shows the results for HDT with different base DT model sizes and adapter hidden sizes when there exist no expert actions.
Table 7 shows the results for all methods when the expert actions are available
[Table] [Table] [Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
B. T RAINING P ERFORMANCES
To better review the effect of model sizes, we show the training performance of different methods in Figure 6.
With larger model sizes, the base model’s performance improves significantly.
The training performance decreases with smaller adapter layers’ bottleneck size and smaller base DT model size
. B. T HE EFFECT OF HYPER - NETWORKS THROUGH ENVIRONMENT V ISUALIZATION
We aim to show the quality of the adapter’s parameter initialization by visualizing the environment rollouts.
The comparisons between our proposed HDT and the baseline HDT-Rand show that initializing the adapter layer with hyper-networks provides a strong prior helping guide online exploration. B. T -SNE VISUALIZATION OF ADAPTERS ’ PARAMETERS INITIALIZED BY THE HYPER - NETWORK
To show whether the hyper-network extract task-specific information, we visualize the adapters’ parameters initialized by the hyper-network in Figure 8.
For each task, we randomly sample 100 expert demonstrations without actions, which serves as input to the hyper-network, and collect 100 samples of the adapters’ parameters as the output of the hyper-network.
Considering that the adapters contain around 69k parameters which form a high-dimensional vector, we first reduce the dimension to 1000 via principle component analysis (PCA).
We then project the PCA results to a 2-dimensional space using t-Distributed Stochastic Neighbor Embedding (t-SNE). We use sklearn to conduct PCA and t-SNE. We change the perplexity to 10, considering that we use a relatively small number of samples. All the other hyperparameters except the perplexity are the same as the default parameters
In Figure
[Table]
we show the transformed 2D features for both the training and testing tasks.
The training tasks are labeled with black text and circle markers.
The testing tasks are labeled with red text and cross markers.
We can see that the adapters’ parameters for different tasks could be distinguished from each other, showing that the hyper-network indeed extracts task-specific information.
B. A DDITIONAL E XPERIMENTS ON M ETA -W ORLD WITH 45 TRAINING TASKS
We train HDT and baselines on the 45 training tasks of the Meta-World ML45 benchmark.
Note that the original training set with 43 training tasks is a subset of ML45’s training set.
Our original testing tasks are identical to the testing task in ML45 benchmark.
The main results are in Figure 9 and
Table 8.
We can see that in the meta-IL setting, HDT converges faster than updating the whole DT model’s parameter (DT).
In the meta-LfO setting, HDT achieves a higher asymptotic performance than baselines.
The main claims presented in the main text remain valid, including that HDT-IA and PDT are hard to finetune.
[Table]
B. A DDITIONAL BASELINES ON M ETA -W ORLD WITH 45 TRAINING TASKS
We train baselines on the 45 training tasks of the Meta-World ML45 benchmark.
We implement
CQL Kumar et al.
(2020), IQL Kostrikov et al.
(2021), BC and TD3BC Fujimoto & Gu (2021)
based on the d3rlpy package Takuma Seno (2021).
The main results are in Figure 10.
Note that
CQL and IQL do not incorporate offline demonstrations when interacting with the environments.
Thus it is expected that CQL and IQL would perform worse than our proposed HDT.
From Figure 10 and Table we can see that in the meta-IL setting
BC and IQL could have performance improvement but still underperform HDT.
In the meta-LfO setting
CQL and IQL are trained in an online manner and underperform HDT.
It is also worth noting that all four baselines here will suffer from the forgetting problem since all the model parameters are modified.
[Table]
B. A DDITIONAL E XPERIMENTS ON D4RL POINTMAZE ENVIRONMENTS
We hope to show the performance of HDT in another domain beyond manipulation tasks and thus add another set of locomotion tasks based on D4RL’s pointmaze environment Fu et al.
We train all the methods with 50 training tasks and test in 10 testing tasks.
The detailed description of the environment and tasks are deferred to Section C.2.
The main results for the pointmaze environment are in Figure 11 and Table 10.
We can see that
HDT still outperforms baselines in terms of adaptation capability to unseen tasks in both meta-IL and meta-LfO settings.
The results in the navigation domain help validate the main results presented in the original submission.
[Table]
C E NVIRONMENT D ETAILS C. M ETA -W ORLD E XPERIMENTS C.1. S UCCESS C RITERION
We utilize the success signal feedback from the environment to calculate the success score, which is the sum of the success signals within one episode.
To avoid false positive success identifications, we define a successful episode if the success score is larger than 5 and the total episode return is larger than 300.
C.1. T RAINING AND T ESTING TASKS FOR EXPERIMENTS IN THE MAIN TEXT
We list the 43 training tasks as follows.
Note that our training tasks is a subset of the original ML benchmark in the Meta-World.
• assembly-v • basketball-v • button-press-topdown-v • button-press-topdown-wall-v • button-press-v • button-press-wall-v • coffee-button-v • coffee-pull-v • coffee-push-v • dial-turn-v • disassemble-v • door-close-v • door-open-v • drawer-close-v • drawer-open-v • faucet-open-v • faucet-close-v • hammer-v • handle-press-side-v • handle-press-v
• handle-pull-side-v • lever-pull-v • peg-insert-side-v • pick-place-wall-v • reach-v • push-back-v • push-v • pick-place-v • plate-slide-v • plate-slide-side-v • plate-slide-back-v • plate-slide-back-side-v • peg-unplug-side-v • soccer-v • stick-push-v • stick-pull-v • push-wall-v • reach-wall-v • shelf-place-v • sweep-into-v • sweep-v • window-open-v • window-close-v
We list the 10 training tasks for HDT-small-train as follows.
Note that our training tasks is the same as the original ML10 benchmark in the Meta-World.
• basketball-v • button-press-v • dial-turn-v • drawer-close-v • peg-insert-side-v • pick-place-v • push-v • reach-v • sweep-into-v • window-open-v
We list the 5 testing tasks as follows.
Note that our testing tasks is the same as the original ML benchmark in the Meta-World.
• bin-picking-v • box-close-v • door-lock-v • door-unlock-v • hand-insert-v C. P OINTMAZE E XPERIMENTS C.2. D ATA G ENERATION
For each task in the training set, we use the expert rule-based controller provided in the D4RL package to generate 100 episodes.
We use the medium-maze as the maze layout.
For each testing task, we also use the expert controller provided but only generate one episode.
C.2. S UCCESS C RITERION
To avoid false positive success identifications, we define a successful episode if the accumulated sparse reward is larger than 5.
C.2. T RAINING AND T ESTING TASKS
Each task corresponds to different start and goal positions.
The list of 50 training tasks:
• Task index: 0, start: [3,3], goal: [1,1] • Task index: 1, start: [3,3], goal: [1,2] • Task index: 2, start: [3,3], goal: [1,5] • Task index: 3, start: [3,3], goal: [1,6] • Task index: 4, start: [3,3], goal: [2,1] • Task index: 5, start: [3,3], goal: [2,2] • Task index: 6, start: [3,3], goal: [2,4] • Task index: 7, start: [3,3], goal: [2,5] • Task index: 8, start: [3,3], goal: [2,6] • Task index: 9, start: [3,3], goal: [3,2] • Task index: 10, start: [3,3], goal: [3,4] • Task index: 11, start: [3,3], goal: [4,1] • Task index: 12, start: [3,3], goal: [4,2] • Task index: 13, start: [3,3], goal: [4,4] • Task index: 14, start: [3,3], goal: [4,5] • Task index: 15, start: [3,3], goal: [4,6] • Task index: 16, start: [3,3], goal: [5,1] • Task index: 17, start: [3,3], goal: [5,3] • Task index: 18, start: [3,3], goal: [5,4] • Task index: 19, start: [3,3], goal: [5,6] • Task index: 20, start: [3,3], goal: [6,1] • Task index: 21, start: [3,3], goal: [6,2] • Task index: 22, start: [3,3], goal: [6,3] • Task index: 23, start: [3,3], goal: [6,5] • Task index: 24, start: [3,3], goal: [6,6] • Task index: 25, start: [4,4], goal: [1,1] • Task index: 26, start: [4,4], goal: [1,2] • Task index: 27, start: [4,4], goal: [1,5] • Task index: 28, start: [4,4], goal: [1,6] • Task index: 29, start: [4,4], goal: [2,1] • Task index: 30, start: [4,4], goal: [2,2] • Task index: 31, start: [4,4], goal: [2,4] • Task index: 32, start: [4,4], goal: [2,5] • Task index: 33, start: [4,4], goal: [2,6] • Task index: 34, start: [4,4], goal: [3,2] • Task index: 35, start: [4,4], goal: [3,3] • Task index: 36, start: [4,4], goal: [3,4] • Task index: 37, start: [4,4], goal: [4,1] • Task index: 38, start: [4,4], goal: [4,2] • Task index: 39, start: [4,4], goal: [4,5] • Task index: 40, start: [4,4], goal: [4,6] • Task index: 41, start: [4,4], goal: [5,1] • Task index: 42, start: [4,4], goal: [5,3] • Task index: 43, start: [4,4], goal: [5,4] • Task index: 44, start: [4,4], goal: [5,6] • Task index: 45, start: [4,4], goal: [6,1] • Task index: 46, start: [4,4], goal: [6,2] • Task index: 47, start: [4,4], goal: [6,3] • Task index: 48, start: [4,4], goal: [6,5] • Task index: 49, start: [4,4], goal: [6,6]
The list of 10 testing tasks:
• Task index: 50, start: [3,2], goal: [1,1] • Task index: 51, start: [3,2], goal: [4,4] • Task index: 52, start: [3,2], goal: [2,5] • Task index: 53, start: [3,4], goal: [4,6] • Task index: 54, start: [3,4], goal: [1,6] • Task index: 55, start: [3,4], goal: [2,2] • Task index: 56, start: [4,5], goal: [6,5] • Task index: 57, start: [4,5], goal: [3,2] • Task index: 58, start: [4,5], goal: [5,3] • Task index: 59, start: [5,4], goal: [3,2]