Papers › A Law of Next-Token Prediction in Large Language Models

A Law of Next-Token Prediction in Large Language Models

24 Aug 2024arXiv:2408.13442archive 2025-07-28

Hangfeng He, Weijie J. Su

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, built on architectures such as Transformer, RWKV, and Mamba. We demonstrate that this law offers new perspectives and insights to inform and guide practices in LLM development and applications, including model scaling, pre-training tasks, and information flow. Overall, our law enables more fine-grained approaches to the design, training, and interpretation of LLMs through scrutinizing their internal data processing mechanisms.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2408.13442")

Code

Syntology Ran 9 of 10 code samples harvested from 1 repository linked to this paper; 1 has no recorded run. Of those that ran: 9 ran with no contract checked.

By repository: official repository: 10 samples from 1 repository, 9 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

hornhehhf/llm-ell officialmentioned in papermentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

10 samples harvested; 9 ran; 0 honoured the contract we drafted; 1 has no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

9ran
1unverified

Licence: 10 of the 10 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from hornhehhf/llm-ell. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

get_class_features hornhehhf/llm-ell/feature_quality_assessment.py official repository ran no licence file found · pointer only · 731e74aa7479482a · report
get_label_distribution hornhehhf/llm-ell/feature_quality_assessment.py official repository ran fingerprinted no licence file found · pointer only · 1e8e910a04a79e5c · report
get_separation_fuzziness hornhehhf/llm-ell/feature_quality_assessment.py official repository ran fingerprinted no licence file found · pointer only · 83945a82104027ee · report
linear_regression hornhehhf/llm-ell/utils.py official repository ran fingerprinted no licence file found · pointer only · 6b7a283014ad42b4 · report
load_data_from_pickle hornhehhf/llm-ell/utils.py official repository ran no licence file found · pointer only · 2569a39582b28750 · report
load_model hornhehhf/llm-ell/feature_learning.py official repository ran no licence file found · pointer only · 8fe7cbd51bab2b6f · report
load_model_from_path hornhehhf/llm-ell/feature_learning.py official repository ran no licence file found · pointer only · 9c79d64508e5eb46 · report
round_to_first_nonzero hornhehhf/llm-ell/utils.py official repository ran fingerprinted no licence file found · pointer only · 9c5852b81b07fb2f · report
select_tokens hornhehhf/llm-ell/visualization.py official repository ran no licence file found · pointer only · d69bd99d23c2f471 · report
sample_sentences hornhehhf/llm-ell/feature_learning.py official repository unverified no licence file found · pointer only · 5c46ee109865c7ed · report

Tasks

Mamba

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerMambaMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections