LEARNING TRANSFERABLE MOTOR SKILLS
Year: 2021

Abstract:
For robots operating in the real world, it is desirable to learn reusable behaviours that can effectively be transferred and adapted to numerous tasks and scenarios. We propose an approach to learn abstract motor skills from data using a hierarchical mixture latent variable model. In contrast to existing work, our method exploits a three-level hierarchy of both discrete and continuous latent variables, to capture a set of high-level behaviours while allowing for variance in how they are executed. We demonstrate in manipulation domains that the method can effectively cluster offline data into distinct, executable behaviours, while retaining the flexibility of a continuous latent variable model. The resulting skills can be transferred and fine-tuned on new tasks, unseen objects, and from state to vision-based policies, yielding better sample efficiency and asymptotic performance compared to existing skilland imitation-based methods. We further analyse how and when the skills are most beneficial: they encourage directed exploration to cover large regions of the state space relevant to the task, making them most effective in challenging sparse-reward settings.

heading: 1 INTRODUCTION
text: Reinforcement learning is a powerful and flexible paradigm to train embodied agents, but relies on large amounts of agent experience, computation, and time, on each individual task. Learning each task from scratch is inefficient: it is desirable to learn a set of skills that can efficiently be reused and adapted to related downstream tasks. This is particularly pertinent for real-world robots, where interaction is expensive and data-efficiency is crucial. There are numerous existing approaches to learn transferable embodied skills, usually formulated as a two-level hierarchy with a high-level controller and low-level skills. These methods predominantly represent skills as being either continuous, such as goal-conditioned (Lynch et al., 2019; Pertsch et al., 2020b) or latent space policies (Haarnoja et al., 2018; Merel et al., 2019; Singh et al., 2021); or discrete, such as mixture or option-based methods (Sutton et al., 1999; Daniel et al., 2012; Florensa et al., 2017; Wulfmeier et al., 2021). Our goal is to combine these perspectives to leverage their complementary advantages.
We propose an approach to learn a three-level skill hierarchy from an offline dataset, capturing both discrete and continuous variations at multiple levels of behavioural abstraction. The model comprises a low-level latent-conditioned controller that can learn motor primitives, a set of continuous latent mid-level skills, and a discrete high-level controller that can compose and select among these abstract mid-level behaviours. Since the mid- and high-level form a mixture, we call our method Hierarchical Latent Mixtures of Skills (HeLMS). We demonstrate on challenging object manipulation tasks that our method can decompose a dataset into distinct, intuitive, and reusable behaviours. We show that these skills lead to improved sample efficiency and performance in numerous transfer scenarios: reusing skills for new tasks, generalising across unseen objects, and transferring from state to vision-based policies. Further analysis and ablations reveal that both continuous and discrete components are beneficial, and that the learned hierarchical skills are most useful in sparse-reward settings, as they encourage directed exploration of task-relevant parts of the state space.
Our main contributions are as follows:
• We propose a novel approach to learn skills at different levels of abstraction from an offline dataset. The method captures both discrete behavioural modes and continuous variation using a hierarchical mixture latent variable model.
• We present two techniques to reuse and adapt the learned skill hierarchy via reinforcement learning in downstream tasks, and perform extensive evaluation and benchmarking in different transfer settings: to new tasks and objects, and from state to vision-based policies. • We present a detailed analysis to interpret the learned skills, understand when they are most
beneficial, and evaluate the utility of both continuous and discrete skill representations.

heading: 2 RELATED WORK
text: A long-standing challenge in reinforcement learning is the ability to learn reusable motor skills that can be transferred efficiently to related settings. One way to learn such skills is via multi-task reinforcement learning (Heess et al., 2016; James et al., 2018; Hausman et al., 2018; Riedmiller et al., 2018), with the intuition that behaviors useful for a given task should aid the learning of related tasks. However, this often requires careful curation of the task set, where each skill represents a separate task. Some approaches avoid this by learning skills in an unsupervised manner using intrinsic objectives that often maximize the entropy of visited states while keeping skills distinguishable (Gregor et al., 2017; Eysenbach et al., 2019; Sharma et al., 2019; Zhang et al., 2020).
A large body of work explores skills from the perspective of unsupervised segmentation of repeatable behaviours in temporal data (Niekum & Barto, 2011; Ranchod et al., 2015; Krüger et al., 2016; Lioutikov et al., 2017; Shiarlis et al., 2018; Kipf et al., 2019; Tanneberg et al., 2021). Other works investigate movement or motor primitives that can be selected or sequenced together to solve complex manipulation or locomotion tasks (Mülling et al., 2013; Rueckert et al., 2015; Lioutikov et al., 2015; Paraschos et al., 2018; Merel et al., 2020; Tosatto et al., 2021; Dalal et al., 2021). Some of these methods also employ mixture models to jointly model low-level motion primitives and a high-level primitive controller (Muelling et al., 2010; Colomé & Torras, 2018; Pervez & Lee, 2018).
Several existing approaches employ architectures in which the policy is comprised of two (or more) levels of hierarchy. Typically, a low-level controller represents the learned set of skills, and a high-level policy instructs the low-level controller via a latent variable or goal. Such latent variables can be discrete (Florensa et al., 2017; Wulfmeier et al., 2020) or continuous (Nachum et al., 2018; Haarnoja et al., 2018) and regularization of the latent space is often crucial (Tirumala et al., 2019). The latent variable can represent the behaviour for one timestep, for a fixed number of timesteps (Ajay et al., 2021), or options with different durations (Sutton et al., 1999; Bacon et al., 2017; Wulfmeier et al., 2021). One such approach that is particularly relevant (Florensa et al., 2017) learns a diverse set of skills, via a discrete latent variable that interacts multiplicatively with the state to enable continuous variation in a Stochastic Neural Network policy; this skill space is then transferred to locomotion tasks by learning a new categorical controller. Our method differs in a few key aspects: our proposed three-level hierarchical architecture explicitly models abstract discrete skills while allowing for temporal dependence and lower-level latent variation in their execution, enabling diverse object-centric behaviours in challenging manipulation tasks.
Our work is related to methods that learn robot policies from demonstrations (LfD, e.g. (Rajeswaran et al., 2018; Shiarlis et al., 2018; Strudel et al., 2020)) or more broadly from logged data (offline RL, e.g. (Wu et al., 2019; Kumar et al., 2020; Wang et al., 2020)). While many of these focus on learning single-task policies, several approaches learn skills offline that can be transferred online to new tasks (Merel et al., 2019; Lynch et al., 2019; Pertsch et al., 2020a; Ajay et al., 2021; Singh et al., 2021). These all train a two-level hierarchical model, with a high-level encoder that maps to a continuous latent space, and a low-level latent-conditioned controller. The high-level encoder can encode a whole trajectory (Pertsch et al., 2020a; 2021; Ajay et al., 2021); a short look-ahead state sequence (Merel et al., 2019); the current and final goal state (Lynch et al., 2019); or can even be simple isotropic Gaussian noise (Singh et al., 2021) that can be flexibly transformed by a flow-based low-level controller. At transfer time, a new high-level policy is learned from scratch: this can be more efficient with skill priors (Pertsch et al., 2020a) or temporal abstraction (Ajay et al., 2021).
HeLMS builds on this large body of work by explicitly modelling both discrete and continuous behavioural structure via a three-level skill hierarchy. We use similar information asymmetry to Neural Probabilistic Motor Primitives (NPMP) (Merel et al., 2019; 2020), conditioning the highlevel encoder on a short look-ahead trajectory. However HeLMS explicitly captures discrete modes of behaviour via the high-level controller, and learns an additional mid-level which is able to transfer abstract skills to downstream tasks, rather than learning a continuous latent policy from scratch.

