Sequence Model Imitation Learning with Unobserved Contexts

Gokul Swamy, Sanjiban Choudhury, J. Andrew Bagnell, Zhiwei Steven Wu

Abstract

We consider imitation learning problems where the learner's ability to mimic the expert increases throughout the course of an episode as more information is revealed. One example of this is when the expert has access to privileged information: while the learner might not be able to accurately reproduce expert behavior early on in an episode, by considering the entire history of states and actions, they might be able to eventually identify the hidden context and act as the expert would. We prove that on-policy imitation learning algorithms (with or without access to a queryable expert) are better equipped to handle these sorts of asymptotically realizable problems than off-policy methods. This is because on-policy algorithms provably learn to recover from their initially suboptimal actions, while off-policy methods treat their suboptimal past actions as though they came from the expert. This often manifests as a latching behavior: a naive repetition of past actions. We conduct experiments in a toy bandit domain that show that there exist sharp phase transitions of whether off-policy approaches are able to match expert performance asymptotically, in contrast to the uniformly good performance of on-policy approaches. We demonstrate that on several continuous control tasks, on-policy approaches are able to use history to identify the context while off-policy approaches actually perform worse when given access to history.

Introduction

In many imitation learning (IL) applications, an expert possesses privileged information—such as a specific destination, a hidden physical parameter, or a latent intent—that is not directly observable by the learner. To bridge this information gap, practitioners often provide the learner with a history of past states and actions, hoping the model will use this sequence to infer the unobserved context.

However, this approach frequently leads to the "latching effect" (or the "copycat problem"), where the learner ignores the environment's dynamics and simply repeats its own previous actions. This paper investigates why off-policy methods like Behavioral Cloning (BC) fail in these scenarios and demonstrates that on-policy interaction is essential for successful sequence-based imitation learning.

The Latching Effect and Causal Self-Delusion

The core of the failure in off-policy methods lies in a causal misattribution. When a learner uses history to infer a hidden context, it must distinguish between actions that provide information about the context and actions that are merely its own past mistakes.

Using Structural Causal Models (SCMs), the authors show that off-policy methods implicitly assume that all actions in the history were produced by the expert. If the learner makes a mistake early in an episode, it "deludes" itself into believing that mistake was the correct expert action for the current context. This creates a false posterior belief, causing the learner to double down on its error. In contrast, on-policy methods like DAgger treat their own actions as interventions. Because the learner knows it chose those actions, it does not use them as evidence to bias its belief about the hidden context, allowing it to recover and eventually align with the expert.

Asymptotic Realizability and Theoretical Bounds

The paper introduces the concept of Asymptotic Realizability (AR): the condition where a learner can eventually match expert performance once sufficient history has been revealed.

The authors prove a significant theoretical gap between on-policy and off-policy approaches:

  • On-Policy Consistency: On-policy algorithms are asymptotically consistent in AR settings. Their imitation gap is bounded by the asymptotic error, meaning they can eventually "catch up" to the expert.
  • Off-Policy Failure: The imitation gap for off-policy methods is bounded by the sum of errors over time. Early mistakes haunt the learner indefinitely, preventing it from ever reaching expert-level performance in many cases.

Experimental Results

The researchers evaluated these theories across three domains, highlighting the robustness of on-policy learning and the fragility of off-policy methods.

Causal Bandit Domain

In a toy bandit environment, the authors observed "sharp phase transitions." Off-policy methods do not degrade gracefully; instead, small changes in environment noise or expert optimality can cause a sudden shift from perfect consistency to total failure. On-policy methods, however, remained uniformly effective across all parameters.

Continuous Control: HalfCheetah and Ant

In modified PyBullet environments, the learner had to infer a hidden target velocity:

  • HalfCheetah: While standard BC performed moderately well, adding history (BC-SEQ) actually decreased performance. The model succumbed to the latching effect. Conversely, DAgger-SEQ significantly outperformed standard DAgger, successfully using history to identify the target velocity.
  • Ant: In a task where the context was revealed only after 200 timesteps, on-policy methods showed a sharp drop in error immediately upon revelation. Off-policy methods struggled to incorporate the new information, as their early "self-delusional" beliefs about the context were too entrenched to overcome.

Conclusion

This research provides a theoretical and empirical foundation for why history-based imitation learning requires on-policy interaction. While sequence models like Transformers and LSTMs are powerful tools for capturing context, they are prone to the latching effect when trained off-policy. To effectively use history for context inference, learners must be able to interact with the environment to disambiguate their own actions from expert intent. Future work remains to develop offline mitigation strategies that can replicate these causal benefits without requiring a live expert.

Summary updated

BibTeX
@inproceedings{swamy2022sequence,
  author = {Gokul Swamy and Sanjiban Choudhury and J. Andrew Bagnell and Zhiwei Steven Wu},
  title = {{Sequence Model Imitation Learning with Unobserved Contexts}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=3nbKUphLBg5},
}
Figure