Hierarchical Few-Shot Imitation with Skill Transition Models
Abstract
A desirable property of autonomous agents is the ability to both solve long-horizon problems and generalize to unseen tasks.
Recent advances in data-driven skill learning have shown that extracting behavioral priors from ofﬂine data can enable agents to solve challenging long-horizon tasks with reinforcement learning.
However, generalization to tasks unseen during behavioral prior training remains an outstanding challenge.
To this end, we present Few-shot Imitation with Skill Transition Models (FIST), an algorithm that extracts skills from ofﬂine data and utilizes them to generalize to unseen tasks given a few downstream demonstrations.
FIST learns an inverse skill dynamics model, a distance function, and utilizes a semi-parametric approach for imitation.
We show that FIST is capable of generalizing to new tasks and substantially outperforms prior baselines in navigation experiments requiring traversing unseen parts of a large maze and 7-DoF robotic arm experiments requiring manipulating previously unseen objects in a kitchen.
1. Introduction
We are interested in developing control algorithms that enable robots to solve complex and practical tasks such as operating kitchens or assisting humans with everyday chores at home.
There are two general characteristics of real-world tasks – long-horizon planning and generalizability.
Practical tasks are often long-horizon in the sense that they require a robot to complete a sequence of subtasks.
For example, to cook a meal a robot might need to prepare ingredients, place them in a pot and operate the stove before the full meal is ready.
Additionally, in the real world many tasks we wish our robot to solve may differ from tasks the robot has completed in the past but require a similar skillset.
For example, if a robot learned to open the top cabinet drawer it should be able to quickly adapt that skill to open the bottom cabinet drawer.
These considerations motivate our research question: how can we learn skills that enable robots to generalize to new long-horizon downstream tasks?
Recently, learning data-driven behavioral priors has become a promising approach to solving long-horizon tasks.
Given a large unlabeled ofﬂine dataset of robotic demonstrations solving a diverse set of tasks this family of approaches (Singh et al., 2021; Pertsch et al., 2020; Ajay et al., 2021) extract behavioral priors by ﬁtting maximum likelihood expectation latent variable models to the ofﬂine dataset.
The behavioral priors are then used to guide a Reinforcement
Learning (RL) algorithm to solve downstream tasks.
By selecting skills from the behavioral prior, the RL algorithm is able to explore in a structured manner and can solve longhorizon navigation and manipulation tasks.
However, the generalization capabilities of RL with behavioral priors are limited since a different RL algorithm needs to be trained for each downstream task and training each RL algorithm often requires millions of environment interactions.
On the other hand, few-shot imitation learning has been a promising paradigm for generalization.
In the few-shot imitation learning setting, an imitation learning policy is trained on an ofﬂine dataset of demonstrations and is then adapted in few-shot to a downstream task (Duan et al., 2017).
Fewshot imitation learning has the added advantage over RL in that it is often easier for a human to provide a handful of demonstrations than it is to engineer a new reward function for a downstream task.
However, unlike RL with behavioral priors, few-shot imitation learning is most often limited to short-horizon problems.
The reason is that imitation learning policies quickly drift away from the demonstrations due to error accumulation (Ross et al., 2011b), and especially so in the few-shot setting when only a handful of demonstrations are provided.
While it is tempting to simply combine data-driven behavioral priors with few-shot imitation learning, it is not obvious how to do so since the two approaches are somewhat orthogonal.
Behavioral priors are trained on highly multimodal datasets such that a given state can correspond to multiple skills.
Given a sufﬁciently large dataset of demonstrations for the downstream task the imitation learning algorithm will learn to select the correct mode.
However, in the few-shot setting how do we ensure that during training
[Figure]
on downstream data we choose the right skill?
Additionally, due to the small sample size and long task horizon it is highly likely that a naive imitation learning policy will drift from the few-shot demonstrations.
How do we prevent the imitation learning policy from drifting away from downstream demonstrations?
The focus of our work is the setup illustrated in Figure 1; we introduce Few-Shot Imitation Learning with Skill Transition Models (FIST), a new algorithm for few-shot imitation learning with skills that enables generalization to unseen but semantically similar long-horizon tasks to those seen during training.
Our approach addresses the issues with skill selection and drifting in the few-shot setting with two main components.
First, we introduce an inverse skill dynamics model that conditions the behavioral prior not only on the current state but also on a future state, which helps FIST learn uni-modal future conditioned skill distribution that can then be utilized in few-shot.
The inverse skill model is then used as a policy to select skills that will take the agent to the desired future state.
Second, we train a distance function to ﬁnd the state for conditioning the inverse skill model during evaluation.
By ﬁnding states along the downstream demonstrations that are closest to the current state, FIST prevents the imitation learning policy from drifting.
We show that our method results in policies that are able to generalize to new long-horizon downstream tasks in navigation environments and multi-step robotic manipulation tasks in a kitchen environment.
To summarize, we list our three main contributions:
We introduce FIST - an imitation learning algorithm that learns an inverse skill dynamics model and a distance function that is used for semi-parametric fewshot imitation.
We show that FIST can solve
long-horizon tasks in both navigation and robotic manipulation settings that were unseen during training and outperforms previous behavioral prior and imitation learning baselines.
We provide insight into how different parts of the FIST algorithm contribute to ﬁnal performance by ablating different components of our method such as future conditioning and ﬁne-tuning on downstream data.
2. Related Work
Our approach combines ingredients from imitation learning and skill extraction to produce policies that can solve long-horizon tasks and generalize to tasks that are out of distribution but semantically similar to those encountered in the training set.
We cover the most closely related work in imitation learning, skill extraction, and few-shot generalization.
Imitation Learning : Imitation learning is a supervised learning problem where an agent extracts a policy from a dataset of demonstrations.
The two most common approaches to imitation are Behavior Cloning (Pomerleau, 1988;
Ross et al., 2011a) and Inverse Reinforcement Learning (IRL) (Ng & Russell, 2000).
BC approaches learn policies π θ ( a | s ) that most closely match the state-conditioned action distribution of the demonstration data.
IRL approaches learn a reward function from the demonstration data assuming that the demonstrations are near-optimal for a desired task and utilize Reinforcement Learning to produce policies that maximize the reward.
For simplicity and to avoid learning a reward function, in this work we aim to learn generalizable skills and using the BC approach.
However, two drawbacks of BC are that the imitation policies require a large number of demonstrations and are prone to drifting away from the demonstration distribution during evaluation due to error accumulation (Ross et al., 2011b).
For this reason, BC policies work best when the time-horizon of the task is short.
Skill Extraction with Behavioral Priors : Methods that leverage behavioral priors utilize ofﬂine datasets of demonstrations to bias a policy towards the most likely skills in the datasets.
While related closely to imitation learning, behavioral priors have been mostly applied to improve Reinforcement Learning.
Behavioral priors learned through maximum likelihood latent variable models have been used for structured exploration in RL (Singh et al., 2021), to solve complex long-horizon tasks from sparse rewards (Pertsch et al., 2020), and regularize ofﬂine RL policies (Wu et al., 2019; Peng et al., 2019; Nair et al., 2020).
While impressive,
RL with data-driven behavioral priors does not generalize to new tasks efﬁciently, often requiring millions environment interactions to converge at an optimal policy for a new task.
Few-Shot Learning : Few-shot learning (Wang et al., 2020) has been studied in the context of image recognition (Vinyals et al., 2016;
Koch et al., 2015), reinforcement learning (Duan et al., 2016), and imitation learning (Duan et al., 2017).
In the context of reinforcement and imitation learning, few-shot learning is often cast as a meta-learning problem (Finn et al., 2017; Duan et al., 2016; 2017).
However, there are other means of attaining few-shot generalization that do not require meta-learning.
Recently, advances in unsupervised representation learning in natural language processing (Radford et al., 2019; Brown et al., 2020) and vision (He et al., 2020; Chen et al., 2020) have shown how a network pre-trained with a self-supervised objective can be ﬁnetuned or adjusted with a linear probe to generalize in few-shot or even zero-shot (Radford et al., 2021) to a downstream task.
Our approach to few-shot imitation learning is loosely inspired by the generalization capabilities of networks pre-trained with unsupervised objectives.
Our approach ﬁrst ﬁts a behavioral prior to an ofﬂine dataset of demonstrations to extract skills and then ﬁts an imitation learning policy over the previously acquired skills to generalize in few-shot to new tasks.
FIST is therefore a hierarchical few-shot imitation learning algorithm.
3. Approach 3.1. Problem Formulation
Few-shot Imitation Learning : We denote a demonstration as a sequence of states and actions: τ = { s 1 , a 1 , s 2 , a 2 , . . .
, s T , a T } .
In a few-shot setting we assume access to a small dataset of
M such expert demonstrations D demo = { τ i } i = M i =1 that fulﬁll a speciﬁc long horizon task in the environment.
For instance a sequence of sub-tasks in a kitchen environment such as moving the kettle, turning on the burner and opening a cabinet door.
The goal is to imitate this behavior to automate the task using only a few example trajectories available.
Skill Extraction : In this work we assume access to an unlabeled ofﬂine dataset of prior agent interactions with the environment in the form of N un-directed trajectories { τ i =
{ ( s t , a t ) } t =
T i t =1 } i
= N
i =1 .
We further assume that these trajectories include semantically meaningful skills that are composable to execute long horizon tasks in the environment.
This data can be collected from past tasks that have been attempted, or be provided by human-experts through teleoperation (Zhang et al., 2018).
Skill extraction refers to an unsupervised learning approach that utilizes this undirected dataset to learn a skill policy in form of π θ ( a | s, z ) where a is action, s is the current state, and z is the skill.
Our hypothesis is that by combining these skill primitives we can solve semantically similar longhorizon tasks that have not directly been seen during the training.
In this work we propose a new architecture for skill extraction based on continuous latent variable models that enables a semi-parametric evaluation procedure for few-shot imitation learning.
3.2. Hierarchical Few-Shot Imitation with Skill Transition Models
Our method, shown in Fig. 2, has three components: (i) Skill extraction, (ii) Skill adaptation via ﬁne-tuning on few-shot data, and (iii) Evaluating the skills using a semi-parametric approach to enable few-shot imitation.
(i) Skill Extraction from Ofﬂine Data: We deﬁne a continuous skill
z i ∈ Z as an embedding for a sequence of stateaction pairs { s t , a t , . .
, s t
+ H − 1 , a t + H − 1 } with a ﬁxed length H. This temporal abstraction of skills has proven to be useful in prior work (Pertsch et al., 2020;
Ajay et al., 2021), by allowing a hierarchical decomposition of skills to achieve long horizon downstream tasks.
To learn the latent space Z we propose training a continuous latent variable model with the encoder as q φ ( z | s t , a t , . . .
, s t
+ H − 1 , a t + H − 1 ) and the decoder as π θ ( a | s, z ) .
The encoder outputs a distribution over the latent variable z that best explains the variation in the state-action pairs in the sub-trajectory.
The encoder is an LSTM that takes in the sub-trajectory of length H and outputs the parameters of a Gaussian distribution as the variational approximation over the true posterior p ( z | s t , a t , . . .
, s t
+ H − 1 , a t + H − 1 ) .
The decoder is a policy that maximizes the log-likelihood of actions of the subtrajectory conditioned on the current state and the skill.
We implement the decoder as a feed-forward network which takes in the current state s t and the latent vector z and regresses the action vector directly.
This architecture resembles prior works on skill extraction (Pertsch et al., 2020).
To learn parameters φ and θ , we randomly sample batches of H -step continuous sub-trajectories from the training data
D and maximize the evidence lower bound (ELBO):
[Equation]
] where the posterior q φ ( z | τ ) is regularized by its KullbackLeibler (KL) divergence from a unit Gaussian prior p ( z ) =
N (0 , I ) and β is a parameter that tunes the regularization term.
To enable quick few shot adaptation over skills we learn an inverse skill dynamics model q ψ ( z | s t , s t + H − 1 ) that infers which skills should be used given the current state and a future state that is H steps away.
To train the inverse skill dynamics model we minimize the KL divergence between the approximated skill posterior q φ ( z | τ ) and the output of the state conditioned skill prior.
This will result in minimizing the following loss with respect to the parameters ψ :
[Equation]
We use a reverse KL divergence to ensure that our inverse dynamics model has a broader distribution than the approximate posterior to ensure mode coverage (Bishop, 2006).
In our implementation we use a feed-forward network that takes in the concatenation of the current and future state and outputs the parameters of a Gaussian distribution over z .
Conditioning on the future enables us to make a more informative decision on what skills to execute which is a key enabler to few-shot imitation.
We jointly optimize the skill extractions and inverse model with the following loss:
[Equation]
(ii) Skill Adaption via Fine-tuning on Downstream Data : To improve the consistency between the unseen downstream demonstrations and the prior over skills, we use the demonstrations to ﬁne-tune the parameters of the architecture by taking gradient steps over the loss in Equation 2.
In the experiments we ablate the performance of FIST with and without ﬁne-tuning to highlight the differences.
(iii) Semi-parametric Evaluation for Few-shot Imitation
Learning : To run the agent, we need to ﬁrst sample a skill [Table] z ∼ q [Table]
( z | s
[Table] , s ∗ t ) based on the current state and the future state that it seeks to reach. Then, we can use the low-level decoder π ( a t | z, s t ) to convert that sampled skill z and the current state s t to the corresponding action a t .
During evaluation we use the demonstrations D demo to decide which state to use as the future state to condition on.
For this purpose we use a learned distance function d ( s, s (cid:48) ) to measure the distance between the current state s t and every other state in the demonstrated trajectories.
Then, from the few-shot data we ﬁnd the closest state s ∗ t to the current state according to the distance metric:
[Equation]
[Equation]
where s ij is the j th state in the i th trajectory in D demo .
We then condition the inverse dynamics model on the current state s t and the state s ∗ (cid:48) t , H -steps ahead of s ∗ t within the trajectory that s ∗ t belongs to.
If by adding H steps we reach the end of the trajectory, we use the end state within the trajectory as the target future state.
The reason for this look-ahead adjustment is to ensure that the sampled skill always makes progress towards the future states of the demonstration.
After the execution of action a t according to the low-level decoder, the process is repeated until the fulﬁllment of the task.
The procedure is summarized in
Algorithm 1.
Inspired by prior work on contrastive learning for control (Srinivas et al., 2020; Stooke et al., 2021) and semiparametric control with distance functions (Savinov et al., 2018; Liu et al., 2020; Emmons et al., 2020)
we learn a distance metric by optimizing a contrastive loss such that states that are H steps in the future are close to the current state while all other states are far.
To train this contrastive encoder, we sample a batch of sub-trajectories of length H , { τ i } i
= B i =1 , and then for each trajectory τ i we use the last state s H ∈
τ i as the positive sample for the ﬁrst state s 1 ∈
τ i and the B − 1 last states from other trajectories within the batch s H ∈
τ j , ∀ j (cid:54) =
i as the negative samples for s 1 ∈ τ i .
Using a contrastive loss we will encourage the positive samples to attract and the negative samples to repel one another.
Then a euclidean distance on the encoded states can be used to measure the distance between two arbitrary states.
4. Experiments
In the experiments we are interested in answering the following questions: (i) Can our method successfully imitate unseen long-horizon downstream demonstrations?
(ii) Is the temporal abstraction obtained from skills necessary for imitating long-horizon trajectories?
(iii) Is pretraining and ﬁne-tuning the skill embedding model necessary for achieving high success rate?
(iv) Can our method also be used for robust one-shot imitation learning for in-distribution long-horizon tasks?
4.1. Environments
We evaluate the performance of FIST on two simulated navigation environments and a robotic manipulation task from the D4RL benchmark as shown in Figure 3.
To ensure generalizability to out-of-distribution tasks we remove some category of trajectories from the ofﬂine data.
At testtime, we see if the agent can generalize to those unseen trajectories.
PointMaze :
In this environment, the task is to navigate a point mass through a maze, from a start to a goal location.
The outline of the maze is shown in Figure 3.
We train the skills on three different datasets, each blocking one side of the maze.
To test the method’s ability to generalize to unseen long-horizon tasks, we use 10 expert demonstrations that start from random places in maze, but end at a goal within the blocked region.
This ensures that our demonstrated trajectories are out of distribution compared to training data.
We evaluate the performance by measuring the episode length and the success rate in reaching the demonstrated goals.
AntMaze : The task is to control a quadruped ant to run to different parts of the maze.
The layout of the maze is similar to PointMaze, and the same sides are blocked off.
The demonstrations are taken directly from the D4RL (Fu et al., 2020) dataset, by removing the trajectories passing through the blocked regions.
The expert downstream demonstrations are randomly sampled for each of the removed trajectories.
Similar to PointMaze we measure the episode length and success rate as our evaluation metric.
Kitchen : The task is to use a 7-DoF robotic arm to manipulate different parts of a kitchen environment in a speciﬁc order (e.g. open a microwave door or move the kettle).
During skill extraction we pre-process the ofﬂine data to exclude interactions with certain objects in the environment (e.g. we exclude interactions with the kettle).
However, for the demonstrations we pick four sub-tasks one of which includes the objects that were excluded from the skill dataset (e.g. if the kettle was excluded, we pick the task to be to open the microwave, move the kettle, turn the top burner, and slide the cabinet door).
In evaluation, for completion of each sub-task in the order consistent with the downstream demonstrations, the agent is awarded with a reward of 1.
for a total max reward of 4.0 per episode.
4.2. Results
We use the following approaches for comparison: BC+FT :
Trains a behavioral cloning agent (i.e. π θ ( a | s ) ) on the ofﬂine dataset D and ﬁne-tunes to the downstream dataset
D demo .
SPiRL :
This is an extension of the existing skill extraction methods to imitation learning over skill space (Ajay et al., 2021; Pertsch et al., 2020).
SPiRL (Pertsch et al., 2020) is very similar to our skill extraction method, but instead of conditioning the skill prior on the future state it only uses the current state.
We extract skills from D using
SPiRL, ﬁne-tune the module on the downstream demonstrations D demo , and then execute the skill prior for evaluation.
FIST (ours) :
This runs our semi-parametric approach after learning the future conditioned skill prior.
After extracting skills from D we ﬁne-tune the parameters on the downstream demonstrations D demo and perform the proposed semi-parametric approach for evaluation.
Our results are summarized in Table 1 and 2, and are also normalized in Figure 4 for easier comparison.
Each row in the tables indicates an experiment where a speciﬁc downstream task was excluded from the ofﬂine data D .
We provide a summary of our key ﬁndings:
(i)
In the
PointMaze
environment, FIST consistently succeeds in navigating the point mass into all three goal locations.
The skills learned by SPiRL fail to generalize when the point mass falls outside training distribution, causing it to get stuck in corners.
While BC+FT also solves the task frequently in the Left and Bottom goal location, the motion of the point mass is sub-optimal, resulting in longer completion times.
(ii)
In the AntMaze environment, FIST achieves the best performance compared to the baselines.
SPiRL and BC+FT make no progress in navigating the agent towards the goal while FIST is able to frequently reach the goals in the demonstrated trajectories.
We believe that the low success rate numbers in this experiment is due to the low quality of trajectories that exist in the ofﬂine skill dataset D .
In the dataset, we see many episodes with ant falling over, and FIST’s failure cases also demonstrate the same behavior, hence resulting in a low success rate.
We hypothesize that with a better skill dataset FIST will be able reach to a higher success rate number.
both baselines are unable to imitate the given demonstrations except for FIST.
(iii)
In the kitchen environment, we see that FIST signiﬁcantly outperforms SPiRL and BC+FT.
FIST can successfully complete 3 out of 4 long-horizon object manipulation tasks in this environment.
In one of these long-horizon tasks all algorithms perform similarly poor.
We believe that such behavior is due to the fact that ﬁne-tuning the agent on the given task may cause it to forget some part of previous skills (e.g. Sliding the cabinet door).
As future work, we plan to explore how different ﬁne-tuning mechanisms (e.g. gradual layer unfreezing) could help avoid forgetting of prior skills.
4.3. Ablation Studies
In this section we study different components of the FIST algorithm to provide insight on the contribution of each part.
[Table] [Table]
Imitation Learning over skills vs. atomic actions :
The
FIST algorithm is comprised of two coupled pieces that are both critical for robust performance: - the inverse dynamics model over skills and the non-parametric evaluation algorithm.
In this experiment we measure the inﬂuence of inverse skill dynamics model q ψ ( z | s t , s t + H − 1 ) .
An alternative baseline to learning skill dynamics model is to learn an inverse dynamics model on atomic actions q ψ ( a t
| s t , s t + H − 1 ) and perform goal-conditioned behavioral cloning (Goal-BC).
This model outputs the ﬁrst action a t required for transitioning from s t to s t + H − 1 over
H steps.
We can combine this model with FIST’s nonparametric module to determine the s t + H − 1 to condition on during evaluation of the policy.
As shown in Table 3, temporal abstraction obtained in learning an inverse skill dynamics model is a critical factor in the performance of
FIST.
[Table]
The effect of skill pre-training and ﬁne-tuning on FIST :
In order to adjust the skill-set to out-of-distribution tasks (e.g. moving the kettle while kettle is excluded from the skill dataset) FIST requires ﬁne-tuning on the downstream demonstrations.
We hypothesize that without ﬁne-tuning, the agent should be able to perfectly imitate the demonstrated sub-trajectories that it has seen during training, but should start drifting away when encountered with an out-ofdistribution skill.
We also hypothesise that pre-training on a large dataset, even if it does not include the downstream demonstration sub-trajectories, is crucial for the good performance seen on FIST.
Intuitively, pre-training provides a behavioral prior that is easier to adapt to unseen tasks than a random initialization.
To examine the impact of ﬁne-tuning, we compare
FIST with FIST-no-FT which directly evaluates the semiparameteric approach with the model parameters trained on the skill dataset without ﬁne-tuning on the downstream trajectories.
To understand the effect of pre-training, we compare FIST with FIST-no-pretrain which is not pre-trained on the skill dataset.
Instead, we directly train the latent variable and inverse skill dynamics model on the downstream data and perform the semi-parametric evaluation of the FIST algorithm.
From the results in Table 4, we observe that ﬁne-tuning is a critical component for out-of-distribution task.
The scores on FIST-no-FT suggests that the agent is capable of fulﬁlling the sub-tasks seen during skill training without ﬁne-tuning but cannot progress onto unseen tasks.
Based on the scores on FIST-no-pretrain , we also ﬁnd that the pretraining on a rich dataset, even when the downstream task is directly excluded, provides sufﬁcient prior knowledge about the dynamics of the environment and can immensely help with generalization to unseen tasks via ﬁne-tuning.
[Table]
One-shot Imitation Learning : The FIST algorithm can be directly evaluated on one-shot in-distribution downstream tasks without any ﬁne-tuning.
In this experiment, we want to see if the agent can pick up the right mode within its skillset with only one demonstration for fulﬁlling a long-horizon task in the kitchen environment.
The difference between this experiment and our main result is that the down-stream task is within the distribution of its pre-trained skill-set.
This is still a challenging task since the agent needs to correctly identify the desired mode of skills.
Our hypothesis is that in SPiRL, the skill prior is only conditioned on the current state and therefore is, by deﬁnition, a multi-modal distribution and would require more data to adapt to a speciﬁc long-horizon trajectory.
For instance, in the kitchen environment, after opening the microwave door, the interaction with any other objects in the environment is a possible choice of skills that can be invoked.
However, in
FIST, by conditioning the skill prior on the future states, we ﬁt a uni-modal distribution over skills.
In principle, there should be no need for ﬁne-tuning for invoking those skills within the distribution of the pre-trained skill set.
We compare our approach to SPiRL (Section 4.2) as a baseline.
In addition, we can provide supervision on which skills to invoke to fulﬁll the long-horizon task by ﬁne-tuning
SPiRL (hence SPiRL-FT ) for a few epochs on the downstream demonstration.
As summarized in Table 5, FIST, without any ﬁne-tuning, can fulﬁll all the long-horizon tasks listed with almost no drift from the expert demonstration.
We also see that it is tricky to ﬁne-tune SPiRL in a one-shot setting, as ﬁne-tuning only on one demonstration may cause over-ﬁtting and degradation of performance
[Table]
5. Broader Impacts and Limitations
[Table]
Limitations As with all imitation learning methods, the performance of FIST is related to the quality of the provided demonstrations.
Concretely, when the skill training demonstrations are poor, we expect the extracted skills to be also sub-optimal, thus, hurting downstream imitation performance.
To better understand this limitation, we analyze an extremely noisy versions of the PointMaze dataset and use it for skill extraction.
As shown in Table 6, despite achieving a high success rate, the episode length is substantially worse than FIST trained on expert data.
Learning structured skills from noisy ofﬂine data is an exciting direction for future research.
Broader Impacts The ability to extract skills from ofﬂine data and adapt them to solve new challenging tasks in few-shot could be impactful in domains where large ofﬂine datasets are available but control is challenging and cannot be manually scripted.
Examples of such domains include autonomous vehicle navigation, warehouse robotics, digital assistants and perhaps in the future, home robots.
However, there are also negative potential consequences.
First, since in real-world settings ofﬂine data will be collected from users at scale there will likely be privacy concerns, especially for video data collected from users’ cars or homes.
Additionally, since FIST extracts skills, without labels data, quality for large datasets becomes increasingly opaque and if there are harmful skills or behavior present in the dataset
FIST may extract those and use them during deployment which could have unintended consequences.
A promising direction for future work is to include a human in the loop for skill veriﬁcation.
6. Conclusion
We present FIST, a semi-parametric algorithm for few-shot imitation learning for long-horizon tasks that are unseen during training.
We use previously collected trajectories of the agent interacting with the environment to learn a set of skills along with an inverse dynamics model that is then combined with a non-parametric approach to keep the agent from drifting away from the downstream demonstrations.
Our approach is able to solve long-horizon challenging tasks in both one and few-shot settings where other methods fail.
A. Implementation Details A.1. Distance function
As mentioned in Section 3, we wish to learn an encoding such that our distance metric d is the euclidean distance between the encoded states.
[Equation]
To learn the encoder h , we optimize a contrastive loss on encodings of the current and future states along the same trajectory.
We use the InfoNCE Loss (van den Oord et al., 2018),
[Equation]
with query q = h
( s it ) as the encoded starting state, and the keys k = h
( s it + H ) as the encoded future states along the K trajectories in the dataset D .
A.2. Training
The training for both skill extraction and ﬁne-tuning were done on a single NVIDIA 2080Ti GPU.
Skill extraction takes approximately 3-4 hours, and ﬁne-tuning requires less than 10 minutes.
Our codebase builds upon the SPiRL released code and is located at https://github.com/kouroshhakha/fist .
Hyperparameters used for training and ﬁne-tuning are listed in Table 7 and 8, respectively.
A.3. Datasets
The PointMaze and Kitchen environment datasets (both skill extraction datasets and few-shot learning datasets) are generated from an expert policy.
For the AntMaze environment, the dataset was created from the D4RL dataset (Fu et al., 2020), licensed under the Creative Commons Attribution 4.0 License (CC BY).
Datasets for each blocked section was created by ﬁltering out any trajectories that passed through the blocked regions shown in Figure 3.
Code for the dataset generation is included in the released repository.
[Table] [Table]