heading: 3 METHOD
text: This paper examines a two-stage problem setup: an offline stage where a hierarchical skill space is learned from a dataset, and an online stage where these skills are transferred to a reinforcement learning setting. The dataset D comprises a set of trajectories, each a sequence of state-action pairs {xt,at}Tt=0. The model incorporates a discrete latent variable yt ∈ {1, . . . ,K} as a high-level skill selector (for a fixed number of skills K), and a mid-level continuous variable zt ∈ Rnz conditioned on yt which parameterises each skill. Marginally, zt is then a latent mixture distribution representing both a discrete set of skills and the variation in their execution. A sample of zt represents an abstract behaviour, which is then executed by a low-level controller p(at | zt,xt). The learned skill space can then be transferred to a reinforcement learning agent π in a Markov Decision Process defined by tuple {S,A, T ,R, γ}: these represent the state, action, and transition distributions, reward function, and discount factor respectively. When transferring, we train a new high-level controller that acts either at the level of discrete skills yt or continuous zt, and freeze lower levels of the policy.
We explain our method in detail in the following sections.

heading: 3.1 LATENT MIXTURE SKILL SPACES FROM OFFLINE DATA
text: Our method employs the generative model in Figure 1a. As shown, the state inputs can be different for each level of the hierarchy, but to keep notation uncluttered, we refer to all state inputs as xt and the specific input can be inferred from context. The joint distribution of actions and latents over a trajectory is decomposed into a latent prior p(y0:T , z1:T ) and a low-level controller p(at | zt,xt):
p(a1:T ,y0:T , z1:T |x1:T ) = p(y0:T , z1:T ) T∏ t=1 p(at | zt,xt)
p(y0:T , z1:T ) = p(y0) T∏ t=1 p(yt |yt−1)p(zt |yt). (1)
Intuitively, the categorical variable yt can capture discrete modes of behaviour, and the continuous latent zt is conditioned on this to vary the execution of each behaviour. Thus, zt follows a mixture distribution, encoding all the relevant information on desired abstract behaviour for the low-level controller p(at | zt,xt). Since each categorical latent yt is dependent on yt−1, and zt is only dependent on yt, this prior can be thought of as a Hidden Markov model over the sequence of z1:T .
To perform inference over the latent variables, we introduce the following variational approximation:
q(y0:T , z1:T |x1:T ) = p(y0) T∏ t=1 q(yt |yt−1,xt)q(zt |yt,xt) (2)
Here, the selection of a skill yt ∼ q(yt |yt−1,xt) is dependent on that of the previous timestep (allowing for temporal consistency), as well as the input. The mid-level skill is then parameterised by zt ∼ q(zt |yt,xt) based on the chosen skill and current input. p(y0) and p(yt |yt−1) model a skill prior and skill transition prior respectively, while p(zt |yt) represents a skill parameterisation prior to regularise each mid-level skill. While all of these priors can be learned in practice, we only found it necessary to learn the transition prior, with a uniform categorical for the initial skill prior and a simple fixed N (0, I) prior for p(zt |yt).
Training via the Evidence Lower Bound The proposed model contains a number of components with trainable parameters: the prior parameters ψ = {ψa, ψy} for the low-level controller and categorical transition prior respectively; and posterior parameters φ = {φy, φz} for the high-level controller and mid-level skills. For a trajectory {x1:T ,a1:T } ∼ D, we can compute the Evidence Lower Bound for the state-conditional action distribution, ELBO ≤ p(a1:T |x1:T ), as follows:
ELBO = Eqφ(y0:T ,z1:T |x1:T ) [ log pψ(a1:T ,y0:T , z1:T |x1:T )− log qφ(y0:T , z1:T |x1:T ) ]
≈ T∑ t=1 [∑ yt q(yt |x1:t) ( per-component action recon︷ ︸︸ ︷ log pψa(at | z̃ {yt} t ,xt)−βz per-component KL regulariser︷ ︸︸ ︷ KL(qφz (zt |yt,xt) || p(zt |yt)) )]
−βy T∑ t=1 [∑ yt−1 q(yt−1 |x1:t−1)KL ( qφy (yt |yt−1,xt) || pψy (yt |yt−1) )︸ ︷︷ ︸ categorical regulariser ] (3)
where z̃{yt}t ∼ q(zt |yt,xt). The coefficients βy and βz can be used to weight the KL terms, and the cumulative component probability q(yt |x1:t) can be computed iteratively as q(yt |x1:t) =∑
yt−1 qφy (yt |yt−1,xt)q(yt−1 |x1:t−1). In other words, for each timestep t and each mixture component, we compute the latent sample and the corresponding action log-probability, and the KL-divergence between the component posterior and prior. This is then marginalised over all yt, with an additional KL over the categorical transitions. For more details, see Appendix C.
Information-asymmetry As noted in previous work (Tirumala et al., 2019; Galashov et al., 2019), hierarchical approaches often benefit from information-asymmetry, with higher levels seeing additional context or task-specific information. This ensures that the high-level remains responsible for abstract, task-related behaviours, while the low-level executes simpler motor primitives. We employ similar techniques in HeLMS: the low-level inputs xLL comprise the proprioceptive state of the embodied agent; the mid-level inputs xML also include the poses of objects in the environment; and the high-level xHL concatenates both object and proprioceptive state for a short number of lookahead timesteps. The high- and low-level are similar to (Merel et al., 2019), with the low-level controller enabling motor primitives based on proprioceptive information, and the high-level using the lookahead information to provide additional context regarding behavioural intent when specifying which skill to use. The key difference is the categorical high-level and the additional mid-level, with which HeLMS can learn more object-centric skills and transfer these to downstream tasks.
Network architectures The architecture and information flow in HeLMS are shown in Figure 1b. The high-level network contains a gated head, which uses the previous skill yt−1 to index into one of K categorical heads, each of which specify a distribution over yt. For a given yt, the corresponding mid-level skill network is selected and used to sample a latent action zt, which is then used as input for the latent-conditioned low-level controller, which parameterises the action distribution. The skill transition prior p(yt |yt−1) is also learned, and is parameterised as a linear softmax layer which takes in a one-hot representation of yt−1 and outputs the distribution over yt. All components are trained end-to-end via the objective in Equation 3.

