A Unified Framework for Critical Scaling of Inverse Temperature in Self-Attention

Tomohiro Hayase, Ryo KarakidaarXiv 2026

TL;DR

When scaling Transformers to long context lengths, self-attention logits must be rescaled to prevent the attention distribution from either completely flattening out or collapsing into a single token. This paper introduces a unified gap-counting framework proving that the optimal scaling law is not a universal constant, but is dynamically determined by how tightly "competitor" tokens crowd around the maximum attention score.

What Problem Does This Paper Address?

As the context length ($n$) of Large Language Models grows, the standard softmax function in self-attention behaves poorly. Without proper adjustment, models face two failure modes: rank collapse (where attention weights become too uniform and diffuse) or entropy collapse (where attention hyper-concentrates on a single token).

To stabilize long-context inference, practitioners scale attention logits using a length-dependent inverse temperature multiplier:

$$\beta_n \propto (\log n)^{\xi_\beta}$$

However, existing literature is deeply conflicted on what the exponent $\xi_\beta$ should actually be. Theoretical Gaussian analyses suggest $\xi_\beta = 1/2$, popular models like Qwen use $\xi_\beta = 1$, and context-window extension techniques like YaRN implicitly use $\xi_\beta = 2$. This paper resolves these contradictions by providing a unified theory that explains why different models require different scaling laws.

Methods

The authors abandon traditional ordinal ranking (e.g., 1st, 2nd, 3rd best token) and instead propose a deterministic gap-counting framework based on the numerical distance of attention scores from the maximum score in a row.

  • Cumulative Gap-Counting Function ($N_n(t)$): Counts how many tokens ("competitors") have attention scores within a distance $t$ of the maximum score.
  • Upper-Tail Accumulation Scale ($\Lambda_n$): Measures the exponential growth rate of this counting curve, defined as: $$\Lambda_n := \sup_{t>0} \frac{\log N_n(t)}{t}$$

The paper's main theorem proves that $\Lambda_n$ is the precise critical boundary separating the two collapse regimes. Scaling below $\Lambda_n$ fails to separate top tokens, while scaling above it causes attention entropy to collapse.

The authors also introduce a coordinate decomposition formula ($\xi_\Lambda = \xi_\alpha - \xi_\Delta + 1$) to show how the critical exponent emerges directly from the token distribution geometry (the number of close competitors vs. the size of the score gap).

The gap-counting function $N_n(t)$ and its exponential envelope $\Lambda_n$.

Datasets

The framework was validated using two distinct experimental setups:

  1. Inference-Time Extrapolation: Evaluating the pretrained Qwen-7B-Chat model on long-context benchmarks:
  2. PG-19: A collection of long books from the Project Gutenberg archive.
  3. Proof-Pile-2 (arXiv subset): Scientific and mathematical documents.
  4. Training-Time Optimization: Training a GPT-124M model from scratch using a learnable inverse-temperature vector on:
  5. SlimPajama: A massive, cleaned web text corpus.
  6. OpenWebText: An open-source replication of the WebText dataset.

Key Insights and Ideas

  • The Exponent is Not Universal: There is no single "correct" scaling law for self-attention. The optimal exponent depends entirely on the underlying geometry of the attention scores, which varies by model architecture and dataset.
  • Structure Dictates Scaling: In simple, flat token configurations ("equicorrelated simplexes"), the framework naturally recovers the standard $\log n$ scaling ($\xi = 1$). However, when tokens form hierarchical clusters, the optimal exponent can shift significantly.
  • Model-Free Diagnostic: Instead of guessing an empirical scaling factor, researchers can directly profile a model's attention scores using the gap-counting function to calculate its exact ideal scaling exponent ($\hat{\xi}_\Lambda$).

Key Results

  • Suboptimality of Default Scaling: Empirical sweeps on Qwen-7B-Chat revealed that the standard $\log n$ scaling ($\xi_\beta = 1$) is suboptimal for long contexts. Language model perplexity was minimized at much higher exponents ($\xi_\beta^* \in [2, 2.5]$). The proposed gap-counting diagnostic accurately predicted this shift, measuring $\hat{\xi}_\Lambda \approx 1.74 - 2.33$.
  • Learned Scaling Dynamics: When GPT-124M was trained from scratch with a learnable logit multiplier, the parameters naturally settled on an exponent below 1 ($\xi_\beta^* \in [0.40, 0.50]$). Once again, the gap-counting framework successfully matched this empirical reality, measuring $\hat{\xi}_\Lambda \approx 0.52 - 0.69$.
Empirical loss landscapes showing optimal exponents for different datasets.

Limitations and Future Work

The primary limitation of this work is that the attention score distribution is treated as a given static property. The framework does not yet explain why a specific architecture, positional encoding, or dataset produces a particular score geometry in the first place.

An exciting direction for future work is to endogenize these properties by coupling the gap-counting theory with the training dynamics and inference-time particle dynamics of self-attention. This would allow researchers to predict how the critical inverse-temperature scale evolves across different layer depths and training milestones.

Summary updated

BibTeX
@misc{hayase2026unified,
  author = {Tomohiro Hayase and Ryo Karakida},
  title = {{A Unified Framework for Critical Scaling of Inverse Temperature in Self-Attention}},
  year = {2026},
  eprint = {2605.12697},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.12697},
}

Loading related content...

Figure