Efficient Shapley Values Estimation by Amortization for Text Classification

Chenghao Yang, Fan Yin, He He, Kai-Wei Chang, Xiaofei Ma, Bing Xiang

Abstract

Explaining black-box NLP models using Shapley Values is a computational challenge, often requiring thousands of model passes that yield unstable results. This paper introduces an amortized approach: instead of sampling at inference time, a separate model is trained to directly predict the Shapley Values of input tokens. This deterministic method is up to 60x faster than traditional sampling while providing significantly more stable and faithful feature attributions.

Introduction

In the field of Explainable AI (XAI), Shapley Values are the gold standard for distributing "credit" for a model's prediction among its input features. However, calculating exact Shapley Values is NP-hard. In practice, researchers use stochastic estimators like KernelSHAP, which suffer from two major flaws:

  1. Efficiency: Estimating values for a single sentence can take seconds—hundreds of times slower than the model's actual prediction.
  2. Instability: Because these methods rely on random sampling, different random seeds produce wildly different explanations for the same input, as shown in Figure 1. This inconsistency erodes user trust and makes explanations unreliable for high-stakes domains.
Visualizing the instability of sampling-based explanations: different random seeds produce inconsistent token attributions for the same input review.

Methodology

The authors propose a two-stage Amortized Model to bypass the sampling bottleneck. First, they collect data using a stable (but slow) estimator, specifically Shapley Value Sampling (SVS-25), to generate reference explanation scores. Second, they train a BERT-based model to map input text directly to these pre-computed scores using a Mean Squared Error (MSE) loss.

Comparison of the traditional sampling-based approach vs. the proposed amortized approach, highlighting the 600x speedup and comparable quality.

Crucially, once trained, the amortized model provides deterministic explanations in a single forward pass. The authors also provide an optional local adaptation step that uses the amortized model's output as a prior for a small number of additional samples to refine instance-specific token interactions.

Key Results

The study evaluated the method on the Yelp-Polarity and MNLI benchmarks, yielding several key insights:

  • Speed and Stability: The amortized model generates explanations in less than 50ms per instance, representing a 60x speedup over KernelSHAP-200 and a 600x speedup over more stable variants. Unlike sampling methods, the amortized model is perfectly stable across runs.
  • The "Long Text" Penalty: Empirical evidence shows that as input length increases, the stability of sampling-based methods plummets because the search space of word combinations grows exponentially. The amortized model avoids this by learning global attribution patterns.
  • Faithfulness: In feature selection tests, the amortized model outperformed KernelSHAP-200, proving its predicted scores are more aligned with the target model's actual behavior.

Conclusion

By moving from a sampling-based approach to a predictive one, amortization eliminates seed sensitivity and drastically reduces computational overhead. While the one-time cost of generating the training set is high, the resulting efficiency makes high-quality Shapley explanations feasible for large-scale text classification tasks. Future work will investigate how these models transfer across more diverse domains and different model architectures.

Summary updated

BibTeX
@inproceedings{yang2023efficient,
  author = {Chenghao Yang and Fan Yin and He He and Kai-Wei Chang and Xiaofei Ma and Bing Xiang},
  title = {{Efficient Shapley Values Estimation by Amortization for Text Classification}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.483},
}
Figure