AISTATS 2025 · LLM auditing & interpretability
Visualizing token importance for black-box language models
Conference paper · University of Cambridge
Paulius Rauba and Qiyao Wei contributed equally.
Proceedings of The 28th International Conference on Artificial Intelligence and Statistics 258, 4105–4113 (2025)
Original abstract
We consider the problem of auditing black-box large language models (LLMs) to ensure they behave reliably when deployed in production settings, particularly in high-stakes domains such as legal, medical, and regulatory compliance. Existing approaches for LLM auditing often focus on isolated aspects of model behavior, such as detecting specific biases or evaluating fairness. We are interested in a more general question—can we understand how the outputs of black-box LLMs depend on each input token? There is a critical need to have such tools in real-world applications that rely on inaccessible API endpoints to language models. However, this is a highly non-trivial problem, as LLMs are stochastic functions (i.e. two outputs will be different by chance), while computing prompt-level gradients to approximate input sensitivity is infeasible. To address this, we propose Distribution-Based Sensitivity Analysis (DBSA), a lightweight model-agnostic procedure to evaluate the sensitivity of the output of a language model for each input token, without making any distributional assumptions about the LLM. DBSA is developed as a practical tool for practitioners, enabling quick, plug-and-play visual exploration of LLMs reliance on specific input tokens. Through illustrative examples, we demonstrate how DBSA can enable users to inspect LLM inputs and find sensitivities that may be overlooked by existing LLM interpretability methods.
Distribution-Based Sensitivity Analysis visualizes which input tokens change a black-box LLM’s response distribution. It uses nearby token substitutions and repeated output samples, so the analysis can be performed without weights, gradients or attention maps.
Which words actually change a black-box LLM’s answers?#
A language model can depend strongly on some parts of a prompt and weakly on others. For a model accessed through an API, however, a practitioner may have no access to weights, gradients or attention maps. Even comparing responses after changing a word is difficult: repeated responses vary without any input change.
Distribution-Based Sensitivity Analysis (DBSA) is a practical method for visualizing token-level sensitivity in that setting. It perturbs input tokens, samples responses repeatedly, and measures changes in their output distributions. The visualization is tied to a defined intervention and sampling procedure rather than to a single illustrative response.
How the method works#
DBSA identifies token positions and constructs nearby replacements using an embedding-based neighborhood. It then compares responses to the original prompt with responses to prompts containing those replacements. This lets the analysis explore local changes in a discrete input space, where an infinitesimal gradient is unavailable.
The outputs are compared through semantic representations. Within-condition and cross-condition comparisons help separate normal variability from the effect of the substitution. The paper develops a finite-sample sensitivity estimate and discusses energy distance as a useful distributional comparison.
The resulting measurements can be aggregated over nearby substitutions and displayed as a heatmap over the input. A token with a larger measured effect is a location where the chosen perturbations caused a larger change in sampled responses. That is an operational definition of sensitivity; it is not a direct view into the model’s hidden reasoning.
What a visualization can reveal#
The paper gives illustrative legal and clinical-support prompts. In the legal example, colored tokens make it easier to inspect which contractual terms are associated with stronger response changes. In the clinical example, it reports both effect sizes and p-values for selected words.
Those examples demonstrate the form of an audit. They do not establish that a legal or clinical system is safe to deploy. A word can strongly influence an answer for an appropriate reason, or an inappropriate one; interpreting the visualization still requires domain knowledge.

