A Law of Next-Token Prediction in Large Language Models

Hangfeng He, Weijie J. Su
8/24/2024
cs.LGcs.AIcs.CL

No official code found. Best implementation: HornHehhf/LLM-ELL (4 stars, last commit 2025-09-24).

Abstract

Large language models (LLMs) have been widely employed across various application domains, yet their black-box nature poses significant challenges to understanding how these models process input data internally to make predictions. In this paper, we introduce a precise and quantitative law that governs the learning of contextualized token embeddings through intermediate layers in pre-trained LLMs for next-token prediction. Our findings reveal that each layer contributes equally to enhancing prediction accuracy, from the lowest to the highest layer -- a universal phenomenon observed across a diverse array of open-source LLMs, irrespective of their architectures or pre-training data. We demonstrate that this law offers new perspectives and actionable insights to inform and guide practices in LLM development and applications, including model scaling, pre-training tasks, and interpretation.

View on arXivView PDF

Code Implementations(1)

HornHehhf/LLM-ELLCommunity100%
40Shell, PythonAug 23, 20241 years ago

Similar Papers

Cite this paper

@article{he2024nexttoken,
  title  = {A Law of Next-Token Prediction in Large Language Models},
  author = {Hangfeng He and Weijie J. Su},
  year   = {2024},
  eprint = {2408.13442},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2408.13442v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2408.13442.svg)](https://codeofpaper.com/paper/2408.13442)

Discussion