arXiv:2610.32788cond-mat.dis-nnOct 2026

Manuscript Offprint

arXiv:2610.32788

Generalization properties of the token perceptron: the role of embedding and vocabulary

Dario Bocchi, Matteo Negri, Flavio Nicoletti, Francesco D'Amico

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original. This text is shared under the same licence.

Dario Bocchi, 1,2,∗^{1,2,*} Matteo Negri, 3,†^{3,\dagger} Flavio Nicoletti, 4,‡^{4,\ddagger} and Francesco D'Amico 1,2,§^{1,2,\S}

1^{1}Physics Department, University of Rome Sapienza, Rome, Italy

2^{2}Institute of Nanotechnology, CNR-NANOTEC, Rome, Italy

3^{3}Laboratoire de Physique Théorique et Modélisation, CY Cergy Paris Université

4^{4}Department of Computer Science and Engineering Chalmers

University of Technology and University of Gothenburg, Sweden

Large language models are trained to predict tokens from a finite vocabulary, each represented by a vector in a dd-dimensional embedding space. Therefore, token prediction is a classification problem whose classes have a geometry determined by the embedding. We study how this geometry affects learning in a minimal solvable model: a linear predictor that maps a sequence of NN embedded tokens to a dd-dimensional output through one d×dd \times d matrix per position, trained in the teacher–student setting. We call this the token perceptron. We compute its generalization error with the replica method, taking N→∞N \to \infty at fixed number of examples per position α=P/N\alpha = P/N and keeping dd and the vocabulary size DD finite. As a first reference case, we consider continuous embeddings on the sphere, which isolate the role of the embedding dimension. The natural load is then α/d\alpha/d, and for d>1d > 1 a normalized label fixes the direction of the teacher output, so the problem becomes a noiseless regression: the teacher is recovered exactly above αrec=d2/(d−1)\alpha_{\mathrm{rec}} = d^2/(d - 1), and spherical cross-entropy reaches this threshold at large inverse temperature. In the same setting the storage capacity of random associations scales as d2d^2 for margins O(1/d)\mathcal{O}(1/\sqrt{d}). We then turn to vocabulary embeddings, where a label only identifies the Voronoi cell of the teacher output, so that each example imposes inequalities rather than equations, as in the classical perceptron. We compute the Bayes-optimal error for a given embedding matrix through an approximate spectral closure and show that the optimal learner first resolves the directions in which the vocabulary has the largest variance, even when the teacher is isotropic.

I. INTRODUCTION AND RELATED WORK

Large language models (LLMs) are trained, before any fine-tuning or reinforcement-learning stage [1], to predict the next token of a text [2, 3]. Each token belongs to a finite vocabulary and is represented by a vector in a d-dimensional embedding space. The network maps a sequence of such vectors to an output vector, which is decoded into a token by comparing it with the learned vocabulary embeddings; in models with tied input and output embeddings the same vectors serve both roles [4, 5]. Token prediction is therefore a classification problem whose classes have a geometry determined by the embedding. In this work we study how this geometry, namely the embedding dimension d, the vocabulary size D and the arrangement of the vocabulary vectors, produces an effect on the learning process, as for example the amount of data needed to learn the task.

For the perceptron, questions of this kind received exact answers from the statistical mechanics of learning developed between the late 1980s and the late 1990s: the number of random associations a network can store [6, 7], the generalization error as a function of the number of examples in the

†^{\dagger} matteo.negri1@cyu.fr

‡^{\ddagger} flavion@chalmers.se

§ francesco.damico@uniroma1.it teacher-student setting [8, 9], and the error of the Bayes-optimal learner [10]. In these models each output is a scalar, binary or real, so neither an embedding dimension nor a vocabulary appears.

Several recent works have built solvable models of transformer-like learning, each in a specific scaling regime. Attention-indexed models take the embedding dimension large at finite sequence length [11]; theories of in-context regression take sequence length and dimension jointly large [12, 13]; models of factual recall store associations between single tokens in a d×dd \times d matrix and send d→∞d \to \infty [14–16]. In these models either the embedding dimension is sent to infinity, or the input is a single token, or there is no vocabulary; in none of them can the embedding dimension and the vocabulary size be varied at finite values. Other works study the attention structure of trained transformers in the Bayesian setting [17], regression from long sequences of high-dimensional tokens [18], how networks acquire hierarchical grammars over a vocabulary [19], or the dynamics of tokens under self-attention [20, 21].