heading: 3.2 REINFORCEMENT LEARNING WITH RELOADED SKILLS
text: Once learned, we propose two methods to transfer the hierarchical skill space to downstream tasks. Following previous work (e.g. (Merel et al., 2019; Singh et al., 2021)), we freeze the low-level controller p(at | zt,xt), and learn a policy for either the continuous (zt) or discrete (yt) latent.
Categorical agent One simple and effective technique is to additionally freeze the mid-level components q(zt |yt,xt), and learn a categorical high-level controller π(yt |xt) for the downstream task. The learning objective is given by:
J = Eπ [∑ t γt (rt − ηyKL(π(yt |xt) ||π0(yt |xt))) ] , (4)
where the standard discounted return objective in RL is augmented by an additional term performing KL-regularisation to some prior π0 scaled by coefficient ηy . This could be any categorical distribution such as the previously learned transition prior p(yt |yt−1), but in this paper we regularise to the uniform categorical prior to encourage diversity. While any RL algorithm could be used to optimize π(yt |xt), in this paper we use MPO (Abdolmaleki et al., 2018) with a categorical action distribution (see Appendix B for details). We hypothesise that this method improves sample efficiency by converting a continuous control problem into a discrete abstract action space, which may also aid in credit assignment. However, since both the mid-level components and low-level are frozen, it can limit flexibility and plasticity, and also requires that all of the mid- and low-level input states are available in the downstream task. We call this method HeLMS-cat.
Mixture agent A more flexible method of transfer is to train a latent mixture policy, π(zt |xt) =∑ yt π(yt |xt)π(zt |yt,xt). In this case, the learning objective is given by:
J = Eπ [∑ t γt ( rt − ηyKL(π(yt |xt) ||π0(yt |xt))− ηz ∑ yt KL(π(zt |yt,xt) ||π0(zt |yt,xt)) )] , (5)
where in addition to the categorical prior, we also regularise each mid-level skill to a corresponding prior π0(zt |yt,xt). While the priors could be any policies, we set them to be the skill posteriors q(zt |yt,xt) learned offline, to ensure the mixture components remain close to the pre-learned skills. This is related to (Tirumala et al., 2019), which also applies KL-regularisation at multiple levels of a hierarchy. While the high-level controller π(yt |xt) is learned from scratch, the mixture components can also be initialised to q(zt |yt,xt), to allow for initial exploration over the space of skills. Alternatively, the mixture components can use different inputs, such as vision: this setup allows vision-based skills to be learned efficiently by regularising to state-based skills learned offline. We optimise this using RHPO (Wulfmeier et al., 2020), which employs a similar underlying optimisation to MPO for mixture policies (see Appendix B for details). We call this method HeLMS-mix.

heading: 4 EXPERIMENTS
text: Our experiments focus on the following questions: (1) Can we learn a hierarchical latent mixture skill space of distinct, interpretable behaviours? (2) How do we best reuse this skill space to improve sample efficiency and performance on downstream tasks? (3) Can the learned skills transfer effectively to multiple downstream scenarios: (i) different objects; (ii) different tasks; and (iii) different modalities such as vision-based policies? (4) How exactly do these skills aid learning of downstream manipulation tasks? Do they aid exploration? Are they useful in sparse or dense reward scenarios?

heading: 4.1 EXPERIMENTAL SETUP
text: Environment and Tasks We focus on manipulation tasks, using a MuJoCo-based environment with a single Sawyer arm, and three objects coloured red, green, and blue. We follow the challenging object stacking benchmark of Lee et al. (2021), which specifies five object sets (Figure 2), carefully designed to have diverse geometries and present different challenges for a stacking agent. These range from simple rectangular objects (object set 4), to geometries such as slanted faces (sets 1 and 2) that make grasping or stacking the objects more challenging. This environment allows us to systematically evaluate generalisation of manipulation behaviours for different tasks interacting with geometrically different objects. For further information, we refer the reader to Appendix D.1 or to (Lee et al., 2021). Details of the rewards for the different tasks are also provided in Appendix F.
Datasets To evaluate our approach and baselines in the manipulation settings, we use two datasets:
• red_on_blue_stacking: this data is collected by an agent trained to stack the red object on the blue object and ignore the green one, for the simplest object set, set4. • all_pairs_stacking: similar to the previous case, but with all six pairwise stacking
combinations of {red, green, blue}, and covering all of the five object sets.
Baselines For evaluation in transfer scenarios, we compare HeLMS with a number of baselines:
• From scratch: We learn the task from scratch with MPO, without an offline learning phase. • NPMP+KL: We compare against NPMP (Merel et al., 2019), which is the most simi-
lar skill-based approach in terms of information-asymmetry and policy conditioning. We make some small changes to the originally proposed method, and also apply additional KL-regularisation to the latent prior: we found this to improve performance significantly in our experiments. For more details and an ablation, see Appendix A.2.
• Behaviour Cloning (BC): We apply behaviour cloning to the dataset, and fine-tune this policy via MPO on the downstream task. While the actor is initialised to the solution obtained via BC, the critic still needs to be learned from scratch.
• Hierarchical BC: We evaluate a hierarchical variant of BC with a similar latent space z to NPMP using a latent Gaussian high-level controller. However, rather than freezing the low-level and learning just a high-level policy, Hierarchical BC fine-tunes the entire model.
• Asymmetric actor-critic: For state-to-vision transfer, HeLMS uses prior skills that depend on object states to learn a purely vision-based policy. Thus, we also compare against a variant of MPO with an asymmetric actor-critic (Pinto et al., 2017) setup, which uses object states differently: to speed up learning of the critic, while still learning a vision-based actor.

