Manuscript Offprint

arXiv:2610.10857

Self-Supervised Keyframe Discovery for Horizon-Invariant Behavior Cloning

Prabin Kumar Rath, Omkar Patil, Nakul Gopalan

Abstract

Behavior cloning (BC) in non-Markovian environments is a challenging problem because policies have to reason over contextual information over long horizons. Existing policy architectures rely on recurrent or attention-based mechanisms to capture long-term dependencies. However, recurrent models suffer from hidden-state collapse and gradient instability under backpropagation through time, while attention-based models are fundamentally limited by context length. To address these issues, we propose Keyframe Mnemonics, a novel self-supervised method that discovers a set of information-critical observations (mnemonics) by learning an objective from randomly sampled past observations and using it as a reward for keyframe selection. We then train a BC policy that conditions on the discovered keyframes to model the action distribution. Under certain task-structure assumptions, our formulation provides context retention guarantees over an infinite horizon, while maintaining a small set of decision-relevant keyframes in the policy's working memory. We evaluate our method on synthetic memory domains, where mnemonic-conditioned BC policies achieve 100% success rates (SR) and generalize to horizons orders of magnitude beyond training without performance degradation. Additionally, we evaluate on memory-intensive robot manipulation benchmark, achieving a 13.9% average absolute SR improvement over the strongest baseline across 23 tasks and retaining 80% SR at 20× longer horizons on a real robot. Code and videos are available at https://keyframe-mnemonics.github.io.

1 Introduction

The Markov assumption for decision processes is that the agent's current state contains sufficient information to determine the optimal action with respect to its goal or objective [1]. In practice, however, real-world environments are non-Markovian and partially observable, where decision-making often requires retaining (“remembering”) information over time to provide context for future actions [2, 3]. Recent advancements in policy learning have increasingly relied on behavior cloning (BC) [4, 5, 6], in which policies are highly dependent on short observation contexts with a working memory spanning only a few seconds into the past. This makes such BC policies brittle on tasks that require remembering information cues over long horizons [7]. Recurrent models have been the architecture of choice for behavior cloning in such memory intensive partially observable environments and are typically trained using Back-Propagation Through Time (BPTT) [8, 9]. However, BPTT is difficult to scale, as it requires sequential gradient accumulation over episode timesteps [10]. Truncated-BPTT tries to mitigate this issue but trades off information from distant past observations [11]. Moreover, recurrent models suffer from hidden-state collapse due to repeated representation updates over time [12, 10]. Attention-based architectures such as transformers [13] address many representation learning challenges, but their finite context length limits retention of the full history in partially observable domains. Furthermore, increasing context through frame stacking incurs quadratic compute complexity [13], degrades at extreme horizons [14], and is prone to overfitting spurious correlations with

Preprint.

Figure

Figure 1: Keyframe Mnemonics three-stage training for horizon-invariant behavior cloning. (1) Proxy policy training. A random binary mask Ψk\Psi_k is applied to the observation history hth_t to assemble a memory buffer Bt\mathcal{B}_t of size at most kk, on which the proxy fθ:B→Af_\theta : \mathcal{B} \to \mathcal{A} is trained to predict the expert action ata_t under a negative log-likelihood loss L\mathcal{L}. Combinatorial support of training data (Lemma 1) biases fθf_\theta toward keyframe-based hypotheses (Theorem 1, Proposition 1), so the frozen objective Jθ∗(Bt)=L(fθ∗(Bt),at)J_{\theta^*}(\mathcal{B}_t) = \mathcal{L}(f_{\theta^*}(\mathcal{B}_t), a_t) scores keyframe-rich buffers favourably (Corollary 1; Section 2.1). (2) Selector policy training. The selector πs\pi_s is trained using PPO to populate Bt\mathcal{B}_t with keyframes using Jθ∗(Bt)J_{\theta^*}(\mathcal{B}_t) as reward function (Section 2.2). (3) Behavior cloning. The trained selector is used to construct a keyframe augmented dataset D†\mathcal{D}^\dagger, which is then used to train the BC policy πBC(at∣ot,Bt)\pi_{\mathrm{BC}}(a_t \mid o_t, \mathcal{B}_t) (Section 2.3). Throughout the figure, blue tiles denote the current observation oto_t, orange tiles denote past frames in hth_t, hatched tiles are frames not selected into Bt\mathcal{B}_t.

visual observations [15]. Many hybrid architectures have been proposed that improve information retention through dedicated memory mechanisms [14, 16, 17, 18, 19, 20, 21] or by learning recurrent summaries [22, 23, 24]. However, these methods remain susceptible to state collapse beyond the horizons encountered during training, often leading to severe performance degradation on tasks that require generalization to longer horizons.

To address these challenges in behavior cloning, we propose Keyframe Mnemonics (KM), a policy learning method that decomposes the original non-Markovian decision-making problem into two subproblems: (i) discovering observations (keyframes) that contain information relevant to the action distribution, and (ii) training a BC policy on demonstrations augmented with the identified keyframes. Our keyframe discovery process is self-supervised and leverages the intrinsic simplicity bias of neural networks [25, 26, 27] to train a reward function that assigns high rewards to information-rich keyframes in the policy's context buffer. The reward learning process is driven by the mutual information advantage of keyframes with the expert action distribution, which is amplified through a novel training method that uses randomly sampled past observations as training samples for the reward function. We then train a selector policy using reinforcement learning to optimize the learned reward function and identify a set of decision-relevant keyframes, which we call Mnemonics ("something that assists memory"). Finally, we train BC policies conditioned on these mnemonics to match the expert action distribution. The trained policy is deployed together with the selector, which identifies keyframes at runtime and provides context to disambiguate actions under partial observability. Under certain assumptions, this architectural decomposition enables horizon-invariance i.e., memory retention beyond the training horizon, allowing BC policies to generalize on longer time scales where existing hybrid memory methods fail. We extensively evaluate Keyframe Mnemonics on synthetic memory benchmarks (Add [28], Scattered Copy [22], T-Maze [29]), grid worlds (MiniGrid Memory [30], LTMB-Hallway [31]), memory-intensive robot manipulation benchmark MIKASA-Robo [7], and additionally on a real robot, demonstrating stable performance without degradation far beyond the training horizon. Our contributions are:

• We propose a novel self-supervised algorithm to discover decision-relevant keyframes in non-Markovian expert demonstrations without explicit keyframe annotations (Figure 1, Algorithm 1).

• We provide a theoretical intuition of our method under task-structure assumptions, derive information retention guarantees, and support our hypotheses with empirical evidence.

• We demonstrate horizon-invariant performance of mnemonic-conditioned BC policies, with MLP policies achieving 100% SR in synthetic and grid memory domains, Transformer policies improving absolute SR by 13.9% on the MIKASA-Robo benchmark, and a flow-matching policy retaining 80% SR at 20×20\times longer test horizons on a real robot.

References (65)