NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Estimating the Probabilities of Rare Outputs in Language Models

Gabriel Wu, Jacob Hilton

The Challenge of Rare, High-Stakes Failures

Modern machine learning models are typically optimized for average-case performance. However, when deploying systems where safety is critical—such as preventing "jailbreaks" or catastrophic "deceptive alignment"—we must account for the worst-case scenarios.

The primary challenge is that dangerous behaviors might be incredibly rare under normal conditions, perhaps occurring with a probability of $10^{-9}$. Finding or measuring these events using naive random sampling is computationally intractable, as it would require billions of model calls to observe a single failure. Yet, under distribution shifts or adversarial attacks, these seemingly "impossible" events can suddenly become common. To build truly safe systems, we need methods to accurately estimate these microscopic probabilities using a limited computational budget. This paper evaluates techniques for low probability estimation (LPE) in language models to address this exact gap.

Methodology: Finding the Needle in the Haystack

To evaluate different LPE techniques, the researchers established a rigorous testing pipeline. They created eight formally defined input distributions (e.g., hexadecimal strings, CamelCase Python tokens) and established a "ground truth" by running a massive $2^{32}$ (approx. 4.3 billion) samples per distribution on small transformer models. They then challenged four LPE methods to estimate those same probabilities using only $2^{16}$ (65,536) samples.

Evaluation pipeline comparing brute-force naive sampling against low probability estimation (LPE) methods using Itakura-Saito loss.

The authors compared two distinct philosophies for estimating these rare events:

1. Importance Sampling (Search-Based)

These methods attempt to find a "warped" version of the input distribution where the rare event is common, then mathematically "un-warp" the results to get an unbiased estimate for the original distribution.

  • ITGIS (Independent Token Gradient Importance Sampling): Uses gradients to identify which individual tokens increase the probability of the rare output, assuming tokens contribute independently.
  • MHIS (Metropolis–Hastings Importance Sampling): A more sophisticated Markov Chain Monte Carlo (MCMC) approach that captures non-linear interactions between tokens (e.g., when a model only fails if token A and token B appear together).

2. Activation Extrapolation (Modeling-Based)

Instead of searching for specific inputs, these methods analyze the model's internal activations and predict how often they might cross a failure threshold.

  • QLD (Quadratic Logit Decomposition): The paper's most novel contribution. It decomposes internal activations into uncorrelated subspaces. By assuming these subspaces are independent, it synthetically creates a massive number of activation combinations, effectively squaring the number of samples available for estimation.
  • GLD (Gaussian Logit Difference): A simple baseline that fits a Gaussian distribution to the difference between the "winning" logit and the "target" logit.

Key Insights and Results

The overall ranking of the methods demonstrated that search-based approaches currently outperform modeling-based ones: Importance Sampling (MHIS/ITGIS) > Activation Extrapolation (QLD) > Simple Gaussian (GLD) > Naive Sampling.

The best methods successfully distinguished between probabilities of $10^{-9}$ and $10^{-5}$ using only $2^{16}$ samples—a scenario where naive sampling would almost always return zero. Performance was measured using Itakura–Saito loss, which is sensitive to ratios rather than absolute differences, ensuring that missing a $10^{-9}$ event by an order of magnitude is penalized as heavily as missing a $10^{-2}$ event by the same factor.

Comparison of MHIS, ITGIS, and QLD estimates against ground truth across different model behaviors and depths. MHIS consistently tracks the ground truth most closely.

A critical finding was the Complexity Shift. As models get deeper (e.g., moving from 1 to 4 layers), MHIS begins to significantly outperform ITGIS. This suggests that as models grow, their rare behaviors rely less on individual "bad tokens" and more on complex, non-linear interactions between tokens that ITGIS fails to capture.

Meanwhile, QLD introduced a fascinating "independence hack." By relying on the presumption of independence between uncorrelated parts of a model's internal state, QLD can mix-and-match activations to simulate what could have happened, turning 65,000 samples into the equivalent of billions of synthetic samples.

Limitations and the Path Forward

While the results are promising, the study has notable limitations:

  • Scale: The experiments were limited to small models (up to 4 layers). It remains an open question whether these internal activation patterns hold for modern, billion-parameter LLMs.
  • Input Structure: The tested input distributions were independent (each token chosen without depending on the previous one). Real-world language contains deep dependencies that might violate the assumptions underlying ITGIS and QLD.
  • Scope of Failure: The paper focuses on the probability of a single rare token being output. Real-world safety concerns usually involve long strings of text, such as a complete jailbroken response.

Ultimately, while search-based methods like Importance Sampling win today, they act like "red-teaming with a calculator" and can be fooled if a model hides its bad behavior in a tiny, hard-to-find corner of the input space. The authors argue that we ultimately need better modeling-based methods (like QLD) to provide robust, mechanistic safety guarantees that don't rely solely on brute-force search.

Summary updated

BibTeX
@inproceedings{wu2025estimating,
  author = {Gabriel Wu and Jacob Hilton},
  title = {{Estimating the Probabilities of Rare Outputs in Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=DC8bsa9bzY},
}
Figure