In trained LLMs, among the sequence length NN, the embedding dimension dd and the vocabulary size DD, the sequence length is the largest, N∼105−106N \sim 10^5 - 10^6 tokens, while d∼103−104d \sim 10^3 - 10^4 and D∼104−105D \sim 10^4 - 10^5. Motivated by this regime, we study a minimal model in which only the sequence length is taken large, N→∞N \to \infty at fixed α=P/N\alpha = P/N, since it is the largest of the three scales, while dd and DD are kept finite and arbitrary. The model is the perceptron extended to sequences of embedded tokens: a linear predictor that assigns a d×dd \times d matrix Wi\mathbf{W}_i to each position ii of the sequence, trained in the teacher-student setting [8, 9, 22]. We call this the token perceptron. Taking N→∞N \to \infty exploits the extensive number Nd2Nd^2 of parameters and allows a direct generalization of the replica theory of the perceptron [6, 8, 9, 23]; the large-dd behavior is then derived from the finite-dd equations. The position-dependent weights are a simplification of attention, where positional information enters through encodings mixed with the token representations [4].

To separate the role of the embedding dimension from that of the vocabulary, we consider two cases: continuous embeddings on the d-dimensional sphere and embeddings drawn from a vocabulary.

  • Continuous embeddings isolate the role of the embedding dimension. For these, we compute the generalization error for any rotationally invariant loss and find that the natural load is α~=P/(Nd)\widetilde{\alpha} = P/(Nd). For d>1d > 1, a normalized label fixes the direction of the teacher output and therefore gives d−1d - 1 linear equations on the weights per example: classification becomes noiseless regression up to an overall scale. The teacher is recovered exactly above αrec=d2/(d−1)\alpha_{\mathrm{rec}} = d^2/(d - 1), the analogue of the interpolation threshold of the linear perceptron [24], and spherical cross-entropy reaches it in the limit of large inverse temperature. We also compute the storage capacity for random associations under two definitions of alignment.

  • Embeddings drawn from a discrete vocabulary are closer to the task of a transformer, which outputs one of D tokens rather than a continuous vector. They also present a harder learning problem that does not reduce to regression: the label identifies only the Voronoi cell containing the teacher output, so each example constrains the weights through inequalities rather than equations. This makes the vocabulary case, rather than the continuous one, the natural extension of the classical perceptron. For this task, we compute the Bayes-optimal error for a given embedding matrix through an approximate spectral ansatz, and show that learning becomes anisotropic: the optimal learner first resolves the directions in which the vocabulary has the largest variance.

The paper is organized as follows. In Sec. II we define the task and architecture that generalize the perceptron to multidimensional variables, together with the corresponding generalizations of the cross-entropy loss to continuous and vocabulary embeddings, that are two natural and valid possible extension of classical results. In Sec. III we solve the teacher-student problem for embeddings with continuous support (Fig. 1 (top)), where each token embedding is constrained to the hypersphere

Figure

Figure 1. Schematic representation of the learning problem with continuous (top) and vocabulary (bottom) token embeddings. In both settings, the token perceptron maps the input sequence ξ=(ξ1,…,ξN)\boldsymbol{\xi} = (\boldsymbol{\xi}_1, \ldots, \boldsymbol{\xi}_N) to the field uW(ξ)=(Nd)−1/2∑i=1NWiξi\boldsymbol{u}_W(\boldsymbol{\xi}) = (Nd)^{-1/2} \sum_{i=1}^N \mathbf{W}_i \boldsymbol{\xi}_i. (Top) continuous embeddings, with input vectors on the unit sphere Sd−1\mathbb{S}^{d-1} and prediction y^(ξ)=uW(ξ)/∥uW(ξ)∥\hat{\boldsymbol{y}}(\boldsymbol{\xi}) = \boldsymbol{u}_W(\boldsymbol{\xi}) / \|\boldsymbol{u}_W(\boldsymbol{\xi})\|. (Bottom) vocabulary embeddings, with each input vector drawn from a fixed vocabulary {z1,…,zD}⊂Sd−1\{z_1, \ldots, z_D\} \subset \mathbb{S}^{d-1}. The prediction is the vocabulary vector with maximal overlap with uW(ξ)\boldsymbol{u}_W(\boldsymbol{\xi}).

Sd−1S^{d-1} embedded in d dimensions. This setting is motivated by normalization schemes widely used in modern language models, such as RMS normalization [25]. In addition in Sec. IIID we study memorization of random inputs, a task analogous to recent results on factual recall [14, 15]. In Sec. IV we study vocabulary classification (Fig. 1 (bottom)), a multiclass supervised setting in which the geometry of a discrete set of vocabulary embeddings explicitly affects learning and generalization. This is a genuinely multidimensional task absent from the scalar perceptron setting and provides a simplified model of next-token prediction, the core objective of autoregressive LLMs [2].