Introduction
Reinforcement Learning (RL) agents are notoriously difficult to interpret, often acting as "black boxes." When an agent makes a critical decision—such as a robot navigating around an obstacle or a medical AI suggesting a treatment—understanding the reasoning behind that decision is essential for trust and safety.
Most existing explainable RL (XRL) methods rely on saliency maps, which highlight parts of the current input state (e.g., "the agent moved left because it detected a wall on the right"). While useful, this approach only explains what the agent is currently looking at, not which parts of its training led to that specific logic. In offline RL, where agents learn from a fixed dataset of past experiences, it is crucial to know which historical trajectories were most influential. This paper addresses that gap by introducing a novel framework for "trajectory-aware" explainability, bringing the concept of training data attribution from supervised learning into the realm of reinforcement learning.
Methodology
The authors propose a comprehensive five-step pipeline to attribute an agent's decisions to specific clusters of past experiences from its training data.
- Trajectory Encoding: The framework uses sequence models (such as Decision Transformers or LSTMs) to convert raw sequences of states, actions, and rewards from the offline data into high-dimensional vectors (embeddings).
- Trajectory Clustering: Using the X-Means algorithm, these embeddings are grouped into clusters that represent distinct, high-level semantic behaviors (e.g., "dying in lava" versus "reaching the goal").
- Data Embedding: A single representative embedding is created for the entire dataset (or subsets of it) using a permutation-invariant set-encoding technique.
- Training Explanation Policies: The framework employs a "leave-one-out" methodology. Multiple new RL policies are trained, each time excluding one specific cluster of trajectories from the training data.
- Trajectory Cluster Attribution: To explain a specific action taken by the original policy, the system identifies which "leave-one-out" policy changed the action the most. The original decision is then attributed to the cluster whose removal caused that change, ensuring the remaining data still looks statistically similar to the original dataset (measured via Wasserstein distance).
Experimental Setup
The framework was evaluated across diverse environments to test its scalability, flexibility, and algorithm-agnostic nature (testing on both Soft Actor-Critic and Batch Constrained Q-Learning):
- Grid-world: A simple navigation task with discrete states and actions.
- Seaquest & Breakout (Atari): Complex visual environments with discrete actions.
- HalfCheetah (MuJoCo): A continuous control task involving physics and joint torques.
Datasets were sourced primarily from the D4RL repository for offline RL.
Key Insights and Results
Semantic Clusters and Distant Influence
A key realization from the study is that an agent's decision at a specific coordinate is not solely influenced by trajectories that passed through that exact spot. Distant experiences—such as observing a failure state elsewhere in the environment—can fundamentally shape the agent's global policy. Furthermore, the trajectory embeddings successfully captured semantic "meaning." In Seaquest, clusters naturally formed around distinct behaviors like "filling oxygen" or "fighting enemies."
Qualitative and Quantitative Success
The framework successfully provided intuitive explanations for complex behaviors.
For example, in the Seaquest environment, the model attributed a specific "move left" action to historical trajectories where the submarine aligned itself to face enemies spawning from the left side of the screen. In HalfCheetah, complex joint torques were accurately attributed to trajectories showing the agent learning to stabilize itself from a fall.
Quantitatively, the authors demonstrated that removing these "influential" clusters significantly degraded the expected return ($V(s_0)$) of the resulting policy. In Seaquest, removing a high-skill cluster dropped the value estimate drastically from ~86 to ~3, proving the cluster's critical role in the agent's competence.
Human Alignment
The authors conducted a human study to compare the algorithm's attributions with human intuition. They found that 70% of the time, humans agreed with the trajectories the algorithm identified as the "best" explanation. Interestingly, the study also noted that humans sometimes neglect actual driving factors in the data, highlighting the necessity of automated attribution tools to build reliable trust.
Limitations and Future Work
While promising, the framework has notable limitations. The current method requires training multiple "explanation policies" (one for each cluster), which is computationally expensive for very large datasets or highly complex environments. Additionally, the authors note a lack of established benchmarks for trajectory attribution in RL, making direct comparisons with other potential methods difficult. Finally, the current study is restricted to the offline RL setting; future work aims to extend this approach to online RL, where an agent's memory and training data constantly evolve as it interacts with the environment.
Summary updated