Rare Event Estimation via Iterative Unalignment

Hanming Yang, Daksh Mittal, Jing Dong, Hongseok NamkoongarXiv 2026

TL;DR

Iterative Unalignment (IU) is a novel importance sampling method designed to estimate the probability of ultra-rare, catastrophic failures in autonomous LLM agents caused by stochastic generation. By directly perturbing language model weights via LoRA and utilizing an adaptive, reverse-KL regularization scheme, IU achieves over $800\times$ compute-weighted efficiency gains over naive Monte Carlo sampling, accurately estimating event probabilities as rare as $10^{-9}$.

What Problem Does This Paper Address?

As AI agents are granted more autonomy to execute code, manage file systems, and call APIs, safety concerns shift from can a catastrophic failure happen to how often will it happen? While adversarial "red teaming" focuses on finding inputs that trigger bad behavior, it doesn't quantify the residual risk of an agent failing due to pure stochastic variation during decoding on a fixed prompt.

Quantifying these rare tail risks (e.g., an agent accidentally deleting a production database) is mathematically daunting. If a failure occurs once in a billion rollouts ($10^{-9}$), a standard brute-force approach (Naive Monte Carlo) would require hundreds of billions of samples to get an accurate estimate. Traditional Importance Sampling (IS)—which samples from a "proposal" distribution that makes the rare event more common—fails here because the token sequence space is combinatorially massive ($|V|^L$). Small, uncoordinated changes at individual decoding steps compound exponentially, leading to extreme estimator variance or collapse.

Figure 2. Importance sampling with Iterative Unalignment for rare-event probability estimation. Naive Monte Carlo from the base model p rarely observes the rare target event (e.g., harmful generations triggered by the prompt), leading to severe under- or over-estimation of µ. Iterative Unalignment perturbs the base model’s weights to obtain the proposal qδ = pθ+δ, which yields a warped activation space in which the rare target is sampled with higher frequency. Reweighting the resulting samples by the importance ratio p(y)/qδ(y) yields an accurate estimator bµ.

Methods

The authors introduce Iterative Unalignment (IU), a gradient-based importance sampling framework that parameterizes the proposal distribution directly within the language model's weight space.

  1. Weight-Space Perturbations: Instead of shifting logits or activations, IU adds a trainable perturbation $\delta$ to the base model's weights $\theta$ using Low-Rank Adaptation (LoRA). The proposal model becomes $q_\delta = p_{\theta+\delta}$. This allows a single weight change to coherently alter prefix-dependent conditional distributions across the entire generation horizon.
  2. Differentiable Surrogates: Traditional rare-event methods use a single scalar score to both define the event and guide the search. IU decouples these: the event is defined by a strict binary indicator $\Phi$, while a separate, continuous, differentiable surrogate function $S_\delta$ (such as the step-averaged log-probability of target tokens) provides dense gradient signals to drive the model toward the rare event space.
  3. Adaptive Regularization: To prevent the model from collapsing onto a single, easily discovered path to the rare event (which causes severe "under-coverage" of other valid paths), the authors introduce a dense per-step reverse-KL regularizer. Crucially, the regularization strength $\lambda_t$ is adjusted dynamically online based on the Effective Sample Size ratio (ESSr) of the batch, balancing event amplification against estimator stability.

Datasets

Because verifying the ground truth of a $10^{-9}$ rare event is computationally impossible with standard text datasets, the authors constructed a controlled, highly verifiable deep-tail evaluation suite across two models: GPT-2 Small (~120M parameters) and Gemma-2 (~2.6B parameters).

The suite consists of three event families spanning over 300 rare events:

  • Token Presence: Estimating the probability of a specific rare token appearing anywhere in a generation of length $L$. This admits an exact, low-variance reference ground truth calculated directly from the base model's next-token probabilities.
  • Compositional Token Presence: Multi-token events requiring tokens to appear either in a strict order (Ordered Sequence) or any order (Conjunctive).
  • Profanity Classifier: A threshold-based event where text is flagged if a bag-of-words logistic regression profanity classifier score exceeds a high threshold $\kappa$.

Key Insights and Ideas

  • The Failure of Chi-Square / Advantage of Reverse-KL: In finite-batch settings, optimizing for the ideal chi-square divergence is highly unstable because it is heavily influenced by unobserved trajectories. Reverse-KL regularization, however, naturally penalizes the proposal for over-concentrating its probability mass, ensuring it broadly covers the diverse ways a rare event can manifest.
  • Weight Space Wins Over Activation Space: Modifying weights via LoRA provides the necessary expressivity to coordinate complex, multi-step sequence changes. Simpler baselines that steer generations via logit or activation offsets fail to maintain efficiency on longer generation horizons.
Figure 1. The challenge is to amplify event trajectories broadly and by similar factors. Black and red numbers show token probabilities under the base and proposal models, respectively. Their products give the sequence probabilities shown on the right. Red shading marks harmful outputs. We seek a proposal that assigns higher probability to every event trajectory, with similar amplification factors so that importance weights remain stable. This requires coordinating probability changes across the full sequence and across the many ways the event can occur.

Key Results

  • Massive Efficiency Gains: For ultra-rare events (probabilities between $10^{-7}$ and $10^{-9}$), IU achieved over $800\times$ compute-weighted efficiency gains over Naive Monte Carlo, factoring in both the upfront cost of training the proposal and the final sampling cost.
  • Deep-Tail Accuracy: After training, IU required as few as 128 samples to yield stable estimates within 1.2 orders of magnitude of the true probability for events below $10^{-7}$.
  • Baseline Outperformance: IU significantly outperformed standard Cross-Entropy (CE) optimization and score-guided MCMC methods. In fact, sequence-space MCMC samplers failed to record a single event hit for events with true probabilities below $10^{-5}$, whereas IU consistently succeeded.

Limitations and Future Work

  • Verifiability in the Wild: The current evaluation relies on token-based and bag-of-words classifiers where exact or brute-force reference probabilities can be computed. Evaluating complex, multi-step tool-use failures in real-world environments remains difficult due to the lack of verifiable ground truth.
  • Scaling to Large Vocabularies: While highly effective on GPT-2, the efficiency gains were lower on Gemma-2. The authors hypothesize that Gemma-2's massive vocabulary size (256,000 tokens vs. GPT-2's 50,257) makes controlling importance weights significantly harder, indicating a need for more advanced surrogate designs and regularization schemes in larger models.

Summary updated

BibTeX
@misc{yang2026rare,
  author = {Hanming Yang and Daksh Mittal and Jing Dong and Hongseok Namkoong},
  title = {{Rare Event Estimation via Iterative Unalignment}},
  year = {2026},
  eprint = {2609.24969},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.24969},
}
Figure