Rare Event Analysis of Large Language Models

Jake McAllister Dorman (University of Nottingham), Edward Gillman, Dominic C Rose, Jamie Mair (University of Nottingham), Juan Garrahan

International Conference on Machine Learning 2026 · Oral

Overview

The evaluation of large language models (LLMs) typically relies on standard sampling techniques that probe model behavior within the bulk of its probability distribution. However, safety-critical faults, alignment failures, and edge-case hallucinations often manifest as rare events residing deep in the tails of these distributions. Standard testing regimens—even those spanning millions of samples—frequently fail to capture these catastrophic outliers because standard decoding methods allocate almost all compute to high-probability, mundane completions. This talk, presented by Jake McAllister Dorman at the International Conference on Machine Learning (ICML) on behalf of the Machine Learning and Science team in the Department of Physics at the University of Nottingham, introduces a principled statistical mechanics framework designed to systematically uncover, sample, and quantify rare unwanted completions in LLMs.

Watch on SlidesLive

Visual summary for Rare Event Analysis of Large Language Models by Jake McAllister Dorman, Edward Gillman, Dominic C Rose, Jamie Mair, Juan Garrahan
Visual summary for Rare Event Analysis of Large Language Models by Jake McAllister Dorman, Edward Gillman, Dominic C Rose, Jamie Mair, Juan Garrahan

Key moments

  1. 0:00 Introduction and the problem of rare events in LLMs
  2. 2:00 Importance sampling and proposal distributions
  3. 4:00 Exponentially reweighted distributions and the challenge of sampling
  4. 5:00 Transition Path Sampling methodology
  5. 7:30 Annealing, burn-in, and Gelman-Rubin convergence
  6. 9:50 Results using TinyStories and readability metrics
  7. 12:15 Conclusion and application to closed-source models

Rare Event Analysis of Large Language Models

Speakers: Jake McAllister Dorman (University of Nottingham); Edward Gillman; Dominic C Rose; Jamie Mair (University of Nottingham); Juan Garrahan

Conference: ICML

YouTube: https://slideslive.com/39083725

Overview

The evaluation of large language models (LLMs) typically relies on standard sampling techniques that probe model behavior within the bulk of its probability distribution. However, safety-critical faults, alignment failures, and edge-case hallucinations often manifest as rare events residing deep in the tails of these distributions. Standard testing regimens—even those spanning millions of samples—frequently fail to capture these catastrophic outliers because standard decoding methods allocate almost all compute to high-probability, mundane completions. This talk, presented by Jake McAllister Dorman at the International Conference on Machine Learning (ICML) on behalf of the Machine Learning and Science team in the Department of Physics at the University of Nottingham, introduces a principled statistical mechanics framework designed to systematically uncover, sample, and quantify rare unwanted completions in LLMs.

The core motivation centers on the scaling mismatch between testing and deployment. An LLM evaluated over $10^6$ test queries may appear entirely safe, yet when deployed at a scale of $10^9$ interactions, even an event with a true probability of $10^{-8}$ will manifest millions of times in production. To bridge this gap, the authors adapt advanced computational chemistry and statistical physics methodologies—specifically Markov Chain Monte Carlo (MCMC) sampling paired with importance sampling—to explore the extreme tails of language model output distributions. By reframing autoregressive text generation through the lens of physical systems, the framework achieves an effective $10^8$ improvement over direct sampling, successfully estimating event probabilities as low as $10^{-14}$ using only $10^6$ total samples.

Crucially, the method relies on mathematical cancellations that eliminate the need for direct access to model log probabilities. This architectural feature means the entire rare-event analysis pipeline can be deployed directly against closed-source, API-locked commercial models without requiring weight inspection, gradient access, or internal logits. This capability transforms how researchers and deployers can audit foundational models for compliance, toxicity, and failure modes that evade standard test suites.

Background

▶ Watch: Introduction and the problem of rare events in LLMs (0:00)

In machine learning systems engineering, quantifying the tail risk of generative models has historically been bottlenecked by the constraints of direct Monte Carlo estimation. When evaluating a text generation model with respect to an observable metric—such as toxicity scores, syntactic complexity, or alignment violations—standard inference strategies rely on drawing independent and identically distributed (IID) samples from the native model distribution (temperature-1 sampling). Because the overwhelming majority of probability mass is concentrated near the mean of the distribution, direct sampling wastes immense computational resources re-generating benign, expected responses while virtually never encountering low-probability tail events.

This limitation creates a false sense of security during pre-deployment evaluation phases. In statistical physics and computational chemistry, analogous challenges arise when studying rare molecular conformation changes, protein folding pathways, or chemical reactions, where thermal fluctuations rarely cross high energy barriers spontaneously. To solve this in the physical sciences, researchers developed sophisticated biased sampling techniques such as Transition Path Sampling (TPS), annealed importance sampling, and variational free energy estimation methods like the Multi-state Bennett Acceptance Ratio (MBAR).

