Top-nσ: Eliminating Noise in Logit Space for Robust Token Sampling of LLM

Chenxia Tang, Jianchun Liu, Hongli Xu, Liusheng HuangACL 2025

TL;DR

Researchers have introduced Top-nσ, a novel LLM sampling method that operates directly in the logit space rather than probability space. By identifying informative tokens as statistical outliers relative to a Gaussian "noise" background, Top-nσ achieves temperature-invariant sampling, maintaining high generation quality even at extreme temperatures where traditional methods like top-$p$ and min-$p$ fail.

What Problem Does This Paper Address?

The "creativity vs. quality" trade-off in Large Language Models (LLMs) is typically managed by the temperature ($T$) parameter. Lower temperatures make models predictable and repetitive; higher temperatures encourage diversity but often introduce "noise"—invalid tokens, hallucinations, or grammatical collapses.

Existing truncation methods like top-$k$, top-$p$ (nucleus sampling), and the more recent min-$p$ all share a common flaw: they rely on probability-based metrics. Because the softmax function exponentially squashes logits into probabilities, these methods are highly sensitive to temperature scaling. At high temperatures, the probability distribution flattens, causing these filters to let in too much noise. The authors set out to find a sampling criterion that remains stable regardless of how "hot" the model is running.

Methods

The core innovation of this paper is moving the filtering process from probability space to logit space (the raw, pre-softmax outputs of the model).

  1. Statistical Observation: The authors discovered that LLM logits naturally separate into two components: a Gaussian-distributed background (representing noise) and a few statistical outliers (representing informative, valid tokens).
  2. The Top-nσ Algorithm: Instead of looking at cumulative probability, Top-nσ calculates a dynamic threshold based on the maximum logit ($M$) and the standard deviation ($\sigma$) of the entire logit distribution.
  3. A token $i$ is kept if its logit $l_i \ge M - n\sigma$.
  4. $n$ is a user-defined multiplier (the authors recommend $n=1.0$ as a robust default).
  5. Temperature Invariance: Mathematically, temperature scaling ($l/T$) affects both the maximum logit and the standard deviation proportionally. Therefore, the relative distance $(M - l_i) / \sigma$ remains constant. This makes the set of candidate tokens selected by Top-nσ identical regardless of the temperature setting.

Datasets

The authors evaluated Top-nσ across several challenging benchmarks using LLaMA-3 (8B/70B) and Qwen2.5 (14B/32B) models:

  • Reasoning Tasks: AQuA (algebra), GSM8K (grade school math), MATH500 (competition math), and GPQA-main (graduate-level science).
  • Creative Writing: A collection of 500 diverse writing prompts evaluated using a "win rate" metric judged by DeepSeek-V3 against greedy decoding.

Key Insights and Ideas

  • The "Aha" Moment in Logit Space: Traditional methods struggle because softmax "hides" the underlying statistical structure of the model's choices. By looking at logits, the authors found a clear "gap" between valid candidates and noise that is much easier to target.
  • Mathematical Equivalence: The paper proves that under a uniform distribution assumption, min-$p$ is actually mathematically equivalent to top-($1-p$). This theoretical bridge helps explain why min-$p$ was an improvement over top-$p$, but also why it still fails at high temperatures.
  • Robustness to Hyperparameters: While top-$k$ depends on vocabulary size and top-$p$ is highly sensitive to $T$, Top-nσ is remarkably stable. The authors derived a theoretical upper bound for $n \le 3.46$, providing a grounded range for tuning.
  • Efficiency: Because it avoids the sorting and cumulative sum operations required by top-$p$, Top-nσ is computationally efficient and can be implemented in just two lines of code.

Key Results

  • Extreme Temperature Stability: On the AQuA reasoning dataset with LLaMA-3-8B, Top-nσ maintained 50% accuracy at $T=4.0$, whereas top-$p$ and top-$k$ crashed to 0% and 0.39% respectively.
  • Superior Creative Writing: Top-nσ achieved the highest win rates (up to 56.40%) against greedy decoding, proving it doesn't sacrifice creativity for its robustness.
  • Better Scaling with Repetition: In "Majority@N" sampling (where the model generates $N$ answers and picks the most frequent), Top-nσ reached a final accuracy of ~93% on GSM8K, showing much smoother and higher performance gains as $N$ increased compared to other methods.

Limitations and Future Work

  • Static $n$: The current method uses a fixed multiplier $n$. The authors acknowledge that a dynamic $n$ that adapts to the model's confidence level for specific tokens might be even more precise.
  • Idealized Assumptions: The theoretical proofs rely on a uniform distribution assumption for informative tokens, which is a simplification of real-world LLM behavior.
  • Domain Scope: While reasoning and writing were covered, the authors suggest further testing in specialized domains like code generation.
  • Sequence-Level Impact: The study focuses on token-level sampling; the long-term impact on global sequence coherence at extremely high temperatures is still an open area for investigation.

Summary updated

BibTeX
@inproceedings{tang2025top,
  author = {Chenxia Tang and Jianchun Liu and Hongli Xu and Liusheng Huang},
  title = {{Top-nσ: Eliminating Noise in Logit Space for Robust Token Sampling of LLM}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure