TokenShapley: Token Level Context Attribution with Shapley Value

Yingtai Xiao, Yuqing Zhu, Sirat Samyoun, Wanrong Zhang, Jiachen T. Wang +1 more
6/18/2025
cs.CLcs.LG

No confident code implementation found for this paper. 1 possible match can be shown below.

Abstract

Large language models (LLMs) demonstrate strong capabilities in in-context learning, but verifying the correctness of their generated responses remains a challenge. Prior work has explored attribution at the sentence level, but these methods fall short when users seek attribution for specific keywords within the response, such as numbers, years, or names. To address this limitation, we propose TokenShapley, a novel token-level attribution method that combines Shapley value-based data attribution with KNN-based retrieval techniques inspired by recent advances in KNN-augmented LLMs. By leveraging a precomputed datastore for contextual retrieval and computing Shapley values to quantify token importance, TokenShapley provides a fine-grained data attribution approach. Extensive evaluations on four benchmarks show that TokenShapley outperforms state-of-the-art baselines in token-level attribution, achieving an 11-23% improvement in accuracy.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 1 weaker match is hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{xiao2025tokenshapley,
  title  = {TokenShapley: Token Level Context Attribution with Shapley Value},
  author = {Yingtai Xiao and Yuqing Zhu and Sirat Samyoun and Wanrong Zhang and Jiachen T. Wang and Jian Du},
  year   = {2025},
  eprint = {2507.05261},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2507.05261v2}
}

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/2507.05261.svg)](https://codeofpaper.com/paper/2507.05261)

Discussion