Introduction
CompILE (Compositional Imitation Learning and Execution) is a framework designed to automatically discover reusable sub-tasks from expert demonstrations without relying on manual labels. By utilizing a novel, fully-differentiable segmentation module, CompILE learns to break down complex behaviors into a library of "latent codes." These codes can then be re-composed to solve new, longer, and more difficult tasks, bridging the gap between low-level imitation and high-level task planning.
The Challenge of Unsupervised Segmentation
When humans learn a complex skill—like cooking a multi-course meal—we do not perceive it as one long, continuous string of muscle movements. Instead, we understand it as a hierarchy of discrete sub-tasks: slicing vegetables, boiling water, and stirring the sauce.
In machine learning, most imitation learning methods treat demonstrations as flat sequences. This makes it difficult for agents to generalize. If an agent only learns "how to make pasta" as a single monolithic sequence, it might struggle to reuse the "boiling water" portion when learning to make tea. The core challenge is unsupervised segmentation: teaching a machine where one sub-task ends and another begins without a human providing explicit "start" and "stop" labels for every action.
How CompILE Works
CompILE treats this challenge as an auto-encoding problem. The architecture consists of an encoder that identifies task boundaries and a decoder that learns to execute the isolated sub-tasks.
- Differentiable Segmentation: To avoid the "all-or-nothing" nature of discrete boundaries (which are notoriously difficult to train using standard backpropagation), the authors use a continuous relaxation technique known as Gumbel-Softmax. This allows the model to predict "soft" masks over the timeline, essentially outputting probabilities for where a task boundary might occur.
- RNN State Masking: As the encoder processes a sequence, it uses these soft masks to "hide" parts of the hidden state that belong to already-explained segments. This forces the model to focus its attention entirely on the remaining, unexplained parts of the demonstration.
- Latent Task Encodings: Each discovered segment is mapped to a latent code. Together, these codes act as a learned "vocabulary" of skills.
- The Decoder Policy: The decoder functions as a policy that takes a latent code and the current state to produce actions. It learns to reconstruct the expert's behavior for that specific segment.
Evaluation Domains
The authors evaluated CompILE on two distinct domains to test its versatility:
- 2D Multi-task Grid World: An agent navigates a 10x10 grid filled with walls and obstacles to "visit" or "pick up" specific objects in a required order.
- Continuous Control Reacher: A simulated two-link robotic arm must touch a series of colored spheres in a specific sequence.
Key Insights and Results
- Zero-Shot Generalization: Because CompILE learns modular components, it can handle sequences longer than those it saw during training. For example, a model trained exclusively on 3-task sequences can successfully segment and imitate 5-task sequences at test time.
- Hierarchical RL "Macro-Actions": Once trained, the learned sub-policies can be used as high-level actions for a Reinforcement Learning (RL) agent. Instead of deciding which individual motor command to send every millisecond, the high-level agent simply selects a "latent code" (e.g., "Go to the red sphere"). This significantly simplifies the learning process for complex tasks.
- Solving Sparse Rewards: In environments where rewards are only given at the very end of a long task (sparse rewards), standard agents often fail because they never stumble upon the correct sequence of thousands of actions. CompILE-based agents succeed because they explore in the space of high-level sub-tasks. In the sparse reward setting, the CompILE-based hierarchical agent was the only one to consistently succeed, while standard behavioral cloning and non-hierarchical baselines failed entirely.
- Boundary Accuracy: In the grid world, CompILE reliably found correct task boundaries, significantly outperforming baseline methods that attempt to find boundaries based on prediction errors.
Limitations and Future Work
While powerful, the CompILE framework has a few limitations that present opportunities for future research:
- Latent Semantics: Because the learning is unsupervised, the latent codes do not always align perfectly with human concepts. Depending on the data, a code might represent "go to coordinate (5,5)" rather than the more semantic "pick up the diamond."
- Observability: The current model assumes a fully-observable Markovian environment. Extending this to partially-observable settings where the agent requires memory would be a valuable next step.
- Weak Supervision: While fully unsupervised regarding task boundaries, the model currently requires the user to specify the maximum number of segments allowed, which acts as a form of weak supervision. Future iterations might learn to determine the optimal number of segments automatically.
Summary updated