SPEX: Scaling Feature Interaction Explanations for LLMs

Justin Singh Kang, Landon Butler, Abhineet Agarwal, Yigit Efe Erginbas, Ramtin Pedarsani +2 more
2/19/2025
cs.LGcs.AIcs.CL

No official code found. Best implementation: basics-lab/spectral-explain (12 stars, MIT, last commit 2026-03-16).

Abstract

Large language models (LLMs) have revolutionized machine learning due to their ability to capture complex interactions between input features. Popular post-hoc explanation methods like SHAP provide marginal feature attributions, while their extensions to interaction importances only scale to small input lengths ($\approx 20$). We propose Spectral Explainer (SPEX), a model-agnostic interaction attribution algorithm that efficiently scales to large input lengths ($\approx 1000)$. SPEX exploits underlying natural sparsity among interactions -- common in real-world data -- and applies a sparse Fourier transform using a channel decoding algorithm to efficiently identify important interactions. We perform experiments across three difficult long-context datasets that require LLMs to utilize interactions between inputs to complete the task. For large inputs, SPEX outperforms marginal attribution methods by up to 20% in terms of faithfully reconstructing LLM outputs. Further, SPEX successfully identifies key features and interactions that strongly influence model output. For one of our datasets, HotpotQA, SPEX provides interactions that align with human annotations. Finally, we use our model-agnostic approach to generate explanations to demonstrate abstract reasoning in closed-source LLMs (GPT-4o mini) and compositional reasoning in vision-language models.

View on arXivView PDF

Code Implementations(1)

MIT

Fast XAI with interactions at large scale. SPEX can help you understand the output of your LLM, even if you have a long context!

120Python, Jupyter NotebookNov 6, 20247 months agoMIT
explainabilityexplainable-aillm-interpretabilityshapsparse-transformer+1 more

Cite this paper

@article{kang2025spex,
  title  = {SPEX: Scaling Feature Interaction Explanations for LLMs},
  author = {Justin Singh Kang and Landon Butler and Abhineet Agarwal and Yigit Efe Erginbas and Ramtin Pedarsani and Kannan Ramchandran and Bin Yu},
  year   = {2025},
  eprint = {2502.13870},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.13870v1},
  journal = {ICML 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.13870.svg)](https://codeofpaper.com/paper/2502.13870)

Discussion