heading: 4.2 LEARNING SKILLS FROM OFFLINE DATA
text: We first aim to understand whether we can learn a set of distinct and interpretable skills from data (question (1)). For this, we train HeLMS on the red_on_blue_stacking dataset with 5 skills. Figure 3a shows some example episode rollouts when the learned hierarchical agent is executed in the environment, holding the high-level categorical skill constant for an episode. Each row represents a different skill component, and the resulting behaviours are both distinct and diverse: for
(a) (b)
Figure 5: (a) Performance on pyramid task; and (b) image sequence showing episode rollout from a learned solution on this task (left-to-right, top-to-bottom).
Figure 6: Performance for visionbased stacking.
example, a lifting skill (row 1) where the gripper closes and rises up, a reaching skill (row 2) where the gripper moves to the red object, or a grasping skill (row 3) where the gripper lowers and closes its fingers. Furthermore, without explicitly encouraging this, the emergent skills capture temporal consistency: Figure 3b shows the learned prior p(yt |yt−1) (visualised as a transition matrix) assigns high probability along the diagonal (remaining in the same skill). Finally, Figure 3c demonstrates that all skills are used, without degeneracy.

heading: 4.3 TRANSFER TO DOWNSTREAM TASKS
text: Generalising to different objects We next evaluate whether the previously learned skills (i.e. trained on the simple objects in set 4) can effectively transfer to more challenging object interaction scenarios: the other four object sets proposed by (Lee et al., 2021). The task uses a sparse staged reward, with reward incrementally given after completing each sub-goal of the stacking task. As shown in Figure 4, both variants of HeLMS learn significantly faster than baselines on the different object sets. Compared to the strongest baseline (NPMP), HeLMS reaches better average asymptotic performance (and much lower variance) on two object sets (1 and 3), performs similarly on set 5, and does poorer on object set 2. The performance on object set 2 potentially highlights a trade-off between incorporating higher-level abstract behaviours and maintaining low-level flexibility: this object set often requires a reorientation of the bottom object due to its slanted faces, a behaviour that is not common in the offline dataset, which might require greater adaptation of mid- and low-level skills. This is an interesting investigation we leave for future work.
Compositional reuse of skills To evaluate whether the learned skills are composable for new tasks, we train HeLMS on the all_pairs_stacking dataset with 10 skills, and transfer to a pyramid task. In this setting, the agent has to place the red object adjacent to the green object, and stack the blue object on top to construct a pyramid. The task is specified via a sparse staged reward for each stage or sub-task: reaching, grasping, lifting, and placing the red object, and subsequently the blue object. In Figure 5(a), we plot the performance of both variants of our approach, as well as
NPMP and MPO; we omit the BC baselines as this involves transferring to a fundamentally different task. Both HeLMS-mix and HeLMS-cat reach a higher asymptotic performance than both NPMP and MPO, indicating that the learned skills can be better transferred to a different task. We show an episode rollout in Figure 5(b) in which the learned agent can successfully solve the task.
From state to vision-based policies While our method learns skills from proprioception and object state, we evaluate whether these skills can be used to more efficiently learn a vision-based policy. This is invaluable for practical real-world scenarios, since the agent acts from pure visual observation at test time without requiring privileged and often difficult-to-obtain object state information.
We use the HeLMS-mix variant to transfer skills to a vision-based policy, by reusing the low-level controller, initialising a new high-level controller and mid-level latent skills (with vision and proprioception as input), and KL-regularising these to the previously learned state-based skills. While the learned policy is vision-based, this KL-regularisation still assumes access to object states during training. For a fair comparison, we additionally compare our approach with a version of MPO using an asymmetric critic (Pinto et al., 2017), which exploits object state information instead of vision in the critic, and also use this for HeLMS. As shown in Figure 6, learning a vision-based policy with MPO from scratch is very slow and computationally intensive, but an asymmetric critic significantly speeds up learning, supporting the empirical findings of Pinto et al. (2017). However, HeLMS once again demonstrates better sample efficiency, and reaches slightly better asymptotic performance. We note that this uses the same offline model as for the object generalisation experiments, showing that the same state-based skill space can be reused in numerous settings, even for vision-based tasks.

