Universal Approximation through Token Distinguishability in Transformers

This direction is no longer present in the current build. Its last version stays readable and citable here.

Version 1 of 114 papers21 conceptsfrozen 2026-10-04

For a long time, the empirical success of Transformers in natural language processing and computer vision outpaced our theoretical understanding of their power. While we knew they worked, the mathematical proof that they could approximate any sequence-to-sequence function was a missing link. Recent research has crystallized a core intuition: Transformers are universal approximators because their attention mechanism acts as a "contextual mapper," ensuring that every token in a sequence receives a unique signature.

The Problem of Sequence Ambiguity

In a standard feedforward neural network, a specific input vector always produces the same output. However, sequences are more complex. The word "bank" in "river bank" requires a different representation than "bank" in "bank account." If a model processed these tokens in isolation, it would be unable to distinguish between them.

To approximate a sequence-to-sequence function, a model must resolve this ambiguity. As Chulhee Yun, Srinadh Bhojanapalli, and colleagues first proved in Are Transformers universal approximators of sequence-to-sequence functions?, Transformers solve this by using self-attention to generate unique contextual signatures. By incorporating information from the entire sequence, the model ensures that identical tokens in different contexts receive distinct representations.

Attention as a Contextual Mapper

The "why" behind Transformer expressivity lies in a division of labor between the attention layers and the position-wise feedforward networks (MLPs).

  1. Attention does not necessarily do the heavy lifting of function approximation itself. Instead, its primary role is token distinguishability. It maps identical or similar input tokens to unique points in a high-dimensional space based on their surroundings.
  2. MLPs then act as the universal approximators for these now-unique vectors. Since the attention layer has ensured that no two tokens (in their specific contexts) "overlap," the MLP can map each unique vector to its desired output.

This framework, formalized by Cheng Jingpu, Qianxiao Li, and others in A unified framework for establishing the universal approximation of transformer-type architectures, suggests that almost any Transformer variant—whether sparse, kernel-based, or symmetric—is a universal approximator as long as it maintains this "distinguishability" property.

The Surprising Power of a Single Layer

Early proofs suggested that Transformers needed to be excessively deep to achieve universal approximation. However, Tokio Kajitsuka and Issei Sato demonstrated in Are Transformers with One Layer Self-Attention Using Low-Rank Weight Matrices Universal Approximators? that even a single layer of self-attention is sufficient.

The secret weapon is the Softmax function. Unlike a "Hardmax" (which only picks the most relevant token), Softmax preserves relative distances between all elements in a sequence. This allows a single attention head to aggregate global sequence information into a unique "ID" for each token. Even with low-rank weight matrices, the Softmax operator can prevent distinct input representations from collapsing into identical vectors, preserving the information necessary for the subsequent MLP to function.

Memorization and Efficiency

This ability to create unique contextual IDs also explains why Transformers are so efficient at memorization. In Provable Memorization Capacity of Transformers, Junghwan Kim, Michelle Kim, and Barzan Mozafari showed that Transformers can "hard-code" massive amounts of data using far fewer parameters than the total number of tokens. By exploiting sequence structure to create unique identifiers, the model can resolve ambiguities in structured data, allowing it to memorize $N$ sequences of length $n$ with only $\tilde{O}(d + n + \sqrt{nN})$ parameters.

Beyond Text: Visual and Prompt Tuning

The principle of token distinguishability extends to other domains:

In summary, the Transformer's power doesn't come from a single complex operation, but from the attention mechanism's ability to ensure that every token is seen as a unique entity within its environment. Once tokens are distinguishable, the rest of the network can treat sequence processing as a massive, solvable coordinate transformation.

Papers in this version

History & citationVersion 1 · 2026-10-04

No longer present in the current build · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_universal_approximation_through_token_di_72e14856,
  title = {Universal Approximation through Token Distinguishability in Transformers},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/universal-approximation-through-token-distinguishability-in-transformers/rdr_72e14856d502443ba838eddc8ae17479},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-12-04},
}

This exact version (version 1, frozen text):

@misc{lacuna_universal_approximation_through_token_di_72e14856_v1,
  title = {Universal Approximation through Token Distinguishability in Transformers},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/universal-approximation-through-token-distinguishability-in-transformers/rdr_72e14856d502443ba838eddc8ae17479/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-12-04},
}