Introduction
Explainable Reinforcement Learning (XRL) typically oscillates between two extremes: local saliency maps that highlight per-pixel influences on single actions, and global summaries that encapsulate entire episodes. Neither approach effectively captures the "middle-ground" behavioral context—the temporally extended strategies like "preparing to jump" or "approaching a goal" that define an agent's policy. This paper introduces a reward-free, offline framework designed to discover these recurring behavioral patterns and attribute specific actions to them, providing explanations that align with human understanding.
Methodology: The Discovery and Attribution Pipeline
The proposed framework operates through a multi-stage pipeline that transforms raw state-action trajectories into interpretable behavior clusters.
- Behavior Discovery: A transformer-based Vector Quantized Variational Autoencoder (VQ-VAE) is trained on sequences of state-action pairs. By including actions, the model learns what the agent did rather than just its spatial location. The VQ-VAE discretizes these sequences into tokens from a learned codebook.
- Behavior Segmentation: To ensure stability, a behavior graph is constructed where edges represent a hybrid of transition frequency and latent similarity. Spectral clustering is applied to this graph to identify distinct behavior clusters.
- Policy Training: For each discovered cluster, a cluster-specific Behavior Cloning (BC) model is trained. A global policy ($\pi_{all}$) is also trained on the full dataset.
- Behavior Attribution: To explain a specific action $a_0$, the framework compares it against the predictions of the cluster-specific BC models. The action is attributed to the cluster whose model minimizes the prediction error (e.g., MSE for continuous actions).
Experimental Evaluation
The framework was tested across four diverse environments: HalfCheetah (locomotion), Seaquest (Atari), Pen-expert (manipulation), and MiniGrid (navigation).
Semantic Interpretability
A key strength of this method is the semantic consistency of the discovered clusters. As shown in the table below, the unsupervised clusters correspond to recognizable, high-level behaviors across different task domains.
In user studies, participants showed a strong preference for these behavior-level attributions over traditional trajectory-level baselines. For instance, in the Pen-expert environment, 85.7% of participants identified the framework's output as the most helpful explanation. Quantitatively, human descriptions of segments within the same cluster exhibited high cosine similarity (0.61 to 0.69), confirming that the clusters capture distinct, recognizable strategies.
Key Insights
- Action-Centric Discovery: Including actions in the VQ-VAE input is essential. Without them, clustering tends to rely on spatial features rather than the underlying strategy.
- Hybrid Graph Weighting: Combining transition dynamics with latent distance prevents over-segmentation, leading to more temporally stable and coherent behavior segments.
- Fidelity and Coherence: The method achieves high Average Fidelity Scores (AFS), ensuring that the explanations accurately reflect the agent's actual policy while remaining human-readable.
Conclusion and Future Work
By bridging the gap between local and global XRL, this framework provides a more nuanced view of agent behavior. While currently limited by manual hyperparameter tuning and challenges in highly stochastic environments, future work involving Graph Neural Networks (GNNs) could automate the learning of task-specific similarity structures. This approach holds significant promise for safety auditing and real-time monitoring of complex RL systems.
Summary updated