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

Dario Bocchi, Matteo Negri, Flavio Nicoletti, Francesco D'AmicoarXiv 2026

This paper introduces the token perceptron, a minimal solvable model designed to bridge the gap between the statistical mechanics of learning and the practical realities of Large Language Models (LLMs). By promoting the classical perceptron's scalar variables to high-dimensional vectors, the authors reveal how embedding geometry and vocabulary structure fundamentally change how models generalize.

TL;DR

The authors extend perceptron theory to multidimensional "tokens," showing that higher embedding dimensions ($d > 1$) allow for perfect teacher recovery at finite data loads. They also demonstrate that learning in discrete vocabularies is inherently anisotropic, with models prioritizing directions of highest vocabulary variance.

What Problem Does This Paper Address?

LLMs predict tokens from a finite vocabulary, where each token is a vector in a $d$-dimensional embedding space. Traditional learning theory often treats labels as simple scalars, ignoring the rich geometric structure of these embeddings.

The researchers identified a lack of models that can vary embedding dimension and vocabulary size at finite values while remaining analytically solvable. They tackle the question: How do the embedding dimension ($d$), vocabulary size ($D$), and the spatial arrangement of tokens affect the amount of data needed to learn a task?

Methods

The authors propose the token perceptron, a linear model that maps a sequence of $N$ embedded tokens to a $d$-dimensional output via $d \times d$ weight matrices. They analyze this model using the teacher-student framework and the replica method from statistical mechanics.

They investigate two distinct scenarios:

  1. Continuous Spherical Embeddings: Tokens and labels are any vector on a unit hypersphere. This isolates the effect of the dimension $d$.
  2. Vocabulary Embeddings: Tokens are drawn from a discrete set of $D$ vectors. This introduces Voronoi cell geometry, where a label identifies a region of space rather than a single point.

To solve the vocabulary case, they developed a spectral anisotropic ansatz, allowing them to compute Bayes-optimal generalization errors for specific vocabulary arrangements.

Schematic of the token perceptron for continuous (top) and vocabulary (bottom) embeddings.

Datasets

The study relies on synthetic datasets to maintain precise control over geometric parameters:

  • Inputs: Sequences of $N$ vectors. In the continuous case, these are sampled uniformly from a unit sphere. In the vocabulary case, they are drawn from a fixed set of $D$ tokens.
  • Labels: Generated by a "teacher" network with fixed weights, providing a ground truth for the "student" to learn.
  • Vocabularies: Randomly generated sets of $D$ unit vectors, held fixed ("quenched") during training.

Key Insights and Ideas

  • Dimension as an Information Multiplier: In dimensions $d > 1$, a normalized label fixes a direction in space, providing $d-1$ linear constraints per example. This effectively turns classification into a "noiseless regression" problem.
  • Phase Transition to Perfect Recovery: Unlike the classical $d=1$ perceptron, the token perceptron with $d > 1$ can achieve zero generalization error at a finite data load.
  • The Bias of Finite Vocabularies: Even if tokens are sampled from an isotropic distribution, a finite vocabulary is inherently anisotropic. The optimal learner exploits this by resolving "more visible" directions (those with higher variance) first.
  • Voronoi Cells as Nonlinearity: In the vocabulary case, labels only identify which Voronoi cell the teacher's output belongs to. This imposes inequalities rather than equations, making it the "natural" high-dimensional extension of the classical perceptron.

Key Results

  • Recovery Threshold: For continuous embeddings, the teacher is recovered exactly once the number of examples per position exceeds $\alpha_{rec} = d^2 / (d-1)$.
  • Universal Scaling: By rescaling the data load as $\tilde{\alpha} = \alpha/d$, the authors showed that generalization error curves for different dimensions converge toward a universal behavior.
Generalization error curves for different embedding dimensions $d$ using rescaled variables.
  • Zero Error at Finite Load: Figure 3 illustrates that for $d > 1$, the generalization error reaches zero at a specific threshold, whereas the $d=1$ case (maximum-margin) remains positive.
Learning curves showing the transition to zero generalization error for $d > 1$ at infinite temperature.
  • Temperature Sensitivity: Figure 4 demonstrates that at high data loads, increasing the "inverse temperature" $\tilde{\lambda}$ (reducing noise) allows the model to recover the teacher perfectly for any $d > 1$.
Generalization error vs. inverse temperature $\tilde{\lambda}$ for low (left) and high (right) data loads.

Limitations and Future Work

The authors acknowledge several simplifications:

  • Linearity: The model uses linear predictors, while real transformers use non-linear attention.
  • Quenched Vocabularies: Real LLMs often learn embeddings and weights jointly.
  • Temporal Independence: The model assumes tokens in a sequence are independent, missing the sequential correlations of real language.

Future work could involve extending the model to include non-linearities, joint embedding learning, or more realistic sequence statistics.

Summary updated

Abstract

Large language models are trained to predict tokens from a finite vocabulary, each represented by a vector in a $d$-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 $N$ embedded tokens to a $d$-dimensional output through one $d\times d$ matrix per position, trained in the teacher--student setting. We call this the \textit{token perceptron}. We compute its generalization error with the replica method, taking $N\to\infty$ at fixed number of examples per position $α=P/N$ and keeping $d$ and the vocabulary size $D$ 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$, and for $d>1$ a normalized label fixes the direction of the teacher output, so the problem becomes a noiseless regression: the teacher is recovered exactly above $α_{\rm 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 $d^2$ for margins $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.
BibTeX
@misc{bocchi2026generalization,
  author = {Dario Bocchi and Matteo Negri and Flavio Nicoletti and Francesco D'Amico},
  title = {{Generalization properties of the token perceptron: the role of embedding and vocabulary}},
  year = {2026},
  eprint = {2610.32788},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.32788},
}
Figure