REVIEW 3 major objections 6 minor 45 references
TokenShapley: Token Level Context Attribution with Shapley Value
T0 review · 3 major / 6 minor · reviewed 2026-08-06 · deepseek-v4-flash
Pith's one-line read TokenShapley claims to trace each token of an LLM's response back to the exact context token that drove it, computing Shapley values in polynomial time without Monte Carlo sampling.
desk verdict TokenShapley is a useful if narrow contribution: exact-match token attribution via KNN-Shapley, but the claims of exactness and general applicability outrun the implementation. read the letter →
The pith
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
The reading
What carries the argument
The load-bearing mechanism is the pair consisting of a KNN datastore and a binary utility function. The datastore maps each context token's prefix embedding $h(x_t)$ to the token itself $y_t$, so that a response token $\hat{z}_t$ becomes a query whose nearest neighbours vote by exact surface-form equality. The utility function $v(S; \hat{z}_t)$ returns 1 exactly when the weighted majority of neighbours in subset $S$ votes for $\hat{z}_t$; because this is a special case of the weighted-KNN utility, the Shapley value can be computed exactly in $O(N^2)$ time by dynamic-programming counting of vote flips. In the $K=1$ setting the runtime drops to $O(N)$.
What would settle it
Create a test set where the correct evidence is a paraphrase (e.g., context says 'Washington, D.C.' and response says 'the capital'), and check whether the true evidence token receives a near-zero Shapley score; a failure there would show the exact-token-match utility misses genuine token-level causation.
Extended reading notes
Core claim
The paper's central discovery is that Shapley-value attribution, previously applied to training data, can be brought to token granularity in in-context learning by treating each context token as a labeled data point: its prefix is the feature and the token itself is the label. A datastore of (prefix embedding, next token) pairs is built from the context in one forward pass, and each response token of interest is treated as a query. The utility function asks whether the weighted K-nearest-neighbor vote among a subset of context tokens predicts that exact response token. With this binary utility, the exact Shapley value of every context token with respect to the response token follows from a dynamic-programming formula, so no sampling is required. The result is that attribution scores can be computed exactly and summed to sentence or response level.
Load-bearing premise
The method assumes a context token causes a response token only when their surface forms are identical under similar prefixes, so evidence expressed in paraphrased words would be invisible to the KNN vote.
Editorial extensions
If this is right
- Users of retrieval-augmented systems can point to the specific context token behind each generated number, name, or year, enabling fine-grained fact-checking.
- Because the scores are exact Shapley values, they are additively decomposable: summing them gives sentence-level or response-level attributions without re-running the algorithm.
- The datastore is built in one offline pass, so per-query cost stays small ($O(n)$ for $K=1$), making token-level attribution practical on long contexts.
- The method requires no fine-tuning and no access to model parameters beyond hidden-state embeddings, so it applies to any transformer LM that exposes activations.
Reading between the lines
- A natural stress test is paraphrase-heavy data: because the utility votes on exact token equality, TokenShapley should visibly lose accuracy when the response uses synonyms of the context evidence; a semantic label (e.g., nearest-embedding token) would be a testable fix.
- The method could be reused as a prompt-debugging probe: tokens in few-shot examples that earn high Shapley scores for an incorrect response token identify the misleading exemplars.
- Because the Shapley computation is exact rather than sampled, the resulting scores are stable and could serve as a training signal for context selection or for detecting verbatim copying, uses the paper does not explore.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper proposes TokenShapley, a token-level context attribution method for LLM responses. It constructs a KNN datastore from the context, defines a binary utility function that asks whether a weighted KNN vote over context tokens predicts the generated token exactly, and then applies the weighted KNN-Shapley algorithm of Wang et al. (2024) to compute Shapley values for each context token. The method is evaluated on QuoteSum, Verifiability-Granular, KV Retrieval, Natural Questions, and CNN/Dailymail, reporting improvements over sentence-level and embedding-similarity baselines, including an 11–23% accuracy gain on the first two datasets. The paper claims exact, polynomial-time Shapley computation without Monte Carlo sampling.
Significance. If the method delivered exact token-level Shapley values and a faithful model of how the LLM uses context, it would be a practically useful tool for fine-grained attribution, and the paper would make a solid contribution to interpretability. The evaluation is external to the Shapley computation, with no constants fitted to ground-truth attribution labels, which is a strength. However, the significance is currently conditional on two unresolved points: the utility function only rewards exact surface-token matches, and the implemented 'exact' computation truncates to the M=10 nearest neighbors. Both issues directly affect the central claim, so the paper's current framing overstates its contribution.
major comments (3)
- [§4.2, Eq. (7), and §8] The utility function v(S; \hat z_t) rewards a context token only when its surface form equals the generated token \hat y_t exactly. If \hat y_t never appears as a value y_j in the datastore (Eq. (6)), then for every non-empty S the matching sum in Eq. (7) is zero while the non-matching sum is positive, so v(S)=0. Together with the implicit convention v(\emptyset)=1 (the 0≥0 tie in Eq. (12)), every marginal contribution v(S∪{z_i})−v(S) is zero or negative, so no context token receives positive attribution. The method therefore cannot attribute paraphrased, inflected, or semantically equivalent evidence (e.g., 'liver toxicity' when the response says 'hepatotoxicity'). Because QuoteSum, KV Retrieval, and Natural Questions are dominated by verbatim copying, the reported 11–23% accuracy does not establish attribution for abstractive generation. The Limitations section only acknowledges exact token matching as a limitation for text-to-image, not for paraphrase in text; the general claim of token-level context attribution is broader than the implemented mechanism.
- [§4.3, Theorem 3, and §5] Section 4.3 states that 'we can further enhance efficiency by selecting only the M nearest neighbors and updating the Shapley value exclusively for the data points within these neighbors (K < M < N),' and Section 5 sets M=10. This truncation is an approximation, not an exact Shapley computation. In the exact weighted KNN-Shapley formula (Theorem 3), the sum over ℓ runs over all subsets S of D\{z_i}, and a data point outside the M nearest neighbors of \hat x can still satisfy Cond_{KNN} when S excludes enough closer points—for K=1, every point is the nearest neighbor of the empty or sufficiently small subset. Consequently, setting their Shapley values to zero changes the result. The contributions claim of 'exact token-level Shapley value calculation' and the claim that Monte Carlo sampling is eliminated are therefore overstated unless M=N or the paper provides a proof (absent here) that all excluded points have zero Shapley value.
- [§4.1, Algorithm 1, and §5] The paper does not specify which embedding function h(·) is used in the experiments. Algorithm 1 takes an 'Embedding model h(·)' as input, and Section 4.1 says 'We use the encoder h(·) of the embedding model,' but the experimental section never identifies this model or states whether it is the same LLM that generates the response. In KNN-LM, h(·) is the hidden-state function of the language model itself, and the utility in Eq. (7) inherits its meaning only in that setting. If h(·) is a separate embedding model, then TokenShapley attributes tokens according to a surrogate KNN classifier rather than the generating model, and the phrase 'context attribution for LLM responses' is not supported without a validation of the surrogate. The paper should either use the generating model's hidden states or clearly state and justify the surrogate choice.
minor comments (6)
- [§1 and Abstract] 'In context learning' should be 'In-context learning,' and the abstract's 'a 11–23%' should be 'an 11–23%.'
- [§3.2] The citation '(Jia et al., 2019b; ?)' contains a placeholder question mark and should be resolved.
- [§4.2, Eq. (12)] The tie convention 0≥0 makes v(\emptyset)=1; please state this explicitly because it affects Shapley values for small subsets and is not an innocent normalization.
- [Algorithm 1, line 4] The line 'find the nearest K neighbors (x_1,...,x_K)' should refer to key-value pairs, since datastore entries are (h(x_t), y_t).
- [Table 1] The EmbSim row reports a single number (53.38) without a model-specific breakdown; clarify whether this value is averaged over the three models.
- [Appendix C] The case study is useful but it illustrates the exact-match limitation: the sentence 'record for wins' receives a spurious score because of surface overlap with 'most wins.' A paragraph in Section 8 acknowledging this text-domain limitation would strengthen the paper.
Circularity Check
No significant circularity: the Shapley computation is self-contained and externally benchmarked; the exact-token utility is an explicit modeling choice, not a fitted input.
full rationale
The paper does not fit any parameter to ground-truth attribution labels and then rename the fit as a prediction. The utility function in Eq. 7 is an explicit definition: v(S; z_t) returns 1 when the weighted KNN vote for the response token y_t beats the vote for the other class. Shapley values are then computed exactly for that defined utility using the weighted KNN-Shapley theorem of Wang et al. (2024). Although one of the present authors co-authored that cited theorem, it is an external mathematical result about weighted nearest-neighbor classifiers, stated with assumptions and applicable beyond token attribution; its use is independent support rather than a self-citation chain that forces the paper's conclusion. The evaluation compares against external benchmarks with ground-truth labels (QuoteSum, Verifiability-Granular, KV Retrieval, Natural Questions, CNN/Dailymail), and the reported improvements are empirical rather than consequences of a fitting step. The exact-token utility in Eq. 7 does define attribution in terms of the response token's surface form, so the method cannot attribute paraphrased or inflected evidence; however, that is a scope limitation of the proposed definition, not a circular derivation. No equation reduces to its own input by construction, and no uniqueness claim is imported to forbid alternatives.
Assumptions & free parameters
free parameters (3)
- K (number of nearest neighbors) =
1
- M (number of neighbors updated with Shapley) =
10
- gamma (RBF kernel bandwidth)
assumptions (5)
- domain assumption A KNN classifier over prefix embeddings is a faithful proxy for how the LLM uses context.
- ad hoc to paper The correct prediction for a response token is defined as exact token equality with the label.
- ad hoc to paper The utility function in Equation 12 treats an empty context as a correct prediction (v(empty set) = 1).
- standard math The exact weighted KNN-Shapley theorem from Wang et al. 2024 applies to the binary utility function.
- domain assumption A datastore built only from the user-provided context is sufficient for attributing response tokens.
Cite this review
Pith. "Pith review of TokenShapley: Token Level Context Attribution with Shapley Value." pith.science (2026). https://pith.science/paper/7S7JZPZQ
@misc{pith2026250705261,
author = {Pith},
title = {Pith review of: TokenShapley: Token Level Context Attribution with Shapley Value},
year = {2026},
howpublished = {\url{https://pith.science/paper/7S7JZPZQ}},
note = {Machine review of arXiv:2507.05261}
}
read the original 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.
Figures
Reference graph
Works this paper leans on
-
[1]
Josh Achiam, Steven Adler, Sandhini Agarwal, Lama Ahmad, Ilge Akkaya, Florencia Leoni Aleman, Diogo Almeida, Janko Altenschmidt, Sam Altman, Shyamal Anadkat, et al. 2023. Gpt-4 technical report. arXiv preprint arXiv:2303.08774
arXiv 2023
-
[2]
Akari Asai, Zeqiu Wu, Yizhong Wang, Avirup Sil, and Hannaneh Hajishirzi. 2023. Self-rag: Learning to retrieve, generate, and critique through self-reflection. arXiv preprint arXiv:2310.11511
arXiv 2023
-
[3]
Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. 2020. Language models are few-shot learners. Advances in neural information processing systems, 33:1877--1901
2020
-
[4]
Jifan Chen, Grace Kim, Aniruddh Sriram, Greg Durrett, and Eunsol Choi. 2023. Complex claim verification with evidence retrieved in the wild. arXiv preprint arXiv:2305.11859
arXiv 2023
-
[5]
Eunsol Choi, He He, Mohit Iyyer, Mark Yatskar, Wen-tau Yih, Yejin Choi, Percy Liang, and Luke Zettlemoyer. 2018. Quac: Question answering in context. arXiv preprint arXiv:1808.07036
arXiv 2018
-
[6]
Benjamin Cohen-Wang, Harshay Shah, Kristian Georgiev, and Aleksander Madry. 2024. Contextcite: Attributing model generation to context. arXiv preprint arXiv:2409.00729
arXiv 2024
-
[7]
Christie Courtnage and Evgueni Smirnov. 2021. Shapley-value data valuation for semi-supervised learning. In Discovery Science: 24th International Conference, DS 2021, Halifax, NS, Canada, October 11--13, 2021, Proceedings 24, pages 94--108. Springer
work page 2021
-
[8]
Qiang Ding, Lvzhou Luo, Yixuan Cao, and Ping Luo. 2024. Attention with dependency parsing augmentation for fine-grained attribution. arXiv preprint arXiv:2412.11404
arXiv 2024
Show all 45 references
-
[9]
Qingxiu Dong, Lei Li, Damai Dai, Ce Zheng, Jingyuan Ma, Rui Li, Heming Xia, Jingjing Xu, Zhiyong Wu, Baobao Chang, et al. 2024. A survey on in-context learning. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pages 1107--1128
2024
-
[10]
Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Amy Yang, Angela Fan, et al. 2024. The llama 3 herd of models. arXiv preprint arXiv:2407.21783
2024 arXiv
-
[11]
Luyu Gao, Zhuyun Dai, Panupong Pasupat, Anthony Chen, Arun Tejasvi Chaganty, Yicheng Fan, Vincent Y Zhao, Ni Lao, Hongrae Lee, Da-Cheng Juan, et al. 2022. Rarr: Researching and revising what language models say, using language models. arXiv preprint arXiv:2210.08726
2022 arXiv
-
[12]
Amirata Ghorbani, James Zou, and Andre Esteva. 2022. Data shapley valuation for efficient batch active learning. In 2022 56th Asilomar Conference on Signals, Systems, and Computers, pages 1456--1462. IEEE
2022
-
[13]
Jocelyn Gravel, Madeleine D’Amours-Gravel, and Esli Osmanlliu. 2023. Learning to fake it: limited responses and fabricated references provided by chatgpt for medical questions. Mayo Clinic Proceedings: Digital Health, 1(3):226--234
2023
-
[14]
Roger Grosse, Juhan Bae, Cem Anil, Nelson Elhage, Alex Tamkin, Amirhossein Tajdini, Benoit Steiner, Dustin Li, Esin Durmus, Ethan Perez, et al. 2023. Studying large language model generalization with influence functions. arXiv preprint arXiv:2308.03296
2023 arXiv
-
[15]
Daya Guo, Dejian Yang, Haowei Zhang, Junxiao Song, Ruoyu Zhang, Runxin Xu, Qihao Zhu, Shirong Ma, Peiyi Wang, Xiao Bi, et al. 2025. Deepseek-r1: Incentivizing reasoning capability in llms via reinforcement learning. arXiv preprint arXiv:2501.12948
2025 arXiv
-
[16]
Zayd Hammoudeh and Daniel Lowd. 2022. Identifying a training-set attack's target using renormalized influence estimation. In Proceedings of the 2022 ACM SIGSAC Conference on Computer and Communications Security, pages 1367--1381
2022
-
[17]
Siqing Huo, Negar Arabzadeh, and Charles Clarke. 2023. Retrieving supporting evidence for generative question answering. In Proceedings of the Annual International ACM SIGIR Conference on Research and Development in Information Retrieval in the Asia Pacific Region, pages 11--20
2023
-
[18]
Ruoxi Jia, David Dao, Boxin Wang, Frances Ann Hubis, Nezihe Merve Gurel, Bo Li, Ce Zhang, Costas J Spanos, and Dawn Song. 2019 a . Efficient task-specific data valuation for nearest neighbor algorithms. Proceedings of the VLDB Endowment
2019
-
[19]
Ruoxi Jia, David Dao, Boxin Wang, Frances Ann Hubis, Nick Hynes, Nezihe Merve G \"u rel, Bo Li, Ce Zhang, Dawn Song, and Costas J Spanos. 2019 b . Towards efficient data valuation based on the shapley value. In The 22nd International Conference on Artificial Intelligence and S...
2019
-
[20]
Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. 2019. Generalization through memorization: Nearest neighbor language models. arXiv preprint arXiv:1911.00172
2019 arXiv
-
[21]
Pang Wei Koh and Percy Liang. 2017. Understanding black-box predictions via influence functions. In International Conference on Machine Learning, pages 1885--1894. PMLR
2017
-
[22]
Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, et al. 2019. Natural questions: a benchmark for question answering research. Transactions of the Association for C...
2019
-
[23]
Dongfang Li, Zetian Sun, Xinshuo Hu, Zhenyu Liu, Ziyang Chen, Baotian Hu, Aiguo Wu, and Min Zhang. 2023 a . A survey of large language models attribution. arXiv preprint arXiv:2311.03731
2023 arXiv
-
[24]
Minghan Li, Xilun Chen, Ari Holtzman, Beidi Chen, Jimmy Lin, Wen tau Yih, and Xi Victoria Lin. 2024. https://arxiv.org/abs/2405.19325 Nearest neighbor speculative decoding for llm generation and attribution . Preprint, arXiv:2405.19325
2024 arXiv
-
[25]
Xiaonan Li, Changtai Zhu, Linyang Li, Zhangyue Yin, Tianxiang Sun, and Xipeng Qiu. 2023 b . Llatrieval: Llm-verified retrieval for verifiable generation. arXiv preprint arXiv:2311.07838
2023 arXiv
-
[26]
Weixin Liang, Kai-Hui Liang, and Zhou Yu. 2021. Herald: An annotation efficient method to detect user disengagement in social conversations. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference o...
2021
-
[27]
Weixin Liang, James Zou, and Zhou Yu. 2020. Beyond user self-reported likert scale ratings: A comparison model for automatic dialog evaluation. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 1363--1374
2020
-
[28]
Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, and Percy Liang
Nelson F. Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, and Percy Liang. 2024. https://doi.org/10.1162/tacl_a_00638 Lost in the middle: How language models use long contexts . Transactions of the Association for Computational Linguistics, 12...
2024 doi
-
[29]
Bruno Mlodozeniec, Runa Eschenhagen, Juhan Bae, Alexander Immer, David Krueger, and Richard Turner. 2024. Influence functions for scalable data attribution in diffusion models. arXiv preprint arXiv:2410.13850
2024 arXiv
-
[30]
Ramesh Nallapati, Bowen Zhou, Caglar Gulcehre, Bing Xiang, et al. 2016. Abstractive text summarization using sequence-to-sequence rnns and beyond. arXiv preprint arXiv:1602.06023
2016 arXiv
-
[31]
Sung Min Park, Kristian Georgiev, Andrew Ilyas, Guillaume Leclerc, and Aleksander Madry. 2023. Trak: Attributing model behavior at scale. arXiv preprint arXiv:2303.14186
2023 arXiv
-
[32]
Anirudh Phukan, Shwetha Somasundaram, Apoorv Saxena, Koustava Goswami, and Balaji Vasan Srinivasan. 2024. Peering into the mind of language models: An approach for attribution in contextual question answering. arXiv preprint arXiv:2405.17980
2024 arXiv
-
[33]
Jirui Qi, Gabriele Sarti, Raquel Fern \'a ndez, and Arianna Bisazza. 2024. Model internals-based answer attribution for trustworthy retrieval-augmented generation. arXiv preprint arXiv:2406.13663
2024 arXiv
-
[34]
Dorian Quelle and Alexandre Bovet. 2024. The perils and promises of fact-checking with large language models. Frontiers in Artificial Intelligence, 7:1341697
2024
-
[35]
Abhilasha Sancheti, Koustava Goswami, and Balaji Vasan Srinivasan. 2024. Post-hoc answer attribution for grounded and trustworthy long document comprehension: Task, insights, and challenges. arXiv preprint arXiv:2406.06938
2024 arXiv
-
[36]
Tal Schuster, Adam D Lelkes, Haitian Sun, Jai Gupta, Jonathan Berant, William W Cohen, and Donald Metzler. 2023. Semqa: Semi-extractive multi-source question answering. arXiv preprint arXiv:2311.04886
2023 arXiv
-
[37]
Lloyd S Shapley. 1953. A value for n-person games. Contributions to the Theory of Games, 2(28):307--317
1953
-
[38]
Aviv Slobodkin, Eran Hirsch, Arie Cattan, Tal Schuster, and Ido Dagan. 2024. Attribute first, then generate: Locally-attributable grounded text generation. arXiv preprint arXiv:2403.17104
2024 arXiv
-
[39]
Zhiqing Sun, Xuezhi Wang, Yi Tay, Yiming Yang, and Denny Zhou. 2022. Recitation-augmented language models. arXiv preprint arXiv:2210.01296
2022 arXiv
-
[40]
Jiachen T Wang, Prateek Mittal, and Ruoxi Jia. 2024. Efficient data shapley for weighted nearest neighbor algorithms. In International Conference on Artificial Intelligence and Statistics, pages 2557--2565. PMLR
2024
-
[41]
Sheng Wang, Zihao Zhao, Xi Ouyang, Qian Wang, and Dinggang Shen. 2023. Chatcad: Interactive computer-aided diagnosis on medical image using large language models. arXiv preprint arXiv:2302.07257
2023 arXiv
-
[42]
according to
Orion Weller, Marc Marone, Nathaniel Weir, Dawn Lawrie, Daniel Khashabi, and Benjamin Van Durme. 2023. " according to...": Prompting language models improves quoting from pre-training data. arXiv preprint arXiv:2305.13252
2023 arXiv
-
[43]
Yue Zhang, Yafu Li, Leyang Cui, Deng Cai, Lemao Liu, Tingchen Fu, Xinting Huang, Enbo Zhao, Yu Zhang, Yulong Chen, et al. 2023. Siren's song in the ai ocean: a survey on hallucination in large language models. arXiv preprint arXiv:2309.01219
2023 arXiv
-
[44]
online" 'onlinestring :=
ENTRY address archivePrefix author booktitle chapter edition editor eid eprint eprinttype howpublished institution journal key month note number organization pages publisher school series title type volume year doi pubmed url lastchecked label extra.label sort.label short.list...
-
[45]
write newline
" write newline "" before.all 'output.state := FUNCTION n.dashify 't := "" t empty not t #1 #1 substring "-" = t #1 #2 substring "--" = not "--" * t #2 global.max substring 't := t #1 #1 substring "-" = "-" * t #2 global.max substring 't := while if t #1 #1 substring * t #2 gl...
Reviewed August 6, 2026 · model on record in the stance chip above.
Discussion (0). Sign in to comment.