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

A law of next-token prediction in large language models

Hangfeng He, Weijie J. Su

TL;DR

Researchers have discovered a universal "law of equi-learning" in Large Language Models (LLMs): each layer contributes an equal multiplicative factor to improving next-token prediction accuracy. This geometric pattern—where prediction error decays exponentially across layers—holds true across diverse architectures like Transformers, Mamba, and RWKV, providing a new lens to understand the internal "black box" of AI.

What Problem Does This Paper Address?

Despite their massive success, LLMs remain "black boxes." We understand their inputs (tokens) and their outputs (predictions), but the hierarchical transformation of data through dozens of layers is poorly understood. Specifically, how do raw embeddings progressively turn into sophisticated features capable of predicting the next word?

Previous research often suggested that certain layers (like the middle or final ones) do the "heavy lifting" for specific tasks. This paper challenges that view, seeking a precise, quantitative law that governs how predictive power evolves from the first layer to the last.

Methods

The authors introduce a metric called the Prediction Residual (PR). To calculate it, they take the contextualized embedding of a token at a specific layer $l$ and try to predict the next token using a simple linear regression model (a technique known as linear probing).

The PR is essentially the "fraction of variance unexplained"—a statistical measure where a high value means the embeddings have little predictive power, and a low value means they are highly informative.

By plotting the PR across layers on a logarithmic scale, they discovered a striking linear relationship: $$PR_l \approx \rho^{l-1} \times PR_1$$ This indicates that the predictive capability improves by a constant decay ratio ($\rho$) at every single layer.

Datasets

The study evaluates the law across a wide range of open-source LLMs (including GPT-2, Llama 2/3, Mistral, Phi-3, RWKV, and Mamba) using several prominent text datasets:

  • Probing Datasets: BookCorpus, C4, OpenWebText, Wikipedia, peS2o, The Pile, Redpajama, and OSCAR.
  • Domain-Specific Sets: MedRAG-Textbooks (medicine), LegalBench (law), and US-Congressional-Speeches (politics) were used to verify the law's emergence across different fields.

Key Insights and Ideas

  • The Law of Equi-learning: The most significant finding is that every layer is equally important. The quantitative nature of this law implies that the midpoint of a model is exactly where the LLM has achieved half of its total predictive capability.
  • Universality Across Architectures: The law isn't just for Transformers. It appears in newer, non-Transformer architectures like Mamba (State-Space Models) and RWKV (RNN-like), suggesting it is a fundamental property of how deep models learn to predict sequences.
  • Natural Emergence: This pattern isn't "baked in" by engineers; it emerges naturally during training. As shown in Figure 3, the law only becomes apparent after the model has seen a sufficient number of training steps.
Evolution of the law during training steps for Pythia-1B
  • Next-Token Prediction (NTP) is Special: The law is much cleaner for models trained on NTP compared to alternative tasks like Masked Language Modeling (used in BERT) or Span Corruption (used in T5). This provides empirical evidence for why NTP has become the dominant pre-training objective.
  • Forgetting the Past to Predict the Future: As data moves to higher layers, the model actually "forgets" information about the current and previous tokens to better focus its internal representations on predicting what comes next.

Key Results

  • High Statistical Significance: Across dozens of models, the Pearson correlation coefficients for the log-linear fit were consistently between -0.98 and -0.997, indicating an incredibly tight fit to the exponential decay law.
  • Scaling Trends: Larger models generally start with better initial embeddings (lower $PR_1$) and reach better final predictions. Interestingly, as models scale, the layer-wise decay ratio ($\rho$) increases, meaning each individual layer in a very deep model might do slightly "less" work than a layer in a shallow model, even though the total model is more powerful.
The law of equi-learning across various popular LLMs
  • Visualizing Separation: Principal Component Analysis (PCA) of embeddings shows that as tokens pass through layers, they become increasingly separated into distinct clusters based on their predictive context.
PCA visualization showing increasing separation of token embeddings across layers

Limitations and Future Work

  • Metric Sensitivity: The law is most precise when using the PR metric. Other common metrics, like "separation fuzziness," show the general trend but are much noisier.
  • Tokenization Dependence: The authors noted that shuffling the vocabulary (changing the indices of tokens) obscures the law. This suggests that the specific way tokenizers (like Byte Pair Encoding) order their vocabulary plays a role in how this geometric pattern manifests.
  • Theoretical Derivation: While the empirical evidence is vast, a formal mathematical proof for why non-linear neural networks converge to this specific geometric equilibrium is still an open challenge.
  • Practical Application: Future research could explore using this law to optimize training—for example, by setting different learning rates for different layers to reach this "equi-learning" state faster.

Summary updated

BibTeX
@article{he2025law,
  author = {Hangfeng He and Weijie J. Su},
  title = {{A law of next-token prediction in large language models}},
  journal = {Physical Review E},
  year = {2025},
  url = {https://openreview.net/forum?id=1LhlVI8xZb},
}
Figure