A Reinforcement Learning Method to Factual and Counterfactual Explanations for Session-based Recommendation

Han Zhou, Hui Fang, Zhu Sun, Wentao HuarXiv 2025 · DOI

Abstract

Session-based Recommendation (SR) models, while highly accurate, often operate as "black boxes," lacking transparency in their decision-making processes. This paper introduces FCESR, a framework that employs Reinforcement Learning (RL) to generate both factual (sufficient) and counterfactual (necessary) explanations for recommendations. By identifying the minimal subset of items that drive a recommendation, FCESR not only provides causal depth but also leverages these explanations as high-quality training data. Through contrastive learning, the base recommendation model is fine-tuned to focus on the essential session components, leading to significant improvements in recommendation accuracy across multiple architectures and datasets.

Introduction

Session-based Recommendation (SR) systems have become a cornerstone of modern e-commerce and content platforms, utilizing deep learning architectures like Graph Neural Networks (GNNs) and Transformers to predict user intent from short-term interaction sequences. Despite their performance, these models are notorious for their lack of interpretability. Existing explanation methods for SR typically suffer from two major flaws: a lack of causal depth, often relying on static profiles or simple attention weights, and a failure to utilize explanations to improve the underlying recommender system.

FCESR addresses these gaps by treating explanation generation as a combinatorial optimization problem. It identifies which specific sequence of items actually caused a recommendation by balancing sufficiency (factual reasoning) and necessity (counterfactual reasoning).

Conceptual Framework

To provide a robust explanation, a subset of items must be both sufficient to trigger the recommendation on its own and necessary such that its removal would change the recommendation.

Conceptual comparison of (a) Counterfactual Reasoning (necessity), (b) Factual Reasoning (sufficiency), and (c) the proposed combined approach.

As illustrated in Figure 1, factual reasoning (b) identifies a set of items that is sufficient to produce the recommendation $v_7$. However, this set might be redundant. Counterfactual reasoning (a) identifies items that are necessary, meaning their absence would lead to a different recommendation ($v_8$). FCESR is the first framework in the SR domain to explicitly balance both, identifying the "essence" of a session (c) that is both sufficient and necessary.

Methodology

The FCESR framework operates in two distinct stages: Explanation Generation and Recommendation Enhancement.

The FCESR framework architecture, illustrating the interaction between the base SR model, the RL-based explanation module, and the contrastive enhancement module.

1. Explanation Generation (RL Module)

Finding the minimal subset of items that explains a recommendation is an NP-Hard problem. FCESR utilizes the REINFORCE algorithm to navigate this search space. The RL agent makes binary decisions for each item in a session to determine its inclusion in the explanation subset. The agent is guided by a multi-faceted reward function:

  • Factual Reward: Measures if the subset alone produces the target recommendation (Sufficiency).
  • Counterfactual Reward: Measures if removing the subset changes the recommendation (Necessity).
  • Sparsity Reward: Encourages the selection of the smallest possible subset.
  • Rank Reward: Ensures the target item remains high in the recommendation list when using the subset.

2. Recommendation Enhancement (Contrastive Module)

The generated explanations serve as high-quality data for Contrastive Learning. Factual subsets are treated as "positive samples" (the core intent), while sessions missing counterfactual items are treated as "negative samples." The base SR model is fine-tuned to align session representations with their factual essence while distancing them from their counterfactual-deficient versions.

Evaluation

Datasets and Setup

The framework was evaluated on three industry benchmarks: Amazon Beauty, Amazon Baby, and MovieLens 1M. To ensure model-agnosticism, the authors tested FCESR as a plug-in for five different architectures, including GRU4Rec, NARM, and BERT4Rec.

Key Results

  • Accuracy Boost: FCESR consistently improved recommendation accuracy (HR@K and NDCG@K) for all base models. Notably, it improved the NDCG@5 of the GRU4Rec model on the MovieLens dataset by over 26%.
  • Explanation Quality: Using metrics like Probability of Sufficiency (PS) and Probability of Necessity (PN), FCESR significantly outperformed baseline methods like Random Selection and CRVAE.
  • Robustness: The model demonstrated high stability across various hyperparameters, including learning rates and loss coefficients, indicating its suitability for real-world deployment.

Conclusion

FCESR demonstrates that explainability and performance are not mutually exclusive. By identifying the causal drivers of a recommendation through RL, the framework provides transparent explanations and a mechanism for self-improvement via contrastive learning. Future work will explore the framework's application to cold-start scenarios and incorporate multi-modal data to further enrich the explanation process.

Summary updated

BibTeX
@misc{zhou2025reinforcement,
  author = {Han Zhou and Hui Fang and Zhu Sun and Wentao Hu},
  title = {{A Reinforcement Learning Method to Factual and Counterfactual Explanations for Session-based Recommendation}},
  year = {2025},
  eprint = {2504.13632},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.13632},
}
Figure