Original Figure 2. The comparison illustrates that sensitivity patterns can differ between models. Source: Section 6.1, CC BY 4.0.
The following selected values come from Table 3, which uses the illustrative clinical-support prompt. None of these examples passes the paper’s stated 0.05 significance threshold. Ranking words by an estimated effect is therefore different from declaring a statistically supported change.
| Perturbed word | Reported effect size | Reported p-value |
|---|---|---|
| congestive | 0.08 | 0.11 |
| examination | 0.07 | 0.16 |
| hypertensive | 0.06 | 0.31 |
What the experiments investigate#
Beyond the illustrative prompts, the paper examines differences across language models, agreement between sensitivity rankings, alternative similarity functions, Monte Carlo sample sizes and perturbation choices. This helps identify which aspects of the procedure influence a resulting visualization.
The cross-model comparison is useful because a sensitivity map is a property of a particular model under a particular test setup. A token that matters for one system need not matter equally for another. Likewise, changing the embedding or neighborhood used to define “nearby” substitutions can change what is being measured.
These experiments are best read as an investigation of a practical auditing tool. They are not a general ranking of models by correctness or safety.
How this relates to DBPA#
The related Distribution-Based Perturbation Analysis papers ask whether arbitrary interventions change an LLM’s response distribution. DBSA focuses on token-level sensitivity and an interface that makes the results easy to inspect visually.
The shared idea is to account for stochastic outputs using repeated samples. The procedures and inferential details should still be taken from the relevant paper. A reader reproducing token-importance plots should follow the DBSA implementation; a reader performing the ICML permutation test should follow that paper’s raw-output resampling procedure.
Scope and limitations#
Token replacement can alter grammar or introduce a stronger semantic change than intended. A nearest neighbor in an embedding space is not guaranteed to preserve meaning in the full sentence. The perturbation neighborhood is therefore part of the experiment, not a neutral implementation detail.
Finite sampling introduces uncertainty, and repeated calls can be costly for long prompts. The semantic representation may also miss distinctions that matter to the user. A small measured response change does not prove that a token is irrelevant in every context, and a large change does not establish a causal explanation of the model’s internal mechanism.
When testing many tokens, statistical interpretation should account for multiplicity and for the sampling assumptions of the chosen procedure. The visual ranking is most useful when accompanied by the perturbation definition, sample count and uncertainty information.
Questions about the paper#
Does DBSA need attention weights or gradients?#
No. It is designed for black-box access and uses sampled model responses together with input and output representations.
Does a highlighted word explain the model’s reasoning?#
It indicates sensitivity to the tested substitutions. It does not expose the model’s internal chain of computation or prove that the model used the word in a human-like way.
Can the same prompt have different importance maps across models?#
Yes. The paper explicitly investigates differences in token sensitivities and rankings across language models.
Sources and implementation#
The authoritative publication is AISTATS 2025, PMLR volume 258, pages 4105–4113. Sections 3–4 describe DBSA; Sections 5–6 provide examples and experiments. The authors’ visualizing-token-importance repository contains code and experiment material. Paulius Rauba and Qiyao Wei are equal contributors.
Use in your work
Cite this paper
Cite the original research below. This generated explanation is a reading aid.
Rauba, P., Wei, Q., & van der Schaar, M. (2025). Visualizing token importance for black-box language models. Proceedings of The 28th International Conference on Artificial Intelligence and Statistics, 258, 4105–4113. https://proceedings.mlr.press/v258/rauba25a.html
BibTeX
@InProceedings{pmlr-v258-rauba25a,
title = {Visualizing token importance for black-box language models},
author = {Rauba, Paulius and Wei, Qiyao and van der Schaar, Mihaela},
booktitle = {Proceedings of The 28th International Conference on Artificial Intelligence and Statistics},
pages = {4105--4113},
year = {2025},
editor = {Li, Yingzhen and Mandt, Stephan and Agrawal, Shipra and Khan, Emtiyaz},
volume = {258},
series = {Proceedings of Machine Learning Research},
month = {03--05 May},
publisher = {PMLR},
pdf = {https://raw.githubusercontent.com/mlresearch/v258/main/assets/rauba25a/rauba25a.pdf},
url = {https://proceedings.mlr.press/v258/rauba25a.html},
abstract = {We consider the problem of auditing \emph{black-box} large language models (LLMs) to ensure they behave reliably when deployed in production settings, particularly in high-stakes domains such as legal, medical, and regulatory compliance. Existing approaches for LLM auditing often focus on isolated aspects of model behavior, such as detecting specific biases or evaluating fairness. We are interested in a more general question—can we understand how the outputs of black-box LLMs depend on \emph{each input token}? There is a critical need to have such tools in real-world applications that rely on inaccessible API endpoints to language models. However, this is a highly non-trivial problem, as LLMs are stochastic functions (i.e. two outputs will be different by chance), while computing prompt-level gradients to approximate input sensitivity is infeasible. To address this, we propose Distribution-Based Sensitivity Analysis (DBSA), a lightweight model-agnostic procedure to evaluate the sensitivity of the output of a language model for each input token, without making any distributional assumptions about the LLM. DBSA is developed as a \emph{practical tool} for practitioners, enabling quick, plug-and-play visual exploration of LLMs reliance on specific input tokens. Through illustrative examples, we demonstrate how DBSA can enable users to inspect LLM inputs and find sensitivities that may be overlooked by existing LLM interpretability methods.}
}