Statistical Hypothesis Testing for Auditing Robustness in Language Models Paulius Rauba; Qiyao Wei; Mihaela van der Schaar ICML 2025 Original record: https://proceedings.mlr.press/v267/rauba25a.html Original PDF: https://raw.githubusercontent.com/mlresearch/v267/main/assets/rauba25a/rauba25a.pdf Original paper text extracted automatically from the PDF. Equations, tables and layout may be imperfect in this representation; consult the PDF for exact notation and reported values. This is the original research text, distinct from the language-model-generated explanation on the landing page. === PDF PAGE 1 === Statistical Hypothesis Testing for Auditing Robustness in Language Models Paulius Rauba 1 Qiyao Wei 1 Mihaela van der Schaar 1 Abstract Consider the problem of testing whether the out- puts of a large language model (LLM) system change under an arbitrary intervention, such as an input perturbation or changing the model vari- ant. We cannot simply compare two LLM out- puts since they might differ due to the stochastic nature of the system, nor can we compare the entire output distribution due to computational intractability. While existing methods for analyz- ing text-based outputs exist, they focus on fun- damentally different problems, such as measur- ing bias or fairness. To this end, we introduce distribution-based perturbation analysis, a frame- work that reformulates LLM perturbation analysis as a frequentist hypothesis testing problem. We construct empirical null and alternative output dis- tributions within a low-dimensional semantic sim- ilarity space via Monte Carlo sampling, enabling tractable inference without restrictive distribu- tional assumptions. The framework is (i) model- agnostic, (ii) supports the evaluation of arbitrary input perturbations on any black-box LLM, (iii) yields interpretable p-values; (iv) supports multi- ple perturbations via controlled error rates; and (v) provides scalar effect sizes. We demonstrate the usefulness of the framework across multiple case studies, showing how we can quantify response changes, measure true/false positive rates, and evaluate alignment with reference models. Above all, we see this as a reliable frequentist hypothesis testing framework for LLM auditing. 1. Introduction Large language models (LLMs) generate outputs condi- tioned on textual inputs by iteratively sampling from a dis- tribution of tokens. Therefore, the outputs of LLMs exhibit 1University of Cambridge. Correspondence to: Paulius Rauba . Proceedings of the 42 nd International Conference on Machine Learning, Vancouver, Canada. PMLR 267, 2025. Copyright 2025 by the author(s). inherent variability due to the stochastic sampling process, a process controlled via parameters such as temperature or top- k (Renze & Guven, 2024). This means that evaluating how interventions—such as input perturbations, model variant changes, prompt system modifications—affect the output, is not straightforward (Romero-Alvarado et al., 2024). Under- standing and quantifying the effects of such perturbations is crucial in high-stakes applications—such as legal document drafting or medical diagnosis—where errors or unintended behavior could have significant consequences (Meskó & Topol, 2023; Helberger et al., 2023). Systematic evaluation of output responses to input pertur- bation is fundamental to comprehending LLM behavior. It provides quantitative insights into model robustness and output consistency across diverse input conditions. Statisti- cal hypothesis testing of model responses can be used for quantifying these effects and isolating the effects of ran- dom variability. There are multiple examples where this is directly relevant. First, it helps with vulnerability identifica- tion by quantifying potential vulnerabilities to adversarial attacks (Goodfellow et al., 2014). Second, it aids with bias discovery, whereby latent biases or unintended behaviors may not become apparent through single-dimension audit- ing approaches (Ribeiro et al., 2016). Third, it can work within a compliance framework. Measurable frameworks for assessing model behavior are essential for compliance with emerging ethical and legal accountability regulations (Doshi-Velez et al., 2017). In the context of language mod- els, subtle changes in patient history could lead to wildly different diagnoses; and patients with nearly identical health records might receive drastically different treatment plans due to minor grammatical changes. Given these critical functions, there is a clear need for a comprehensive LLM auditing framework centered around reliable statistics tools. Current methods for analyzing LLM behavior changes of- ten focus on simplistic metrics, such as word overlap or direct log-probability comparisons. While effective in cer- tain cases, these approaches fail to account for the nuanced, high-dimensional nature of semantic information processed by LLMs (Bhandari et al., 2020; Lin, 2004). Moreover, existing methods typically lack rigorous statistical founda- tions, making it difficult to disentangle meaningful changes in model behavior from intrinsic randomness in the output generation process. Efforts to address this have included 1 === PDF PAGE 2 === Statistical Hypothesis Testing in Language Models specialized attribution methods, feature importance tech- niques, and counterfactual reasoning frameworks (Ribeiro et al., 2016; Garg et al., 2019). However, these approaches are often model-specific, rely on restrictive assumptions about the data or model, or fail to provide interpretable and generalizable metrics. Our solution. In this work, we introduce distribution-based perturbation analysis (DBPA), a framework that reformu- lates the problem of LLM perturbation analysis as a fre- quentist hypothesis testing task. DBPA constructs empirical output distributions using Monte Carlo sampling to cap- ture the inherent stochasticity of LLMs, and enables sta- tistical hypothesis testing of perturbation effects within a low-dimensional semantic similarity space. By using statis- tical hypothesis testing, the framework enables robust, inter- pretable inferences about whether and how input perturba- tions meaningfully influence LLM outputs. DBPA is model- agnostic, computationally efficient, and flexible enough to accommodate arbitrary perturbations on any black-box LLM. It also provides interpretable p-values, scalar effect sizes, and supports multiple testing with controlled error rates, making it a versatile tool for post-hoc interpretability and reliability assessments of LLMs.1 ­ Contributions. 1⃝We identify limitations in exist- ing methods for evaluating language model outputs (Sec. 2). 2⃝We introduce distribution-based pertur- bation analysis which is a model-agnostic sensitivity technique that can test the effect of any perturba- tion with statistical significance measures (Sec. 3). 3⃝We perform multiple case studies to show the usefulness of DBPA (Sec. 4). 2. An analysis of viewing LLM outputs through frequentist hypothesis testing 2.1. Problem formulation Let X denote the input space and Y the output space of a machine learning system. We define the system as a stochastic mapping S : X →P(Y), where P(Y) is the space of probability distributions over Y. This formulation captures the inherent stochasticity of modern ML systems, including LLMs. Our objective is to address the following research question: Given an ML system S, an input x ∈X, and an input perturbation ∆x, how can we systematically measure and interpret the impact of ∆x on the output distribution of S(x) under a general notion of sensitivity? Definition 2.1 (Sensitivity). The sensitivity of a machine learning system S with respect to an input perturbation ∆x : 1Code can be found at https://github.com/vanderschaarlab/dbpa X →X, or a system perturbation ∆S : S →S, at input x ∈ X, is characterized by a non-negative discrepancy measure d between the output distributions S(x) and S(∆x(x)), or S(x) and ∆S(S)(x), respectively. We aim to perform statistical hypothesis testing on black- box LLMs S with respect to the system and input. Therefore, (i) we do not assume access to the underlying system’s parameters, such as their weights or biases; and (ii) we make no assumptions about access to ground-truth labels, as the evaluation is done with respect to the generated outputs of the system. 2.2. Distribution testing as a frequentist hypothesis-testing problem The challenge of assessing the sensitivity of S can be re- framed as a frequentist hypothesis testing problem. A com- mon approach involves querying a language model once to obtain an answer, modifying the input, querying again, and comparing the outputs: y ∼S(x), y′ ∼S(x′). (1) This approach suffers from high variance and therefore low statistical efficiency due to the stochastic nature of LLM sys- tems. Since S(x) generates a random variable for any fixed input x, both y and y′ represent single realizations from a distribution of outputs. Any observed difference between y and y′ could therefore arise from inherent randomness rather than a true effect of ∆x. To address this limitation, we propose reframing the prob- lem from the lens of distribution testing. Instead of com- paring individual outputs, we would ideally like to compare the entire output distributions. For notational convenience, let Dx := S(x) denote the output distribution for input x. Let Yx and Yx′ be random variables where Yx ∼Dx and Yx′ ∼Dx′. Definition 2.2 (Output Distribution). For a given input x ∈ X and an LLM S : X →P(Y), the output distribution Dx is the probability distribution from which the random variable Yx is drawn when generated by S(x). That is, Yx ∼Dx. The probability mass function is given by: px(y) = P(Yx = y), ∀y ∈Y. (2) Our goal is to determine whether these distributions differ significantly. This can be formulated as a hypothesis test: H0 : Dx = Dx′ (The perturbation has no effect) (3) H1 : Dx ̸= Dx′ (The perturbation has an effect) (4) Here, x′ := ∆x(x) is shorthand for the perturbed input. The primary benefit of such a distributional formulation is that it 2 === PDF PAGE 3 === Statistical Hypothesis Testing in Language Models captures the full stochastic behavior of S instead of just a single realization. This means we could perform statistical inference by directly comparing these distributions and un- derstanding how much the outputs have shifted across the whole output space, such detecting subtle shifts that might not be apparent from individual samples. ­ Takeaway. To understand the sensitivity of a lan- guage model to changes in input, we need to look at the entire range of possible outputs it can produce, not just single examples. Clearly, there are challenges in directly using this framework in the context of language models: how do we practically estimate Dx or how to practically interpret it? We discuss these questions next. 2.3. Challenges with analyzing output distributions There are two primary challenges in comparing output distri- butions to evaluate the effect of an input perturbation on the output: computational intractability and poor interpretabil- ity. ▶Challenge 1: Computational intractability. Even when we restrict the language model to sequences of a fixed length L, the output space is exponential: Y = V L with |Y| = |V |L. For a given input x, the distribution Dx is fully described by its probability mass function px(y) = L Y t=1 p yt | y