NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Semifactual Explanations for Reinforcement Learning

Jasmina Gajcin, Jovan Jeromela, Ivana Dusparic · DOI

Introduction

Deep Reinforcement Learning (DRL) agents are increasingly deployed in complex, high-stakes environments. However, their "black-box" nature often obscures the reasoning behind specific decisions, making them difficult to trust in domains like healthcare or autonomous driving. While Explainable AI (XAI) has traditionally focused on counterfactual explanations—answering "If I had done X, the outcome would be different"—these do not address the robustness of a decision.

This paper introduces the first framework for generating semifactual explanations in Reinforcement Learning (RL). Semifactuals provide "even if" scenarios (e.g., "Even if X happened, the outcome would stay the same"), allowing users to understand which factors are redundant and how stable an agent's policy is against perturbations.

The Problem: Beyond "If-Only"

Counterfactuals are useful for identifying the minimum changes required to alter an outcome. However, they fail to explain why a specific outcome was inevitable or which environmental factors were irrelevant to the agent's success. In a precision farming context, a counterfactual might suggest how to increase yield, but a semifactual would explain: "Even if you had used 20% less fertilizer, the crop yield would have remained the same." This type of insight is critical for resource optimization and for verifying that an agent is not merely succeeding due to luck.

Prior to this work, semifactual methods were largely confined to supervised learning. Adapting them to RL requires accounting for the sequential and stochastic nature of agent-environment interactions.

Proposed Framework and Desirable Properties

The authors define five key properties that a high-quality RL semifactual should satisfy:

  1. Validity: The alternative scenario must result in the same outcome as the original.
  2. Temporal Distance: The explanation should be temporally close to the event being explained to maintain relevance.
  3. Stochastic Uncertainty: The framework prioritizes scenarios where the outcome almost changed, as these provide the most informative "even if" arguments.
  4. Fidelity: Explanations must align with the agent’s actual policy logic, typically measured by high Q-values.
  5. Exceptionality: The method should highlight surprising or counterintuitive scenarios that challenge the user's assumptions.

To optimize these properties, the researchers developed two algorithms based on the NSGA-II (a multi-objective evolutionary algorithm):

  • SGRL-Rewind (Backward): Analyzes the past to determine how different prior actions or environmental shifts would have still led to the current state.
  • SGRL-Advance (Forward): Projects into the future to identify how potential perturbations would still result in the same eventual outcome.

Experimental Evaluation

The approach was evaluated using two stochastic RL benchmarks:

  • Stochastic Gridworld: An agent navigates obstacles (which can regrow) to reach a target.
  • Frozen Lake: An agent navigates a grid where "frozen" tiles may cause it to slip in unintended directions.

The proposed SGRL algorithms were compared against S-GEN, a state-of-the-art semifactual generator originally designed for supervised learning tasks.

Key Insights

Temporality in RL

Unlike tabular or image classification, RL involves a temporal dimension. The authors demonstrate that "even if" can refer to both the past and the future, a distinction that is vital for agents acting over time but non-existent in standard XAI.

The Strength of the "Even If"

A powerful semifactual does not just present any scenario with the same outcome; it presents a scenario that challenges the outcome. For instance, saying "even if the environment was more difficult, you still would have succeeded" is a more robust explanation than one involving a simpler environment.

Policy Fidelity

By incorporating policy Q-values into the search process, the SGRL algorithms ensure that the generated explanations do not suggest "nonsense" paths that the agent would never realistically take, thereby maintaining high fidelity to the agent's internal logic.

Results

  • Fidelity Improvements: SGRL-Advance achieved significantly better fidelity scores (0.13–0.14) compared to the S-GEN baseline (0.27–0.97), indicating that the explanations were much more representative of the agent's actual policy.
  • Diversity: The evolutionary approach produced a more diverse set of explanations, which is essential for tailoring information to different user needs.
  • Human-Agent Mental Models: In a user study involving 90 participants, those provided with SGRL-Advance explanations predicted the agent's next move with 77.58% accuracy, compared to 68.62% for the baseline. While not a statistically significant leap, the trend suggests that semifactuals help humans build more accurate mental models of RL agents.

Limitations and Future Work

While promising, the current evaluation is limited to 5x5 grid worlds. Scaling these evolutionary searches to high-dimensional state spaces, such as complex robotics or strategy games, remains a significant challenge. Additionally, the current framework assumes full knowledge of the environment's stochastic configuration, which may not be available in true "black-box" scenarios. Future research may also distinguish between actionable agent decisions and non-actionable environment changes to provide more practical advice to human operators.

Summary updated

BibTeX
@inproceedings{gajcin2024semifactual,
  author = {Jasmina Gajcin and Jovan Jeromela and Ivana Dusparic},
  title = {{Semifactual Explanations for Reinforcement Learning}},
  booktitle = {HAI},
  year = {2024},
  doi = {10.1145/3687272.3688324},
}
Figure