Applying these physical chemistry methodologies to discrete, autoregressive sequence generation presents a distinct set of mathematical and algorithmic challenges. Text generation operates over discrete token spaces with variable-length sequences, whereas physical systems typically evolve over continuous spatial coordinates governed by differential equations. Furthermore, computing partition functions—normalizing constants over the combinatorial space of all possible token completions—is computationally intractable. Prior work in ML safety has often relied on adversarial prompt engineering, reinforcement learning from human feedback (RLHF) red-teaming, or heuristic search algorithms to discover failure modes. However, these techniques lack formal statistical guarantees regarding the true underlying probability of the uncovered events. The Nottingham group's work addresses this gap by establishing a rigorous statistical mechanics framework that maps discrete LLM text completions to continuous observable biases, enabling unbiased probability estimation in the deepest tails of language model distributions.

Key Findings

▶ Watch: Exponentially reweighted distributions and the challenge of sampling (4:00)

The primary contribution of this work is a rigorous, physics-inspired framework that enables the systematic exploration and probability estimation of rare text completions in large language models without requiring exhaustive brute-force sampling. By combining importance sampling with an exponentially reweighted proposal distribution, the authors demonstrate that extreme tail events can be sampled efficiently and reweighted to yield accurate population-level probability estimates.

Evaluating the framework on a TinyStories model—a language model intentionally trained on children's stories to provide an interpretable testbed with known training data boundaries—reveals several key findings:

  • Extreme Tail Reaches: The proposed methodology successfully penetrates deep into the probability distribution tails, reaching event likelihoods down to $10^{-14}$, whereas standard direct sampling (temperature-1) fails to observe events past $10^{-6}$ within equivalent compute budgets.
  • Quantified Efficiency Gains: The framework achieves a $10^8$ times improvement in sampling efficiency over direct model sampling, enabling the estimation of rare failure probabilities using only $10^6$ samples.
  • Extrapolation Beyond Training Data: By analyzing model behavior against the exact training corpus of the TinyStories model (where specific data bins contain fewer than 10 samples), the authors demonstrate how LLMs extrapolate into low-probability regimes that deviate substantially from their training distribution.
  • Black-Box Compatibility: Because the mathematical formulation causes the model's native log probabilities to cancel out during the importance sampling reweighting and MCMC acceptance steps, the entire pipeline operates effectively on black-source or closed-source models via standard completion APIs.

Technical Deep Dive

▶ Watch: Transition Path Sampling methodology (5:00)

The technical architecture of the rare-event analysis framework rests on three pillars: importance sampling with exponential biasing, Markov Chain Monte Carlo via Transition Path Sampling, and multi-state partition function estimation.

To overcome the inefficiency of sampling from the bulk of a model's distribution, the framework constructs proposal distributions that cover the domain of a target observable uniformly. The optimal proposal distribution, derived by minimizing the Kullback-Leibler (KL) divergence between the original model and the biased distribution, takes the form of an exponentially reweighted distribution:

$$P_{\lambda}(X) \propto P(X) e^{\lambda \mathcal{O}(X)}$$

where $P(X)$ is the probability of completion $X$, $\mathcal{O}(X)$ is a continuous observable metric (such as the Automated Readability Index (ARI) measuring text complexity), and $\lambda$ is a continuous bias parameter. By tuning $\lambda$, the expectation of the distribution is pushed toward the rare events of interest.

Sampling from this biased distribution directly is hindered by two computational bottlenecks: the intractable partition function $Z(\lambda)$ (the normalizing constant integrated over all possible completions), and the difficulty of mapping a whole-sequence probability distribution into autoregressive token-by-token generation probabilities. To bypass these issues, the authors employ Transition Path Sampling (TPS), a variant of Markov Chain Monte Carlo adapted from statistical physics.

The TPS algorithm proceeds iteratively:

  1. Current State: Given a prompt (e.g., "The sky is") and an existing token completion $X$ (e.g., "blue and cloudy"), evaluate its observable score $\mathcal{O}(X)$.
  2. Proposal Generation: Cut the completion sequence at a random index (e.g., after the word "blue") and regenerate the remaining suffix using the base language model (e.g., yielding "blue radiant and dazzling").
  3. Scoring: Compute the observable score for the newly proposed completion.
  4. Acceptance Criterion: Calculate the Metropolis-Hastings acceptance probability based on the change in observable values and the biasing parameter. If a randomly sampled uniform variate falls below the acceptance rate, accept the proposal as the new state; otherwise, retain the previous completion.

To ensure robust exploration across multiple energy barriers, the framework runs $C$ independent Markov chains in parallel (yielding Independent and Identically Distributed chains) using an annealing schedule that gradually ramps up the bias parameter $\lambda$. To eliminate initialization bias, the initial phase of each chain (the burn-in period) is discarded. Convergence across the parallel chains is rigorously evaluated using the Gelman-Rubin diagnostic ($\hat{R}$). Chains exhibiting a Gelman-Rubin value greater than $1.1$ are rejected, while converged chains ($\hat{R} < 1.1$) are retained for final analysis.