heading: 4.4 WHERE AND HOW CAN HIERARCHICAL SKILL REUSE BE EFFECTIVE?
text: Sparse reward tasks We first investigate how HeLMS performs for different rewards: a dense shaped reward, the sparse staged reward from the object generalisation experiments, and a fully sparse reward that is only provided after the agent stacks the object. For this experiment, we use the skill space trained on red_on_blue_stacking and transfer it to the same RL task of stacking on object set 4. The results are shown in Figure 7. With a dense reward (and no object transfer required), all of the approaches can successfully learn the task. With the sparse staged reward, the baselines all plateau at a lower performance, with the exception of NPMP, as previously discussed. However, for the challenging fully-sparse scenario, HeLMS is the only method that achieves nonzero reward. This neatly illustrates the benefit of the proposed hierarchy of skills: it allows for directed exploration which ensures that even sparse rewards can be encountered. This is consistent with observations from prior work in hierarchical reinforcement learning (Florensa et al., 2017; Nachum et al., 2019), and we next investigate this claim in more depth for our manipulation setting.
Exploration To measure whether the proposed approach leads to more directed exploration, we record the average coverage in state space during an episode at the start of RL (i.e. zero-shot transfer). This is computed as the variance (over an episode) of the state xt, separated into three interpretable groups: joints (angles and velocity), grasp (a binary simulated grasp sensor), and object poses. We also record the total reward (dense and sparse staged). The results are reported in Table 1,
Method Reward State coverage (×10 −2)
Dense Staged Joints Grasp Objects MPO 3.16 0.0 8.72 0.004 1.21
NPMP 3.67 0.0 3.43 0.0 1.45 BC 31.68 0.004 4.22 0.05 1.52 Hier. BC 16.42 0.004 2.61 0.04 1.31 HeLMS 20.46 0.05 2.98 1.10 1.61
Table 1: Analysis of zero-shot exploration at the start of RL, in terms of the reward obtained and state coverage (variance over an episode of different subsets of the agent’s state: proprioception, grasp sensor, and object states). Results are averaged over 1000 episodes.
(a) (b)
Figure 8: Ablation to measure the benefit of continuous and discrete components during offline learning, when transferring to the (a) easy case (object set 4) and (b) hard case (object set 3).
averaged over 1000 episodes. While all approaches achieve some zero-shot dense reward (with BC the most effective), HeLMS1 receives a sparse staged reward an order of magnitude greater. Further, in this experiment we found it was able to achieve the fully sparse reward (stacked) in one episode. Analysing the state coverage results, while other methods are able to cover the joint space more (e.g. by randomly moving the joints), HeLMS is nearly two orders of magnitude higher for grasp states. This indicates the utility of hierarchical skills: by acting over the space of abstract skills rather than low-level actions, HeLMS performs directed exploration and targets particular states of interest, such as grasping an object.

heading: 4.5 ABLATION STUDIES
text: Capturing continuous and discrete structure To evaluate the benefit of both continuous and discrete components, we train our method with a fixed variance of zero for each latent component (i.e. ‘discrete-only’) and transfer to the stacking task with sparse staged reward in an easy case (object set 4) and hard case (object set 3), as shown in Figure 8(a) and (b). We also evaluate the ‘continuousonly’ case with just a single Gaussian to represent the high- and mid-level skills: this is equivalent to the NPMP+KL baseline. We observe the the discrete component alone leads to improved sample efficiency in both cases, but modelling both discrete and continuous latent behaviours makes a significant difference in the hard case. In other words, when adapting to challenging objects, it is important to capture discrete skills, but allow for latent variation in how they are executed.
KL-regularisation We also perform an ablation for KL-regularisation during the offline phase (via βz) and online RL (via ηz), to gauge the impact on transfer; see Appendix A.1 for details.

heading: 5 CONCLUSION
text: We present HeLMS, an approach to learn transferable and reusable skills from offline data using a hierarchical mixture latent variable model. We analyse the learned skills to show that they effectively cluster data into distinct, interpretable behaviours. We demonstrate that the learned skills can be flexibly transferred to different tasks, unseen objects, and to different modalities (such as from state to vision). Ablation studies indicate that it is beneficial to model both discrete modes and continuous variation in behaviour, and highlight the importance of KL-regularisation when transferring to RL and fine-tuning the entire mixture of skills. We also perform extensive analysis to understand where and how the proposed skill hierarchy can be most useful: we find that it is particularly invaluable in sparse reward settings due to its ability to perform directed exploration.
There are a number of interesting avenues for future work. While our model demonstrated temporal consistency, it would be useful to more actively encourage and exploit this for sample-efficient transfer. It would also be useful to extend this work to better fine-tune lower level behaviours, to allow for flexibility while exploiting high-level behavioural abstractions.
1Note that HeLMS-cat and HeLMS-mix are identical for this analysis: at the start of reinforcement learning, both variants transfer the mid-level skills while initialising a new high-level controller.

heading: A ADDITIONAL EXPERIMENTS
text: A.1 ABLATIONS FOR KL-REGULARISATION
In these experiments, we investigate the effect of KL-regularisation on the mid-level components, both for the offline learning phase (regularising each component to p(zt |yt) = N (0, I) via coefficient βz), and the online reinforcement learning stage via HeLMS-mix (regularising each component to the mid-level skills learned offline, via coefficient ηz)). The results are reported in Figure 9, where each plot represents a different setting for offline KL-regularisation (either regularisation toN (0, I) with βz = 0.01, or no regularisation with βz = 0) and a different transfer case (the easy case of transferring to object set 4, or the hard case of transferring to object set 3). Each plot shows the downstream performance when varying the strength of KL-regularisation during RL via coefficient ηz . The HeLMS-cat approach represents the extreme case where the skills are entirely frozen (i.e. full regularisation).
The results suggest some interesting properties of the latent skill space based on regularisation. When regularising the mid-level components to the N (0, I) prior, it is important to regularise during online RL; this is especially true for the hard transfer case, where HeLMS-cat performs much better, and the performance degrades significantly with lower regularisation values. However, when removing mid-level regularisation during offline learning, the method is insensitive to regularisation during RL over the entire range evaluated, from 0.01 to 100.0. We conjecture that with mid-level skills regularised to N (0, I), the different mid-level skills are drawn closer together and occupy a more compact region in latent space, such that KL-regularisation is necessary during RL for a skill to avoid drifting and overlapping with the latent distribution of other skills (i.e. skill degeneracy). In contrast, without offline KL-regularisation, the skills are free to expand and occupy more distant regions of the latent space, rendering further regularisation unnecessary during RL. Such latent space properties could be further analysed to improve learning and transfer of skills; we leave this as an interesting direction for future work.
A.2 NPMP ABLATION
The Neural Probabilistic Motor Primitives (NPMP) work (Merel et al., 2019) presents a strong baseline approach to learning transferable motor behaviours, and we run ablations to ensure a fair comparison to the strongest possible result. As discussed in the main text, NPMP employs a Gaussian high-level latent encoder with a AR(1) prior in the latent space. We also try a fixed N(0, I) prior (this is equivalent to an AR(1) prior with a coefficient of 0, so can be considered a hyperparameter choice). Since our method benefits from KL-regularisation during RL, we apply this to NPMP as well.
As shown in Figure 10, we find that both changes lead to substantial improvements in the manipulation domain, on all five object sets. Consequently, in our main experiments, we report results with the best variant, using a N(0, I) prior with KL-regularisation during RL.

