WorksComputer Science
Dancing Tokens on the Vocabulary Network from LLM Generation
Abstract
Large language models (LLMs) generate text one token at a time, yet how a particular generation relates to the geometry learned in pre-training remains unclear. The fundamental explainability of LLMs is elusive. Here, we build a similarity network from the input embeddings of six open LLMs and map generation onto it. The token-embedding network is scale-free while heavy-tailed, as are random embeddings with matched covariance, but far more fragmented. Distillation barely changes this topology because input embeddings are largely inherited. The knowledge space is thus deterministic from pre-training. Consecutive generated tokens are rarely graph neighbours and, in most models, no more often than in shuffled order, so generation is not a walk on the predefined network, although the tokens it visits are concentrated within it. Through the logit lens in a layer- wise manner, tokens settle late in depth in most models, and repetitive models remain confined to small domain-specific sub-graphs. These observables could serve as inference-time monitors of degeneration. We thus provide a fresh perspective on understanding LLM generation in the microscopic way from node or link prediction by graph learning.
Large language models (LLMs), built on the Transformer architecture [1], generate text in the autoregressive manner from a prompt. They are now used across science, technology and society [2, 3]. Trained on internet-scale corpora and refined by distillation, fine-tuning, reinforcement learning and prompt engineering (chain-of-thought prompting etc.), contemporary models generate fluent and often satisfied text [4, 5]. Yet, understanding of how this text is produced has not kept pace with deployment. Scaling and “densing” laws describe how capability grows with parameters and data [6], but they treat the model as a black box. The cost is practical: hallucination [7, 8] cannot be eliminated entirely [9, 10], and existing responses — semantic-entropy uncertainty [11], retrieval-augmented decoding [12] and contrastive-layer decoding [13] — act on the output without reference to the space in which the model’s tokens live. Acquiring explainability of LLMs is strongly desired but still far from wanted.
A complementary tradition represents knowledge as a network and analyses its topology, tracing back to ancient times. Physically, many natural and engineered systems have been found to share scale-free degree distributions and small-world organisation [14, 15, 16]. In materials science, networks built from compositions or text have exposed design rules for amorphous alloys [17, 18]. Within the field of natural language, a word co-occurrence graph with a scale-free degree distribution was found similarly [19], and word-association networks carry the same statistics [20]. Small-world lexico-semantic structure has recently been reported in the input embeddings of LLMs [21], Lee et al. showed that the token embeddings of different LLMs share similar relative orientations [22], and hub tokens that organise their neighbours have been traced across layers [23]. Nearest-neighbour graphs in high dimensions, however, develop hubs generically [24], so heavy-tailed degree statistics require a reasonable comparison before they can be attributed to learning.
In general, LLMs are pre-trained on large corpus by breaking words into tokens at a scale of roughly . Combinations of the fragmented tokens will make up texts during inference. The set of tokens per LLM is thus defined before training, while after training each token will be assigned a unique high-dimensional tensorial representation, by optimizing the loss function. These numerical embeddings define the meanings of tokens for computer processing. Finally, three main components function a LLM: the set of tokens, the model architecture, and the parameters (token embeddings and model weights). Given a prompt, the information will be initialized and processed by them to make token-by-token predictions. Nevertheless, the physical mechanism of such a processing is obscure. This applies to vision-based or multi-modal LLMs in the similar way, sourcing from how tokens are defined.
During LLM generation, there are usually tens of hidden layers, consisting of the attention block and the feed-forward one. After these layer-wise processing, the logit lens will evaluate the possibility of each token as the next chosen one. In principle, these lens are extendable to other hidden layers. In calculation, it reads out a provisional next-token distribution from each hidden layer [25, 26], and the layer beyond which this read-out stops changing has itself become an observable: Lioubashevski et al. showed that the top-ranked tokens become fixed in order of their rank [27], Gupta et al. described a guess-then-refine use of depth [28], and Chen et al. related late-layer revision to reasoning effort and accuracy [29]. The settling layer varies for different tokens and models, which is critical in inference performance. These read-outs are made token by token, without a global map of the token space on which a whole generation can be located. We therefore ask whether generation can be located on a fixed network built from the pretrained token embeddings, and whether that network constrains the order in which tokens are emitted. For LLMs the link between the static geometry of token embeddings [30, 31] and the dynamic process of generation remains unestablished. Hence, whether a carrier for the complex LLM can be defined as a medium to crack related puzzles from a viewpoint of statistical physics.
In principle, a transformer-based language model learns the embeddings of a set of tokens from its training corpora by capturing the hidden correlations among them through the self-attention mechanism. Given user input, the model transforms the sequential embeddings into a probability distribution over the token set to predict the next token [1]. The temperature will determine how stochastic this selection is. This is the inference process from the pre-trained model. The intermediate computations are high-dimensional and entangled. The mapping from input context to output tokens resists the kind of mechanistic account that is routine in the natural sciences, for example, in the field of complex disordered systems. The data flow within the architecture during a specific generation has received comparatively little study. Token prediction is intrinsically a search over the vocabulary, driven by the conditional probabilities that the architecture computes: transformer layers capture the hidden correlations between tokens, while multi-layer perceptrons compute those between the features of tokens. An efficient search requires a well-defined representation of these tokens and their features, and understanding how the search proceeds is a prerequisite for principled domain adaptation.
In this study, we construct, for each of six open LLMs of 7–21 billion parameters from four developers, a token-similarity network from the pretrained input embeddings, fix its cutoff at the connectivity reference point where the mean degree crosses unity, and map autoregressive generation onto it. Even though the cutoff will quantitatively change the network properties, here our main purpose is to propose the viewpoint of understanding LLM generation from the token graph. How the cutoff will lead these quantitative variations is an open interesting question for future investigation. Currently, we find that the networks are heavy-tailed but far more fragmented than random-embedding nulls, even after surface-form variants are merged. Their topology fingerprints the model family (i.e. model architecture) and survives distillation, because the input embeddings are largely inherited. This raise the question what distillation really changes to modify the performance of LLMs in certain domains. Consecutive generated tokens are not network neighbours, although a generation occupies a concentrated region of the network. Tokens settle late in depth in most models. The breadth of coverage separates repetitive from exploratory generation. These findings pave a way to explaining LLM generation by graph learning on a quantitative token network.
Results
Network representation of LLM generation
We represent a model in its token space as a network: every token in the vocabulary is a node, and two nodes are connected when the cosine similarity of their input embeddings exceeds a threshold (Methods). A generation is then mapped onto this fixed network by locating the prompt and generated tokens as nodes and drawing the order of emission as directed steps between them (Figure 1). Nothing in the construction requires a sequence step to be a similarity edge, which is a static property of a LLM as a pre-training by-product. The network thus encodes the static geometry laid down in pre-training, and the sequence the choices made at inference. The token graph is fixed once pre-training ends, whereas the generated sequence is produced at inference, so the construction separates a quenched object (the network) from an annealed one (the sequence).
Figure 1. Schematic of autoregressive generation mapped onto a token graph. a, The tokens of an input sequence are located as nodes of the token-similarity network (grey edges), and their order is drawn as directed sequence steps (blue arrows); sequence steps need not coincide with similarity edges. b, The predicted next token is located as a further node, joined to the sequence by a new step (orange; dashed, predicted step). c, The extended sequence becomes the new input (orange step now part of the sequence) and the following token is predicted (green, dashed). d, Iterating maps the full generation onto the network (one colour per generated step). Linked squares beneath each panel show the corresponding input (blue) and generated (coloured) token sequence.
We study the six models of Table 1, with vocabularies of about 128–201k tokens: one pretrained base model (Meta-Llama-3.1-8B), three distilled models from DeepSeek-R1 reasoning traces and two post-trained instruction or reasoning models. These models are open-sourced and we hope to choose them to cover different model architectures (Supplementary Note 1). The threshold is the single free parameter of the construction, and no value is correct a priori (Supplementary Fig. 1), so we swept it from 0.05 to 0.95. The mean degree passes through unity within a narrow window of for all models (Figure 2a), and the largest connected component (LCC) grows as the cutoff is lowered through this window (Figure 2b). The curves group by model family: gpt-oss-20B has the highest token similarities and remains essentially fully connected (LCC above 99%) up to , whereas the Llama and Qwen families collapse onto two groups with much smaller similarities
Figure 2. Network construction, the reference cutoff and percolation. Each curve is one model (legend below); the cosine-similarity threshold is swept from 0.05 to 0.95. a, Mean degree versus (log scale); the dashed line marks , equivalent to with edges counted as unordered pairs. b, Fraction of nodes in the largest connected component (solid) and fraction of nodes with degree (dotted) versus ; vertical dashed lines mark each model’s , where . c, Susceptibility , the mean size of all clusters other than the largest, versus (log scale), with marked as in b. d, Largest-component fraction versus for each model (solid), its Gaussian null (dashed) and its shuffled-dimension null (dotted), with the Erdős–Rényi prediction (thick grey) and (vertical dashed line).
| Model | Type (starting checkpoint) | Architecture | heads/KV | ||||
| Meta-Llama-3.1-8B | pretrained base | Llama | 8.0 B | 32 | 4096 | 32/8 | 128256 |
| Qwen3-8B | post-trained, hybrid thinking (Qwen3-8B-Base) | Qwen3 | 8.2 B | 36 | 4096 | 32/8 | 151936 |
| DeepSeek-R1-0528-Qwen3-8B | R1-0528 distilled (Qwen3-8B-Base) | Qwen3 | 8.2 B | 36 | 4096 | 32/8 | 151936 |
| DeepSeek-R1-Distill-Llama-8B | R1 distilled (Llama-3.1-8B) | Llama | 8.0 B | 32 | 4096 | 32/8 | 128256 |
| DeepSeek-R1-Distill-Qwen-7B | R1 distilled (Qwen2.5-Math-7B) | Qwen2 | 7.6 B | 28 | 3584 | 28/4 | 152064 |
| gpt-oss-20B | reasoning, post-trained | GPT-OSS (MoE) | 20.9 B | 24 | 2880 | 64/8 | 201088 |
Table 1. The six studied LLMs and their key architectural parameters. is the total parameter count; the number of transformer blocks (layers); the hidden size; heads/KV the number of attention and key–value heads; the vocabulary size. All use SiLU activations and root-mean-square layer normalisation (RMSNorm). gpt-oss-20B is a mixture-of-experts (MoE) model with 32 experts (4 active per token).
Supplementary Fig. 1.
We use the onset of connectivity to fix the cutoff. In an Erdős–Rényi random graph a giant component emerges at , when the number of undirected edges reaches half the number of nodes [16, 32], and we denote by the cutoff at which our networks satisfy this condition. We borrow this cutoff for the finite systems here, which is well defined, reproducible and model specific. The token graphs do not, however, percolate like a random graph. This renders possible physical distinctions of the designed graph from the random one, hypothesizing the mysterious messages under the construction. At the LCC holds only 0.6–5% of the vocabulary, and it reaches half of the vocabulary only at –11, against 1.4 for an Erdős–Rényi graph; the susceptibility, the mean size of the finite clusters, peaks at –2.5 (Figure 2b–Figure 2d). is therefore a reproducible, model-specific reference point near the onset of connectivity rather than a sharp transition, and we perform all subsequent analysis at each model’s working cutoff , a sweep grid point 0.015–0.052 below (Methods). This criterion differs from the minimum-connectivity rule of Liu et al. [21] and the training-time percolation of Lubana et al. [33] (Supplementary Note 3).
Three groups of behaviour are visible in Figure 2, and they follow the model architecture. gpt-oss-20B (MoE) has the highest token similarities and the most persistent connectivity: it has the largest (and hence ) among all the models, and its fully connected graph survives up to . The curves collapse within another two groups: the Llama architecture and the Qwen architecture. Their token similarities are much smaller than those of gpt-oss-20B, as shown by the fast decay of and of the LCC in Figure 2a,Figure 2b. What distillation does change remains a question for future work, while it barely influences the token graph from pretraining (see, for example, ref. [34]). This observation rationalizes the necessity of pretraining LLM for different domains.
Physical properties of token graphs
At the working cutoff the degree distribution is heavy-tailed for every model (Figure 3a), giving with .(Supplementary Table 3 and Supplementary Fig. 2). The tail exponent near what from a word co-occurrence graph, approaching the Barabási–Albert value expected under preferential attachment [14, 19]. These successes motivate an analogous treatment of language models, in which the token embeddings learned during pre-training are examined for network structure and for its role in generation. Suprisingly, a Gaussian with each model’s mean and covariance, thresholded at the same , reproduces a comparable tail (Supplementary Fig. 2), as expected from the hubness of high-dimensional data [24]. What separates the trained embeddings from their nulls is fragmentation: at matched the LCC holds 2–13% of the tokens for the models, against 17–55% for the Gaussian null and 36–83% for a null with each embedding dimension permuted independently, while the fraction of tokens with at least one neighbour is similar (Supplementary Note 6). The linked tokens of a trained model sit in many small clusters rather than in one giant component (Figure 2d). This spatial distribution features the token graph, indicating strongly heterogeneous dynamics during model training and inference. These observations define the uniqueness of the token graphs from LLM pretraining, which may serve as a typical system for network study.
Figure 3. Network fingerprints across models. a, Degree distribution at each model’s working cutoff (log–log; see d), restricted to nodes with and normalised over them. Abbreviated model names in the legend are used in panels d and e. b,c, Largest connected component coloured by node degree for gpt-oss-20B (b) and the top-degree core of Qwen3-8B (its 3,000 highest-degree nodes; c), on a shared degree scale (colour bar in b). d, Working cutoff per model. e, Pairwise Euclidean distance between model network fingerprints (mean degree, modularity and community fraction of the LCC)
Decoding the vocabulary shows what these hubs and clusters are. In all six models, at least 99 of the 100 highest-degree tokens contain no letter or digit. They are closing brackets, semicolons and quotation marks fused with newline or carriage-return characters (Supplementary Table 5). Surface-form duplication also shapes the local structure: 26–42% of the edges join tokens that differ only in case or surrounding whitespace, and 34–45% of the finite clusters consist solely of such variants. The fragmentation nevertheless survives their removal. Restricted to tokens that contain a letter, the LCC holds 1.9–8.7% of those tokens, against 11–35% for a Gaussian null fitted to them at the same edge count. With all surface-form variants of a string merged into one node, it holds 2.9–11.9% of the merged nodes, against 22–63% for the Gaussian null merged in the same way (Supplementary Note 6). Fragmentation is thus a property of the trained tokenizer–embedding pair, part of which reflects the byte-pair encoding of one string in several forms. What the remaining clusters encode is not resolved here.
The network topology also fingerprints the model. We summarised each network by the mean degree, modularity and community fraction of its largest connected component and computed the pairwise distance between models (Figure 3b–Figure 3e; Methods). Models of the same family cluster together and gpt-oss-20B is the clear outlier. The fingerprint distance between DeepSeek-R1-0528-Qwen3-8B and Qwen3-8B, two siblings post-trained from Qwen3-8B-Base, is nearly seven-fold smaller than the mean distance from DeepSeek-R1-0528-Qwen3-8B to the four other models. This invariance is inherited through the weights. The distilled checkpoints keep their family’s tokenizer and largely its input embeddings: the relative Frobenius change of the embedding matrix is 0.11 between the two Qwen3-8B siblings and 0.14 between DeepSeek-R1-Distill-Llama-8B and its base, Meta-Llama-3.1-8B, with mean row-wise cosines of 0.995 and 0.988 (Supplementary Note 6). The fingerprint is therefore set by the model family and its pre-training, which distillation and reinforcement learning barely move. We note that the LCC structure differs visibly between gpt-oss-20B and Qwen3-8B (Figure 3b,Figure 3c). Growth by preferential attachment to emerging hubs is one hypothesis, but the Gaussian null could reproduce a comparable tail without any growth process, which makes its origin elusive.
Generation order relative to the network
With the network fixed, we asked whether generation moves along its edges. We note from the transformer attention mechanism that essentially the token graph should be dynamical with attention scores changing based on the prompt text for the next token. Nevertheless, to understand the graph, we first take the static graph from pre-training for early mining. For every pair of consecutive generated tokens we tested whether the two are neighbours at , excluding immediate repeats of a token, and compared this edge fraction with that of the same tokens in shuffled order, which keeps the composition of the run and destroys only its order (Methods). Consecutive tokens are rarely neighbours (Figure 4a). Pooled over 9 prompts (about transitions per model), the edge fraction ranges from 0.07% for gpt-oss-20B to 9.1% for Qwen3-8B, and for five of the six models it lies below the shuffled-order value (Figure 4b; Supplementary Table 4). The exception is Qwen3-8B (9.1%, 95% confidence interval 7.7–10.8%, against 8.4% shuffled), because two movie-prompt runs that repeat lists of titles reach 23% and 33%. Of the 54 runs, 36 fall below the 95% range of their shuffled baseline and three lie above it. Sampling does not change the picture: in five temperature-0.6 runs each of Qwen3-8B and gpt-oss-20B, the edge fraction is 5.3–7.5% and 0%, against shuffled-order values of 9.7–11.8% and 0.3–0.5% (Supplementary Note 6). Generation is therefore not a walk on the static similarity network but a dynamical one: the next token is, as a rule, not an embedding neighbour of the current one. The graph is dynamical as assumed from the attention mechanism. This also raises a question that whether a specific domain will have a unique graph layout. The layout of the generation features will also determine the generation quality, as discussed below.
Figure 4. Transition-edge test for consecutive generated tokens. a, Percentage of consecutive generated-token pairs that are edges of the token network at (observed) against the same percentage for the tokens of the run in shuffled order, one point per model and prompt (54 greedy-decoded runs; marker and colour identify the model, legend). Vertical bars, 95% moving-block bootstrap intervals of the observed value; horizontal bars, 2.5–97.5 percentile range over 1,000 shuffles; dashed line, equality. b, Observed (filled) and shuffled-order (hatched) edge percentage per model. Immediate repeats of a token are excluded from both.
The network nevertheless locates the generation. The shuffled-order baseline, which measures how often two tokens of the same run are neighbours irrespective of order, exceeds the density of the whole graph by a factor of about 400 for gpt-oss-20B and 1,900–4,900 for the other models (Supplementary Table 4), so the tokens emitted for one prompt occupy a small, densely linked part of the network, partly because runs reuse the punctuation hubs identified above. This suggests one condition to optimize the pretraining process. An intervention supports this reading. Rotating every input embedding of Qwen3-8B by the same small angle (row cosine 0.99 to the original), either towards a random direction or away from its network neighbours, keeps the model fluent; the targeted edit deletes 92% of the network’s edges (mean degree 2.62 0.20) and the random edit 9%, yet on two prompts the generations they produce are indistinguishable in edge fraction, concentration, repetition and settling depth, all measured on the original network (Supplementary Note 7; Supplementary Table 6). We therefore use the network as a coordinate system onto which generation is mapped, not as its generator. The static graph provides a new carrier to tackle this complex puzzle. The drawn paths of Figure 5e,Figure 5f and 6a,b join consecutive tokens by sequence steps that are, in general, not similarity edges.
Figure 5. Model architecture and the layered generation trajectory (gpt-oss-20B and Qwen3-8B). a, Schematic generalised decoder-only architecture shared by the six studied models. b,c, Logit-lens top-1 probability for gpt-oss-20B (b) and Qwen3-8B (c) over the first 60 generated tokens of the simple machine-learning prompt. Red squares linked by a line mark each token’s settling layer. d, Mean Kullback–Leibler divergence from each layer’s distribution to the final-layer distribution versus normalised depth (gpt-oss-20B, blue; Qwen3-8B, vermillion; shaded bands, ±1 s.d. across positions). e,f, Generated sequence mapped onto the prompt-and-generated token sub-graph for gpt-oss-20B (e) and Qwen3-8B (f): similarity edges in grey, visited tokens in blue and sequence steps between consecutive tokens in orange. g, Distribution of settling depth (settling layer divided by ) for all six models (legend in-panel). h, Median (filled, crosshatched) and mean (open) settling depth per model, normalised by ; the absolute median and mean settling layer are printed above each bar.
Layered trajectories of token generation
We next followed the data flow within the architecture (Figure 5a; Supplementary Note 1) using the logit lens, projecting the hidden state of every layer through the shared output head (Methods). For each token we define its settling layer as the earliest layer at and beyond which the layer-wise top-1 prediction matches that of the deepest layer and remains stable; under greedy decoding this target is the emitted token. The settling layer is the saturation event of Lioubashevski Lioubashevski et al. [27], and it compresses into one number per token the guess-then-refine use of depth described by Gupta Gupta et al. [28]; Chen Chen et al. [28] counted tokens still revised in late layers of GPT-OSS, DeepSeek-R1 and
Qwen3 models and found that their share tracks accuracy [29]. With the settling layer quantified, we analyze its distribution across a panel containing base, distilled and reasoning-tuned members of the same families, and its ordering relative to the entropy of the lens distribution.
Tokens settle late in most models. The share of tokens settling within the top quartile of layers ranges from 33% (Meta-Llama-3.1-8B) to 85% (gpt-oss-20B) and exceeds one half in five of the six models; for gpt-oss-20B the median settling depth is 0.87 of the stack, and tokens settle only once the lens prediction has become confident (Figure 5b,Figure 5c,Figure 5g). For five of the six models the mean settling depth lies below the median (Figure 5h), so a thin tail of early-settling tokens coexists with a bulk that resolves near the top of the stack, and the divergence to the final distribution decreases gradually with depth (Figure 5d). Mapped onto the network, the sequence runs through a structured region (Figure 5e,Figure 5f; per-model trajectories in Supplementary Fig. 3), i.e. a sub-graph of the token graph. In the dense models, the layers above the mean settling layer hold 7–24% of the parameters, varying by up to 1.8-fold across prompt domains. This is an upper bound on the average depth that an ideal per-token early exit [35] could skip to save computational resources, and, consistent with reports that early exit pays least in newer and tuned models [36], the base model carries the largest fraction (Supplementary Note 4; Supplementary Table 2 and Supplementary Fig. 5). This may rationalize the advantage of the mixture-of-experts design in LLMs.
Beneath this convergence, the Shannon entropy of the lens distribution first rises and then falls with depth (Supplementary Fig. 4 and Supplementary Note 8), reproducing the expansion-then-pruning profile of Ali et al. [37], and its falling branch collapses onto a common logistic curve after rescaling for gpt-oss-20B and Qwen3-8B (median per-token ). Notably, this entropy collapse sits mid-stack, ahead of the late settling of the top-1 identity. Combined with the ordered saturation of Lioubashevski et al., in which lower-ranked candidates are fixed after the top-1 [27]. This suggests a three-step sequence in depth: the distribution concentrates, the top-1 identity commits and the runners-up follow.
We also compare the network information for three fields by designing the prompts, i.e. metallic-glass, machine-learning and movie (Supplementary Table 7 and Supplementary Fig. 6). The three domain networks differ markedly in their nodes and community structure for both gpt-oss-20B and Qwen3-8B. The cross-domain overlap of activated tokens is low (Jaccard 0.07–0.10 for gpt-oss-20B and 0.08–0.13 for Qwen3-8B). Averaged over the six models, 70% of the tokens generated for a given domain are never used in the other two (metallic glasses 68%, machine learning 71%, movies 70%). Each domain resolves into its own communities: for gpt-oss-20B, the metallic-glass, machine-learning and movies sub-graphs contain 61, 49 and 108 communities, respectively. Because each field activates a largely disjoint set of high-similarity token clusters, its functional sub-graph is field-intrinsic. Pruning a model to that sub-network is left to future work. This indicates the feasibility of developing domain-specific LLMs over the general intelligent ones, from the perspective of token graphs.
Repetition as confinement on the network
Finally, we asked how broadly each model’s generation covers the network. Meta-Llama-3.1-8B collapses into a tight cluster (Figure 6a), whereas Qwen3-8B spreads across many communities (Figure 6b). Across the six models, a higher token-revisit rate accompanies a lower diversity of generated -grams (Pearson , ; Figure 6c). Both axes are repetition statistics of the same sequence, so their correlation is expected, and neither measures correctness; the informative content is the ordering of the models, which is stable across prompts ( between and over nine prompts; Supplementary Note 6). It measures the generation quality of the LLM regarding to the given prompt. A larger revisit rate indicates a deeper trap over fewer tokens in the high-dimensional landscape of the learning dynamics.
Figure 6. Repetition and exploration mapped onto the token network. a,b, Generated sequence mapped onto the prompt-and-generated token sub-graph (similarity edges in grey, visited tokens in blue, sequence steps in orange) for a repetitive model (Meta-Llama-3.1-8B, a) and an exploratory model (Qwen3-8B, b). c, Token-revisit rate versus distinct-3-gram ratio for all six models. d, Cumulative number of unique tokens versus generated-token position over the LLM generation run.
Regarding the model comparison, Meta-Llama-3.1-8B is a pretrained base model, the other five are post-trained. All runs used greedy decoding of raw-text prompts without a chat template (Methods), a regime that the Qwen3 developers advise against because it can cause endless repetition. The base model does not drive the correlation: without it, lies between and over the nine prompts (; on every prompt). Nor does post-training guarantee exploration: the post-trained gpt-oss-20B and Qwen3-8B are each the most repetitive model on one of the nine prompts. The ordering is a property of each checkpoint under this regime, not of a model type. This highlights the necessity of efficient prompt engineering or reasoning process to guide model output.
The accumulation of new tokens makes the confinement explicit (Figure 6d). Over a 2,048-token run, Meta-Llama-3.1-8B plateaus at 45 distinct tokens, having fallen into a short cycle, whereas DeepSeek-R1-0528-Qwen3-8B reaches 648. The two same-family pairs isolate post-training more cleanly: DeepSeek-R1-Distill-Llama-8B, distilled from Meta-Llama-3.1-8B, reaches 311 distinct tokens, seven-fold more than its base, and on the Qwen3-8B-Base backbone the reasoning-distilled sibling reaches 648 against 515 for Qwen3-8B; in both pairs the distilled model revisits less on all nine prompts. Hence, the bare difference made by distillation onto the input embeddings or network topology is actually beneficial to leverage the model performance by dragging it out of the deep minima it has been trapped in.
Sampling moderates the confinement of some models: at temperature 0.6 the revisit rate of gpt-oss-20B falls from 0.90 to 0.44–0.82 across five seeds (three of which stop early at an end-of-sequence token), whereas that of Qwen3-8B barely changes (0.72–0.77 against 0.77; Supplementary Note 6). Early saturation of token discovery is thus a simple readout of confinement to a sub-graph, paralleling the geometric account of mode collapse by Du and Tanaka-Ishii [38] and the attractor cycles of Wang et al. [39]. This is also a new feature to fingerprint a model.
Discussion
Our central result is that the pretrained input embeddings of an LLM define a fragmented token network onto which generation can be mapped, and that generation does not move along its edges. The transition-edge test separates two readings that a drawn path conflates. As a generator, the similarity graph would predict the next token from the current one, and it does not (Figure 4). As a coordinate system, it places the tokens of a generation in a concentrated, domain-specific region and exposes how broadly a model’s output covers it (Figure 4 and Figure 6). That consecutive tokens are less often neighbours than random pairs from the same run is consistent with fluent text alternating between function words, punctuation and content words, which the graph places in different clusters. In physical terms, the embedding geometry is a quenched variable, frozen at the end of pre-training, whereas the sequence is annealed at inference: post-training leaves the embedding geometry nearly unchanged (Figure 3e) while changing the generated sequences (Figure 6d).
The static results temper the analogy with language networks. The degree exponent resembles the scale-free class that for word co-occurrence [19]. But a matched Gaussian reproduces it, consistent with high-dimensional hubness [24] and with geometry shared across LLM embeddings [22]. In all six models the hubs are punctuation–newline tokens rather than words. For the percolation threshold of a random graph with the measured degree sequence vanishes in the thermodynamic limit [14, 40], so is a reference point for a finite system rather than a critical point, where the largest component holds half the vocabulary. What the trained embeddings add is fragmentation into many small clusters, which the nulls lack and which survives the removal of surface-form duplicates. The distillation invariance, in turn, is inheritance: the distilled checkpoints differ from their closest relatives by a relative Frobenius change of only 0.11–0.14 in their input embeddings, so the fingerprint reports how little post-training moves the embedding geometry, much as instruction tuning, unlike scale, leaves the alignment of LLMs with human language processing unchanged [41]. Unlike provenance detectors that recover lineage from behaviour [42] or gradients [43], it describes the geometry onto which generation is mapped.
On the dynamic side, from settling layer analysis [27, 28, 29], and we identify several remarkable features: late settling in most models, least so in the base model, and entropy concentration ahead of identity commitment. The breadth of coverage, by contrast, is a network observable. Spatial collapse, a high revisit rate and early saturation coincide under confinement, the network counterpart of neural text degeneration [44]. Within the Llama family distillation from reasoning traces raises the number of distinct tokens seven-fold on a network that it barely moves. Readings of hallucination as a continuation that leaves the domain sub-graph licensed by the prompt, and of subliminal learning [34] and emergent misalignment [45] as changes of sequence on an inherited network, remain hypotheses for future investigation.
In summary, an LLM’s pretrained embeddings define a fragmented token network onto which generation can be mapped, although the sequence does not follow its edges. The network supplies a cutoff tied to the onset of connectivity, a fingerprint that pre-training fixes and distillation barely moves, a placement of each generation in a concentrated region, and a repetition diagnostic based on how broadly the generation covers the network. These observables are computed from released weights and the generated sequence. A running count of newly visited tokens, for instance, could flag a generation that has become confined to a small sub-graph while it is still being produced. Building a similarity network from learned embeddings and fixing its cutoff near the onset of connectivity is not specific to language, and could be applied to the learned representations now used across the computational sciences [3] (Supplementary Note 5). The perspective of token graph paves new way to explain the physical mechanism of LLM generation and demonstrate the domain-specific feature, which motivates the development of cutting-edge domain-adaptive AI models or prompt engineering tools.
The fingerprint, the distillation invariance and the path observables all live on the static similarity graph. Coupling the path to attention deserves future efforts. Lindsey et al. [46] traced planning features that hold several candidate end-words of a poem line at once and steer the line towards them, so generation is locally goal-conditioned over the span about to be emitted. Because consecutive tokens do not follow similarity edges, tools that assume motion along the graph, such as static shortest paths, do not apply directly. Strategic path optimization is required. Community-aware measures of coverage and of boundary crossing are the natural network tools for the mapped sequences. Beyond the inference-time monitors, the distillation-invariant fingerprint print offers a lightweight handle for model auditing, and the measured effective depth informs how many layers a given task warrants. Extending the construction to the context-dependent attention computation, to multilingual and multimodal token spaces, and to a theory of how the fragmented cluster structure forms during pre-training are natural next steps, as is an interventional test in which input embeddings are perturbed along a cluster and the predicted change in revisit rate is measured.
Building a similarity network from learned embeddings, fixing its cutoff near the onset of connectivity and reading generation as coverage of the resulting graph resonates with the network representations now reshaping materials science, where elements, compositions and the literature have been cast as graphs to expose design rules and accelerate the discovery of amorphous alloys [17, 18, 47]. Characterising the token networks onto which LLM generation is mapped, and steering generation towards under-explored yet promising regions, may extend their role from summarisation to hypothesis generation and materials design.
Methods
Models and token embeddings
We studied six open-source LLMs from four developers (Table 1): the pretrained base model Meta-Llama-3.1-8B; Qwen3-8B, post-trained with a hybrid thinking mode; DeepSeek-R1-0528-Qwen3-8B, obtained by distilling DeepSeek-R1-0528 reasoning traces into Qwen3-8B-Base; DeepSeek-R1-Distill-Llama-8B and DeepSeek-R1-Distill-Qwen-7B, distilled from DeepSeek-R1 into Llama-3.1-8B and Qwen2.5-Math-7B; and the reasoning model gpt-oss-20B. For each model we extracted the pretrained input-embedding matrix [30] , whose row is the embedding of token in a vocabulary . Architectural parameters were read directly from each model’s configuration and are reported per model in the Supplementary Information.
Token-similarity network and topology analysis
For each ordered pair of tokens with we computed the cosine similarity of their input embeddings,
and connected the pair when exceeded a threshold . This defines an undirected, unweighted graph with adjacency
edge count and node degree . We swept from 0.05 to 0.95 in steps of 0.05 and, at each value, recorded the edge count and the degree of every node. The reference cutoff was set where the mean degree
crosses unity, the Erdős–Rényi percolation criterion, equivalently for the unordered-pair edge count used throughout, where counts all vocabulary tokens (isolated ones included),
was located on the sorted edge list (below), which agrees within 0.01 with linear interpolation of between the two swept points bracketing . All sub-graph and fingerprint analyses are performed at a per-model working cutoff : the sweep grid point at which the released graphs were built, lying 0.015–0.052 below . This approximation is made for the convenience of investigation. There the mean degree is –, close to the susceptibility peak, and the LCC holds 2–13% of the vocabulary.
Following the onset of connectivity, we extract the LCC or subgraph from the token graph. We measured its size , the fraction of non-isolated nodes and the susceptibility , the mean size of the clusters (connected components) other than the largest, as functions of both and . For Qwen3-8B the LCC sizes on the sweep grid agree exactly with an independent sparse-matrix computation of the pipeline. Two null embeddings with the same and were analysed identically: rows drawn from a Gaussian with the model’s mean and covariance, and the model’s embedding matrix with each column permuted independently across tokens. This feature indicates the probable training inefficiency as the parameters are not fully optimized and the process is not converged to a local optimal. Null degree distributions were compared at the edge count of the model at .
Token strings were decoded from each model’s byte-level vocabulary. A token was classed as a word token if its decoded string contains a letter, and its surface-form key was the decoded string with surrounding whitespace removed and letters lower-cased. At we recorded the class of the 100 highest-degree tokens, the fraction of edges joining two tokens with the same key and the fraction of finite clusters (connected components of two or more tokens other than the LCC) whose tokens all share one key. Two controls re-evaluated the LCC fraction: the sub-graph induced on word tokens, compared with a Gaussian null fitted to the word-token embeddings and thresholded at the same edge count; and the graph obtained by merging all tokens with the same key into one node, compared with the full-vocabulary Gaussian null at matched edge count, merged by the same key assignment.
Graph statistics
For each model we computed the number of components, the largest component of size , the mean degree (eq. (3)), the degree distribution
the modularity, and the number of communities. Communities were detected by greedy modularity maximisation, and the modularity itself was evaluated as
where is the community of node and is the Kronecker delta [16]. Network fingerprints used three statistics of the largest connected component — its mean degree (eq. (3) restricted to ), its modularity and its community fraction — z-scored across models,
with , the mean and standard deviation of feature over the six models; the distance matrix is the pairwise Euclidean distance
ordered by average-linkage hierarchical clustering.
Layer-wise generation and the logit lens
Each model was run on nine prompts, three topics (metallic glasses, machine learning and movies) at three complexities (simple, moderate and complex), listed in Supplementary Table 7. Generations used the token-by-token method with a key–value cache. For every generated position we saved, for each layer (0-based from the first transformer block, so is the deepest layer), the top- token identities and probabilities () obtained by projecting the layer’s hidden state through the shared final normalisation and output head (the logit lens [25]). is the model’s own output distribution,
From these we computed, per position, the layer-wise top-1 prediction and three observables. The settling layer, which corresponds to the saturation event of Lioubashevski et al. [27], is the earliest layer at and beyond which the layer-wise top-1 prediction equals the deepest-layer top-1 and remains stable,
whose target coincides, under greedy decoding, with the token the model actually emits. We report it as the settling depth , write for its mean over the generated positions of a run, and say that a token settles in the top quartile of layers when . The per-layer Shannon entropy, evaluated on the renormalised truncated top- distribution , is
and the per-layer Kullback–Leibler divergence to the final-layer distribution, evaluated on the union with missing entries floored at and renormalised into , is
All logarithms are natural, so entropies and divergences are in nats. Generated sequences were mapped onto the prompt-and-generated token sub-graph by locating each token as a node and adding a directed sequence step between consecutive tokens, . These steps are drawn on top of the similarity edges and are not themselves similarity edges unless .
Transition-edge test
For a generated sequence , let be the set of transitions between distinct tokens. The transition-edge fraction is
Its baseline is evaluated on 1,000 random permutations of , which keep the multiset of tokens of the run and remove its order. We also computed for pairs drawn independently from the run’s unigram distribution, which gives the same values, and the graph density . The 95% interval of the observed is a moving-block bootstrap over transitions (block length 50, 2,000 resamples). Runs were pooled per model by concatenating their transitions. The same statistics were computed for five temperature-0.6 runs of Qwen3-8B and gpt-oss-20B on the moderate machine-learning prompt, generated with the same pipeline for a companion temperature study.
For Qwen3-8B, whose input embedding and output head are untied, every row of the input-embedding matrix was replaced by with and a unit vector, so that every token keeps its norm and has cosine with its original embedding. In the random edit is an independent Gaussian direction. In the targeted edit it points away from the sum of the unit embeddings of the token’s neighbours at (isolated tokens receive the random direction). The output head was not changed, so the logit lens is unaffected. All statistics were evaluated on the unedited network.
Domain sub-graphs and path metrics
For each domain we used a simple prompt (metallic glasses, machine learning, movies) and built the sub-graph induced by the prompt and generated tokens together with their similarity neighbours, augmented by the sequence steps. Communities were detected by greedy modularity maximisation of (eq. (6)). Domain overlap is the Jaccard index of the activated token sets ,
Given a generated token sequence , repetition was characterised by the token-revisit rate, the distinct--gram ratio (with ), and the cumulative count of unique tokens over the run,
Across-model summary statistics (e.g. the Pearson correlation in Figure 6c) were computed on the per-model pairs .
Data availability
The models are open-sourced. An interactive dashboard visualising the model features and token generation on the graph is available at https://ychu-mining-ai-dashboard.hf.space/.
Code availability
The code pipelines are available from the authors upon reasonable request.
Author contributions
Y.-C.H. conceived the project, performed the analyses and wrote the manuscript.
Competing interests
The authors declare no competing interests.
Acknowledgements
We thank the developers of the open-weight models analysed here for releasing their weights. Generative AI assisted with literature organization, manuscript editing, and the development and review of plotting and figure-generation scripts. The author directed its use and independently verified all scientific claims, calculations, code, figures, and references. No competing interests exist.
References
- [1]Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L. & Polosukhin, I. Attention is all you need. In Guyon, I., Luxburg, U. V., Bengio, S., Wallach, H., Fergus, R., Vishwanathan, S. & Garnett, R. (eds.) Advances in Neural Information Processing Systems, vol. 30 (Curran Associates, Inc., 2017).arxiv.org/abs/1706.03762
- [2]LeCun, Y., Bengio, Y. & Hinton, G. Deep learning. Nature 521, 436–444 (2015).DOI
- [3]Wang, H. et al. Scientific discovery in the age of artificial intelligence. Nature 620, 47–60 (2023).DOI
- [4]Guo, D. et al. DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning. Nature 645, 633–638 (2025).DOI
- [5]Wei, J., Wang, X., Schuurmans, D., Bosma, M., Ichter, B., Xia, F., Chi, E. H., Le, Q. V. & Zhou, D. Chain-of-thought prompting elicits reasoning in large language models. In Proceedings of the 36th International Conference on Neural Information Processing Systems, NIPS ’22 (Curran Associates Inc., Red Hook, NY, USA, 2022).arxiv.org/abs/2201.11903
- [6]Xiao, C., Cai, J., Zhao, W., Lin, B., Zeng, G., Zhou, J., Zheng, Z., Han, X., Liu, Z. & Sun, M. Densing law of LLMs. Nature Machine Intelligence 7, 1823–1833 (2025).
- [7]Ji, Z., Lee, N., Frieske, R., Yu, T., Su, D., Xu, Y., Ishii, E., Bang, Y., Madotto, A. & Fung, P. Survey of hallucination in natural language generation. ACM Computing Surveys 55, 1–38 (2023).DOI
- [8]Huang, L. et al. A survey on hallucination in large language models: Principles, taxonomy, challenges, and open questions. ACM Transactions on Information Systems 43, 1–55 (2025).DOI
- [9]Xu, Z., Jain, S. & Kankanhalli, M. Hallucination is inevitable: An innate limitation of large language models. Preprint at arXiv:2401.11817 (2024).arxiv.org/abs/2401.11817
- [10]Kalai, A. T., Nachum, O., Vempala, S. S. & Zhang, E. Evaluating large language models for accuracy incentivizes hallucinations. Nature 653, 1047–1051 (2026).DOI
- [11]Farquhar, S., Kossen, J., Kuhn, L. & Gal, Y. Detecting hallucinations in large language models using semantic entropy. Nature 630, 625–630 (2024).DOI
- [12]Lewis, P. et al. Retrieval-augmented generation for knowledge-intensive NLP tasks. In Advances in Neural Information Processing Systems (NeurIPS) (2020).arxiv.org/abs/2005.11401
- [13]Chuang, Y.-S., Xie, Y., Luo, H., Kim, Y., Glass, J. & He, P. DoLa: Decoding by contrasting layers improves factuality in large language models. In International Conference on Learning Representations (ICLR) (2024).arxiv.org/abs/2309.03883
- [14]Barabási, A.-L. & Albert, R. Emergence of scaling in random networks. Science 286, 509–512 (1999).
- [15]Watts, D. J. & Strogatz, S. H. Collective dynamics of ’small-world’ networks. Nature 393, 440–442 (1998).
- [16]Newman, M. E. J. The structure and function of complex networks. SIAM Review 45, 167–256 (2003).DOI
- [17]Zhang, S., Tian, J., Liu, S., Zhang, H., Bai, H., Hu, Y.-C. & Wang, W.-H. Constructing material network representations for intelligent amorphous alloy design. Natl. Sci. Rev. 12, nwaf398 (2025).DOI
- [18]Ouyang, K., Zhang, S., Liu, S.-L., Tian, J., Li, Y., Tong, H., Bai, H.-Y., Wang, W.-H. & Hu, Y.-C. Graph learning metallic glass discovery from Wikipedia. AI for Science 1, 025004 (2025).DOI
- [19]Ferrer i Cancho, R. & Solé, R. V. The small world of human language. Proc. R. Soc. Lond. B 268, 2261–2265 (2001).pubmed.ncbi.nlm.nih.gov/11674874
- [20]Steyvers, M. & Tenenbaum, J. B. The large-scale structure of semantic networks: Statistical analyses and a model of semantic growth. Cognitive Science 29, 41–78 (2005).
- [21]Liu, Z., Liu, Y., Luo, K., Kong, C. & Sun, M. From the new world of word embeddings: A comparative study of small-world lexico-semantic networks in LLMs. Preprint at arXiv:2502.11380 (2025).arxiv.org/abs/2502.11380
- [22]Lee, A., Weber, M., Viégas, F. & Wattenberg, M. Shared global and local geometry of language model embeddings. Preprint at arXiv:2503.21073 (2025).arxiv.org/abs/2503.21073
- [23]Liu, A., Srinivasan, D. & Penn, G. Some tokens behave like magnets: Revealing linguistic organization in the layers of language models. Preprint at arXiv:2609.05743 (2026).arxiv.org/abs/2609.05743
- [24]Radovanovic, M., Nanopoulos, A. & Ivanović, M. Hubs in space: Popular nearest neighbors in high-dimensional data. Journal of Machine Learning Research 11, 2487–2531 (2010).DOI
- [25]nostalgebraist. Interpreting GPT: the logit lens. LessWrong (2020).
- [26]Belrose, N., Ostrovsky, I., McKinney, L., Furman, Z., Smith, L., Halawi, D., Biderman, S. & Steinhardt, J. Eliciting latent predictions from transformers with the tuned lens. Preprint at arXiv:2303.08112 (2023).arxiv.org/abs/2303.08112
- [27]Lioubashevski, D., Schlank, T., Stanovsky, G. & Goldstein, A. Looking beyond the top-1: Transformers determine top tokens in order. In Proceedings of the 42nd International Conference on Machine Learning, vol. 267, 38029–38048 (2025).arxiv.org/abs/2410.20210
- [28]Gupta, A., Yeung, J., Anumanchipalli, G. & Ivanova, A. How do LLMs use their depth? Preprint at arXiv:2510.18871 (2025).arxiv.org/abs/2510.18871
- [29]Chen, W.-L., Peng, L., Tan, T., Zhao, C., Chen, B. J., Lin, Z., Go, A. & Meng, Y. Think deep, not just long: Measuring LLM reasoning effort via deep-thinking tokens. Preprint at arXiv:2602.13517 (2026).arxiv.org/abs/2602.13517
- [30]Mikolov, T., Chen, K., Corrado, G. & Dean, J. Efficient estimation of word representations in vector space. Preprint at arXiv:1301.3781 (2013).arxiv.org/abs/1301.3781
- [31]Ethayarajh, K. How contextual are contextualized word representations? comparing the geometry of BERT, ELMo, and GPT-2 embeddings. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing (EMNLP-IJCNLP), 55–65 (2019).arxiv.org/abs/1909.00512
- [32]Erdős, P. & Rényi, A. On the evolution of random graphs. Publ. Math. Inst. Hung. Acad. Sci. 5, 17–61 (1960).
- [33]Lubana, E. S., Kawaguchi, K., Dick, R. P. & Tanaka, H. A percolation model of emergence: Analyzing transformers trained on a formal language. Preprint at arXiv:2408.12578 (2024).arxiv.org/abs/2408.12578
- [34]Cloud, A., Le, M., Chua, J., Betley, J., Sztyber-Betley, A., Mindermann, S., Hilton, J., Marks, S. & Evans, O. Language models transmit behavioural traits through hidden signals in data. Nature 652, 615–621 (2026).DOI
- [35]Schuster, T., Fisch, A., Gupta, J., Dehghani, M., Bahri, D., Tran, V. Q., Tay, Y. & Metzler, D. Confident adaptive language modeling. In Advances in Neural Information Processing Systems (NIPS) (2022).arxiv.org/abs/2207.07061
- [36]Wei, R., Du, R., Yu, H., Tiwari, D., Li, J., Xu, Z. & Wang, H. The diminishing returns of early-exit decoding in modern LLMs. Preprint at arXiv:2603.23701 (2026).arxiv.org/abs/2603.23701
- [37]Ali, R., Caso, F., Irwin, C. & Liò, P. Entropy-Lens: Uncovering decision strategies in LLMs. Preprint at arXiv:2502.16570 (2025).arxiv.org/abs/2502.16570
- [38]Du, X. & Tanaka-Ishii, K. Escaping mode collapse in LLM generation via geometric regulation. Preprint at arXiv:2605.00435 (2026).arxiv.org/abs/2605.00435
- [39]Wang, Z., Li, Y., Yan, J., Cheng, Y. & Zhang, Y. Unveiling attractor cycles in large language models: A dynamical systems view of successive paraphrasing. Preprint at arXiv:2502.15208 (2025).arxiv.org/abs/2502.15208
- [40]Newman, M. E. J. Power laws, pareto distributions and zipf’s law. Contemporary Physics 46, 323–351 (2005).DOI
- [41]Gao, C., Ma, Z., Chen, J., Li, P., Huang, S. & Li, J. Increasing alignment of large language models with language processing in the human brain. Nature Computational Science 5, 1080–1090 (2025).DOI
- [42]Wu, Z., Zhao, H., Wang, Z., Guo, J., Wang, Q. & He, B. LLM DNA: Tracing model evolution via functional representations. In International Conference on Learning Representations (ICLR) (2026).arxiv.org/abs/2509.24496
- [43]Wu, Z., Zhao, Y. & Wang, H. Gradient-based model fingerprinting for LLM similarity detection and family classification. Preprint at arXiv:2506.01631 (2025).arxiv.org/abs/2506.01631
- [44]Holtzman, A., Buys, J., Du, L., Forbes, M. & Choi, Y. The curious case of neural text degeneration. In International Conference on Learning Representations (ICLR) (2020).
- [45]Betley, J., Warncke, N., Sztyber-Betley, A., Tan, D., Bao, X., Soto, M., Srivastava, M., Labenz, N. & Evans, O. Training large language models on narrow tasks can lead to broad misalignment. Nature 649, 584–589 (2026).DOI
- [46]Lindsey, J., Gurnee, W., Ameisen, E., Chen, B., Pearce, A., Turner, N. L., Citro, C., Abra-hams, D., Carter, S. et al. On the biology of a large language model. Transformer Circuits Thread, Anthropic (2025).
- [47]Zhou, Q., Tang, P., Liu, S., Pan, J., Yan, Q. & Zhang, S-C. Learning atoms for materials discovery. Proceedings of the National Academy of Sciences 115, E6411–E6417 (2018).DOI