Finally, to compute accurate expectation values and probabilities via importance sampling, the intractable partition function $Z(\lambda)$ across different bias values is estimated using the Multi-state Bennett Acceptance Ratio (MBAR). MBAR ingests the matrix of converged data samples across all annealed $\lambda$ levels, outputting optimal free energy differences and normalizing constants. This enables the calculation of rigorous importance weights for every sampled completion, yielding unbiased probability estimates across the entire span of the observable domain.

Experimental Setup & Results

▶ Watch: Results using TinyStories and readability metrics (9:50)

The empirical evaluation utilizes the TinyStories model architecture, a deliberate choice that offers two distinct advantages. First, full access to the underlying training dataset enables exact identification of out-of-distribution (OOD) generations versus memorized training samples. Second, because TinyStories is trained exclusively on simple children's narratives, text complexity metrics (such as the Automated Readability Index) serve as clean, intuitive proxies for misalignment—complex, sophisticated, or formal technical text generated by the model represents an unwanted rare event.

The primary evaluation metrics include:

  • Automated Readability Index (ARI): A linguistic metric measuring text complexity, serving as the primary observable $\mathcal{O}(X)$ for biasing toward unwanted linguistic anomalies.
  • Log Probability: The sequence log probability of the completion under the target model.
  • Probability Estimates: Reconstructed probability density histograms spanning down to $10^{-14}$.

Headline Results

When comparing histograms generated via the proposed MCMC-importance sampling framework against standard temperature-1 direct sampling, the performance delta is stark. Standard direct sampling (visualized in orange) clusters tightly near the bulk of the distribution, failing to capture completions with high ARI scores. In contrast, the physics-informed framework (visualized in blue) successfully maps the distribution tails, generating reliable probability estimates down to $10^{-14}$ using a modest sample size of $10^6$ evaluations. This represents a confirmed $10^8$-fold improvement in tail-sampling reach compared to unguided inference. Furthermore, comparison against the training data distribution—specifically isolating regions where the training corpus contains fewer than 10 samples—demonstrates that the framework accurately quantifies how LLMs extrapolate deep into unsupported, low-probability syntactic spaces.

Practical Implications

▶ Watch: Conclusion and application to closed-source models (12:15)

For AI safety researchers, red-teaming practitioners, and infrastructure teams, this framework offers a rigorous mathematical alternative to heuristic prompt injection and brute-force stochastic testing. By decoupling rare-event analysis from model weight access, safety auditors can evaluate proprietary commercial APIs (such as closed-source foundation models) for catastrophic tail failures, toxic output probabilities, and extreme hallucination risks with formal statistical guarantees.

However, practitioners must navigate specific tradeoffs and limitations inherent to the methodology:

  • Choice of Observable: The accuracy and utility of the biased sampling depend entirely on the choice of the observable metric $\mathcal{O}(X)$. If the observable fails to capture the underlying failure mode or semantic property of interest, the MCMC sampler will efficiently explore irrelevant tails.
  • Computational Overhead: While exponentially more efficient than direct sampling for tail events, running multiple parallel Markov chains with annealing and MBAR partition function estimation introduces non-trivial computational and memory overhead during the evaluation phase.
  • Autoregressive Constraints: The sequence-cutting and suffix-regeneration steps in Transition Path Sampling require high query throughput against the target model API, making latency a practical consideration when auditing massive commercial models.

Key Takeaways

  • Physics-Informed LLM Auditing: Adapting statistical mechanics methods—specifically Markov Chain Monte Carlo and Transition Path Sampling—enables rigorous exploration of rare, unwanted LLM completions residing deep in distribution tails.
  • Quantified $10^8$ Speedup: The framework achieves a $10^8$ times improvement over direct sampling, successfully estimating event probabilities as low as $10^{-14}$ using only $10^6$ total samples.
  • Black-Box Applicability: Mathematical cancellation of model log probabilities during reweighting and acceptance steps allows the entire pipeline to audit closed-source, API-locked models without requiring internal weight or logit access.
  • Principled Tail Estimation: Combining exponentially reweighted proposal distributions with the Multi-state Bennett Acceptance Ratio (MBAR) provides unbiased probability estimators for critical safety metrics.
  • Rigor in Safety Testing: The methodology replaces ad-hoc adversarial prompting with formal statistical convergence diagnostics (such as the Gelman-Rubin metric) to validate that rare failure probability estimates are statistically sound.

About the Speaker(s)

  • Jake McAllister Dorman (University of Nottingham): Jake is from the University of Nottingham, Department of Physics, and is part of the Machine Learning and Science team. He is presenting the paper on Rare Event Analysis of Large Language Models.
  • Jamie Mair (University of Nottingham): Jamie is at the University of Nottingham, Department of Physics, as part of the Machine Learning and Science team, and is attending ICML.

Co-authors: Edward Gillman, Dominic C Rose, Juan Garrahan.

Reviews

→ Top-rated talks at International Conference on Machine Learning 2026

All talks from International Conference on Machine Learning 2026