heading: B REINFORCEMENT LEARNING WITH MPO AND RHPO
text: As discussed in Section 3.2, the hierarchy of skills are transferred to RL in two ways: HeLMScat, which learns a new high-level categorical policy π(yt |xt) via MPO (Abdolmaleki et al., 2018); or HeLMS-mix, which learns a mixture policy π(zt |xt) = ∑ yt π(yt |xt)π(zt |yt,xt) via RHPO (Wulfmeier et al., 2020). We describe the optimisation for both of these cases in the following subsections. For clarity of notation, we omit the additional KL-regularisation terms introduced in Section 3.2 and describe just the base methods of MPO and RHPO when applied to the RL setting in this paper. These KL-terms are incorporated as additional loss terms in the policy improvement stage.
B.1 HELMS-CAT VIA MPO
Maximum a posteriori Policy Optimisation (MPO) is an Expectation-Maximisation-based algorithm that performs updates in three steps: (1) updating the critic; (2) creating a non-parametric intermediate policy by weighting sampled actions using the critic; and (3) updating the parametric policy to fit the critic-reweighted non-parametric policy, with trust region constraints to improve stability. We detail each of these steps below. Note that while the original MPO operates in the environment’s action space, we use it here for the high-level controller, to set the categorical variable yt.
Policy evaluation First, the critic is updated via a TD(0) objective as:
min θ L(θ) = Ext,yt∼B
[( QT −Qφ(xt,yt))2 ] , (6)
Here, QT = rt + γExt+1,yt+1 [Q′(st+1,yt+1)] is the 1-step target with the state transition (xt,yt,xt+1) returned from the replay buffer B, and next action sampled from yt+1 ∼ π′(·|xt+1). π′ and Q′ are target networks for the policy and the critic, used to stabilise learning.
Policy improvement Next, we proceed with the first step of policy improvement by constructing an intermediate non-parametric policy q(yt|xt), and optimising the following constrained objective:
max q J(q) = Eyt∼q,xt∼B
[ Qφ(xt,yt) ] , s.t. Ext∼B [ KL ( q(·|xt)‖πθk(·|xt) )] ≤ E , (7)
where E defines a bound on the KL divergence between the non-parametric and parametric policies at the current learning step k. This constrained optimisation problem has the following closed-form solution:
q(yt |xt) ∝ πθk(yt |xt) exp (Qφ(xt,yt)/η) . (8)
In other words, this step constructs an intermediate policy which reweights samples from the previous policy using exponentiated temperature-scaled critic values. The temperature parameter η is derived based on the dual of the Lagrangian; for futher details please refer to (Abdolmaleki et al., 2018).
Finally, we can fit a parametric policy to the non-parametric distribution q(yt |xt) by minimising their KL-divergence, subject to a trust-region constraint on the parametric policy:
θk+1 = argmin θ
Ext∼B [ KL(q(yt |xt) ||πθ(yt|xt)) ] ,
s.t. Ext∼B [ KL ( πθk+1(yt |xt) ||πθk(yt |xt) )] ≤ M . (9)
This optimisation problem can be solved via Lagrangian relaxation, with the Lagrangian multiplier M modulating the strength of the trust-region constraint. For further details and full derivations, please refer to (Abdolmaleki et al., 2018).
B.2 HELMS-MIX VIA RHPO
RHPO (Wulfmeier et al., 2020) follows a similar optimisation procedure as MPO, but extends it to mixture policies and multi-task settings. We do not exploit the multi-task capability in this work, but utilise RHPO to optimise the mixture policy in latent space, π(zt |xt) =∑
yt π(yt |xt)π(zt |yt,xt). The Q-function Qφ(xt, zt) and parametric policy πθk(zt |xt) use the continuous latents zt as actions instead of the categorical yt. This is also in contrast to the original formulation of RHPO, which uses the environment’s action space. Compared to MPO, the policy improvement stage of the non-parametric policy is minimally adapted to take into account the new mixture policy. The key difference is in the parametric policy update step, which optimises the following:
θk+1 = argmin θ
Ext∼B [ KL(q(zt |xt) ||πθ(zt|xt)) ] ,
s.t. Ext∼B [ KL ( πθk+1(yt |xt) ||πθk(yt |xt) ) + ∑ yt KL ( πθk+1(zt |yt,xt) ||πθk(zt |yt,xt) )] ≤ M . (10)
In other words, separate trust-region constraints are applied to a sum of KL-divergences: for the high-level categorical and for each of the mixture components. Following the original RHPO, we separate the single constraint into decoupled constraints that set a different for the means, covariances, and categorical ( µ, σ , and cat, respectively). This allows the optimiser to independently modulate how much the categorical distribution, component means, and component variances can change. For further details and full derivations, please refer to (Wulfmeier et al., 2020).

heading: C ELBO DERIVATION AND INTUITIONS
text: We can compute the Evidence Lower Bound for the state-conditional action distribution, p(a1:T |x1:T ) ≥ ELBO, as follows:
ELBO = p(a1:T |x1:T )− KL(q(y0:T , z1:T |x1:T ) || p(y0:T , z1:T |x1:T )) = Eq(y0:T ,z1:T |x1:T ) [ log p(a1:T ,y0:T , z1:T |x1:T )− log q(y0:T , z1:T |x1:T ) ] = Eq1:T [ T∑ t=1 log p(at | zt,xt) + log p(zt |yt) + log p(yt |yt−1)
− log q(zt |yt,xt)− log q(yt |yt−1,x)
]
= T∑ t=1 Eq1:T
[ log p(at | zt,xt)− KL(q(zt |yt,xt) || p(zt |yt))
−KL(q(yt |yt−1,xt) || p(yt |yt−1)) ] (11)
We note that the first two terms in the expectation depend only on timestep t, so we can simplify and marginalise exactly over all discrete {y1:T }\yt. For the final term, we note that the KL at timestep t is constant with respect to yt (as it already marginalises over the whole distribution), and only depends on yt−1. Lastly, we will use sampling to approximate the expectation over zt. This yields the following:
ELBO = T∑ t=1 Eq(zt |yt,xt) [∑ y0:T q(y0:T |x1:T ) ( log p(at | zt,xt)− KL(q(zt |yt,xt) || p(zt |yt))
−KL(q(yt |yt−1,xt) || p(yt |yt−1)) )]
ELBO ≈ T∑ t=1 [∑ yt q(yt |x1:t) ( per-component recon loss︷ ︸︸ ︷ log p(at | z̃{yt}t ,xt)−βz per-component KL regulariser︷ ︸︸ ︷ KL(q(zt |yt,xt) || p(zt |yt)) )]
−βy T∑ t=1 [∑ yt−1 q(yt−1 |x1:t−1)KL(q(yt |yt−1,xt) || p(yt |yt−1))︸ ︷︷ ︸ discrete regulariser ] (12)
where z̃{yt}t ∼ q(zt |yt,xt), the coefficients βy and βz can be used to weight the KL terms, and the cumulative component probability q(yt |x1:t) can be computed iteratively as:
q(yt |x1:t) = ∑ yt−1 q(yt |yt−1,xt)q(yt−1 |x1:t−1) (13)
In other words, for each timestep t and each mixture component, we compute the latent sample and the corresponding action log-probability, and the KL-divergence between the component posterior and prior. This is then marginalised over all yt, with an additional KL over the categorical transitions.
Structuring the graphical model and ELBO in this form has a number of useful properties. First, the ELBO terms include an action reconstruction loss and KL term for each mixture component, scaled by the posterior probability of each component given the history. For a given state, this pressures the model to assign higher posterior probability to components that have low reconstruction cost or KL, which allows different components to specialise for different parts of the state space. Second, the categorical KL between posterior and prior categorical transition distributions is scaled by the
posterior probability of the previous component given history q(yt−1 |x1:t−1): this allows the relative probabilities of past skill transitions along a trajectory to be considered when regularising the current skill distribution. Finally, this formulation does not require any sampling or backpropagation through the categorical variable: starting from t = 0, the terms for each timestep can be efficiently computed by recursively updating the posterior over components given history (q(yt |x1:t)), and summing over all possible categorical values at each timestep.

heading: D ENVIRONMENT PARAMETERS
text: As discussed earlier in the paper, all experiments take place in a MuJoCo-based object manipulation environment using a Sawyer robot manipulator and three objects: red, green, and blue. The state variables in the Sawyer environment are shown in Table 3. All state variables are stacked for 3 frames for all agents. The object states are only provided to the mid-level and high-level for HeLMS runs, and the camera images are only used by the high- and mid-level controller in the vision transfer experiments (without object states).
The action space is also shown in Table 4. Since the action dimensions vary significantly in range, they are normalised to be between [−1, 1] for all methods during learning. When learning via RL, we apply domain randomisation to physics (but not visual randomisation), and a randomly sampled action delay of 0-2 timesteps. This is applied for all approaches, and ensures that we can learn a policy that is robust to small changes in the environment.
D.1 OBJECT SETS
As discussed in the main paper, we use the object sets defined by Lee et al. (2021), which are carefully designed to cover different object geometries and affordances, presenting different challenges for object interaction tasks. The object sets are shown in Figure 11 (the image has been taken directly from (Lee et al., 2021) for clarity), and feature both simulated and real-world versions; in this paper we focus on the simulated versions. As discussed in detail by (Lee et al., 2021), each object set has a different degree of difficulty and presents a different challenge to the task of stacking red-on-blue:
• In object set 1, the red object has slanted surfaces that make it difficult to grasp, while the blue object is an octagonal prism that can roll.
• In object set 2, the blue object has slanted surfaces, such that the red object will likely slide off unless the blue object is first reoriented.
• In object set 3, the red object is long and narrow, requiring a precise grasp and careful placement.
• Object set 4 is the easiest case with rectangular prisms for both red and blue. • Object set 5 is also relatively easy, but the blue object has ten faces, meaning limited surface
area for stacking.
For more details about the object sets and the rationale behind their design, we refer the reader to (Lee et al., 2021).

heading: E NETWORK ARCHITECTURES AND HYPERPARAMETERS
text: The network architecture details and hyperparameters for HeLMS are shown in Table 5. Parameter sweeps were performed for the β coefficients during offline learning and the η coefficients during RL. Small sweeps were also performed for the RHPO parameters (refer to (Wulfmeier et al., 2020) for details), but these were found to be fairly insensitive. All other parameters were kept fixed, and used for all methods except where highlighted in the following subsections. All RL experiments were run with 3 seeds to capture variation in each method.
For network architectures, all experiments except for vision used simple 2-layer MLPs for the highand low-level controllers, and for each mid-level mixture component. An input representation network was used to encode the inputs before passing them to the networks that were learned from scratch: i.e. the high-level for state-based experiments, and both high- and mid-level for vision (re-
call that while the state-based experiments can reuse the mid-level components conditioned on object state, the vision-based policy learned them from scratch and KL-regularised to the offline mid-level skills). The critic network was a 3-layer MLP, applied to the output of another input representation network (separate to the actor, but with the same architecture) with concatenated action.

heading: F REWARDS
text: Throughout the experiments, we employ different reward functions for different tasks and to study the efficacy of our method in sparse versus dense reward scenarios.
Reward stages and primitive functions The reward functions for stacking and pyramid tasks use various reward primitives and staged rewards for completing sub-tasks. Each of these rewards are within the range of [0, 1]
These include:
• reach(obj): a shaped distance reward to bring the TCP to within a certain tolerance of obj. • grasp(): a binary reward for triggering the gripper’s grasp sensor. • close_fingers(): a shaped distance reward to bring the fingers inwards. • lift(obj): shaped reward for lifting the gripper sufficiently high above obj. • hover(obj1,obj2): shaped reward for holding obj1 above obj2. • stack(obj1,obj2): a sparse reward, only provided if obj1 is on top of obj2 to
within both a horizontal and vertical tolerance. • above(obj,dist): shaped reward for being dist above obj, but anywhere horizon-
tally. • pyramid(obj1,obj2,obj3): a sparse reward, only provided if obj3 is on top of the
point midway between obj1 and obj2, to within both a horizontal and vertical tolerance. • place_near(obj1,obj2): sparse reward provided if obj1 is sufficiently near obj2.
Dense stacking reward The dense stacking reward contains a number of stages, where each stage represents a sub-task and has a maximum reward of 1. The stages are:
• reach(red) AND grasp(): Reach and grasp the red object. • lift(red) AND grasp(): Lift the red object. • hover(red,blue): Hover with the red object above the blue object. • stack(red,blue): Place the red object on top of the blue one. • stack(red,blue) AND above(red): Move the gripper above after a completed
stack.
At each timestep, the latest stage to receive non-zero reward is considered to be the current stage, and all previous stages are assigned a reward of 1. The reward for this timestep is then obtained by summing rewards for all stages, and scaling by the number of stages, to ensure the highest possible reward on any timestep is 1.
Sparse staged stacking reward The sparse staged stacking reward is similar to the dense reward variant, but each stage is sparsified by only providing the reward for the stage once it exceeds a value of 0.95.
This scenario emulates an important real-world problem: that it may be difficult in certain cases to specify carefully shaped meaningful rewards, and it can often be easier to specify (sparsely) whether a condition (such as stacking) has been met.
Sparse stacking reward This fully sparse reward uses the stack(red,blue) function to provide reward only when conditions for stacking red on blue have been met.
Pyramid reward The pyramid-building reward uses a staged sparse reward, where each stage represents a sub-task and has a maximum reward of 1. If a stage has dense reward, it is sparsified by only providing the reward once it exceeds a value of 0.95. The stages are:
• reach(red) AND grasp(): Reach and grasp the red object. • lift(red) AND grasp(): Lift the red object. • hover(red,green): Hover with the red object above the green object (with a larger
horizontal tolerance, as it does not need to be directly above). • place_near(red,green): Place the red object sufficiently close to the green object. • reach(blue) AND grasp(): Reach and grasp the blue object. • lift(blue) AND grasp(): Lift the blue object. • hover(blue,green) AND hover(blue,red): Hover with the blue object above
the central position between red and green objects. • pyramid(blue,red,green): Place the blue object on top to make a pyramid. • pyramid(blue,red,green) AND above(blue): Move the gripper above after a
completed stack.
At each timestep, the latest stage to receive non-zero reward is considered to be the current stage, and all previous stages are assigned a reward of 1. The reward for this timestep is then obtained by summing rewards for all stages, and scaling by the number of stages, to ensure the highest possible reward on any timestep is 1

Review summaries:
This paper introduces a latent variable controller model that allows for reusable skill learning in behaviour cloning and reinforcement learning settings. The architecture comprises three stages or levels. At the highest level, input state information (eg. proprioception, visual input, object state information) is passed through an MLP to produce a discrete latent state skill selection variable, incorporating a discrete latent transition model. This skill selection prior is then used in a mid level network operating on the same input information, to produce a continuous latent state, conditioned on this discrete latent variable. Finally, this latent state, together with the input state is used by an actor network to produce actions.  The model is trained used a heuristic process depending on the deployment setting, with different elements frozen at different times, or through the use of a mixture agent that can be initialised from scratch or using previous skills (a similar approach is explored by Florensa et al., ICLR 2017). A KL regularisation on the discrete latent variable skill selector is used (also in prior work - Burke et al., CoRL 2019). Results show that this approach is effective on a range of tasks, and that skill re-use (as expected) out performs learning from scratch. Probably the most interesting result is the comparison with a hierarchical behaviour cloning network and the experiments around skills transfer. The idea seems sound, although the presentation is in need of some improvement, and at times the paper suffers from lack of clarity (in problem formulation and presentation of results). Moreover, some important work in the admittedly vast array of work on hierarchical models for RL and behaviour cloning is missed.  

This paper presents a hierarchical model for skills extraction from an online dataset. In particular, the model can be seen as a 3-level hierarchy. The highest level of the hierarchy selects a discrete variable that corresponds to the index of a skill. The mid-level selects the continuous parameter that defines the skill. The lower level executes the skill.  The considered problem is crucial in reinforcement learning. In particular, the definition of skills to be reused across different tasks is essential to achieve better sample efficiency, and crucial to allow reinforcement learning to be applied directly on challenging real robotic tasks.   When dealing with an off-line dataset, one wants potentially to first extract a set of skills (say, low-level policies) and then to learn via RL the selector of such policies. In this way, one both simplifies the problem (increasing sample efficiency) and allows the skills to be reused in different tasks.  The authors propose a graphical model that consists, per time step, of four variables: $x_t$, $y_t$ $z_t$ and $a_t$. $x_t$ represents the MDP's state, $y_t$ is the discrete selector of the skill, $z_t$ the (continuous) parameters of the skill, and $a_t$ is the output at time $t$ of the selected skill (and can represent, for example, the joint velocities of the robot).  After learning via variational inference the probabilistic model, the authors propose to refine the learned behavior via MPO, learning the skill selector $p(y_t | y_{t-1},x_t)$, the skill parameters $p(z_t | y_t, x_t)$, and the skill p(a_t | z_t, y_t).  Further, the authors propose 1) to use an asymmetric information approach, where each level of the described hierarchy sees a different definition of the state. In particular, the lower layer sees the robotic state (proprioception), the mid-layer sees the position of objects in the scene, and the highest level sees both the information 2) the models use "gated"-heads: the categorical variable $y_t$ is fed to the last part of the neural network.   Once the hierarchy has been learned, one can tune it on the same or different tasks. In particular, the lowest layer is kept fixed, while only the highest, or the highest, and the mid-layer are learned.   The authors propose to use MPO as a reinforcement learning algorithm. They perform a few ablation studies and experiments to empirically prove the efficacy of their method. 

This paper presents a method to learn a three-leveled hierarchy of skills offline, from a dataset of demonstrations, that can then be applied to accelerate reinforcement learning. The three-level architecture is novel. It encodes a discrete selection, a continuous contextual variable (dependent on the discrete selection) and a low level policy dependant of the continuous contextual variable. The results show some improvements over baselines, especially in a sparse reward context where the presented method capitalizes from the offline learned strategies for exploration.

This paper proposes a three-level hierarchy for learning motor skills. At the bottom, there is a low-level controller for action generation and at the top a high-level controller that generates sequences of skills, with continuous control signals generated by skills at the mid-level. When transferring motor skills from one task to another using reinforcement learning, it is possible to either retrain only the high-level controller or the mid-level one as well. In experiments, it is shown that for transfers to more complex manipulation tasks with sparse rewards, you are more likely to get convergence in training with positive rewards, if only retraining the high-level controller. Thus you are given more flexibility and are possibly able to learn more complex tasks, with the proposed hierarchy compared to earlier methods based on only two levels.