Characterizing the Expressivity of Fixed-Precision Transformer Language Models

Jiaoda Li, Ryan Cotterell

Overview

This paper provides the first exact theoretical characterization of "realistic" transformers—specifically, those utilizing fixed precision and soft attention without positional encodings. The authors prove that these models are exactly as powerful as a specific fragment of logic called $LTL[P]$. Consequently, these models can only recognize patterns that are "left-deterministic" and fundamentally cannot handle tasks involving counting or complex nesting.

Introduction & Motivation

While Transformers dominate modern AI, our theoretical understanding of why they work—and what they fundamentally cannot do—is still catching up to empirical results. Previous research has often relied on "idealized" versions of Transformers, assuming they possess infinite numerical precision or use "hard attention" (where the model picks exactly one token to look at).

However, real-world models use fixed precision (like 16-bit or 32-bit floats) and soft attention (a weighted average across tokens). This paper closes the gap between theory and practice by analyzing a model that mirrors the constraints of deployed systems. Specifically, the authors examine decoder-only Transformers with no positional encodings (NoPE), asking: What is the formal "language" of these machines?

Theoretical Framework

The authors employ formal logic, automata theory, and algebra to rigorously bound the expressive power of these models.

  1. Logical Mapping: They demonstrate that every such Transformer can be translated into a formula in $PFO^2[<]$ (a fragment of first-order logic). Conversely, any formula in $LTL[P]$ (Linear Temporal Logic using only the "past" operator) can be simulated by a Transformer.
  2. The Precision Argument: A key technical contribution is proving that under fixed precision, the "soft" nature of attention actually limits the model. Because floating-point numbers have a minimum representable value, if a model tries to attend to too many tokens, the weights "underflow" to zero. This effectively gives the Transformer a finite "attention span," a constraint the authors cleverly incorporate into their proofs.
  3. Automata Connection: They link these models to Partially Ordered Deterministic Finite Automata (PODFAs). These are state machines that can never return to a previous state once they've left it—essentially, they can only move "forward" through a hierarchy of patterns.

Core Insights

  • The "Past" Operator is the Limit: Without positional encodings, a Transformer's only sense of time is "this happened before that." This maps perfectly to the P (past) operator in logic.
  • Soft Attention is a Weakness, Not a Strength: Surprisingly, in a fixed-precision setting, soft attention is less expressive than "Unique Hard Attention" (UHA). While UHA models can recognize all star-free languages, soft-attention models are restricted to a subset called "left-deterministic" languages.
  • The Counting Ceiling: Because of fixed precision, these models can only "count" up to a small, constant threshold. They cannot recognize languages like PARITY or $a^n b^n$ because they cannot keep track of an arbitrary number of items as the sequence grows.
  • Left vs. Right Determinism: The models are "asymmetric." They can easily recognize if a sequence starts with a certain pattern (left-deterministic) but struggle to recognize if it ends with one (right-deterministic) because future masking prevents them from looking ahead.

Main Findings

Theoretical Equivalence

The paper establishes a unified framework connecting several distinct areas of computer science. They prove that Fixed-Precision NoPE Transformers are theoretically equivalent to $LTL[P]$, PODFAs, and $\mathcal{R}$-trivial monoids.

Extracted figure from page 2 of Characterizing the Expressivity of Fixed-Precision Transformer Language Models

Empirical Validation

The authors evaluated their theory using synthetic formal languages designed to test specific computational abilities, such as Counter Languages (e.g., $a^n b^n$), Regular Languages (e.g., PARITY), Star-free Languages (e.g., Dyck languages), and Polynomials. The models were trained on short sequences (length $\le 40$) and tested on much longer ones (up to 500) to measure length generalization.

The empirical results were strikingly binary:

  • Perfect Generalization: For languages within the $LTL[P]$ class (like $PT-2$ or $LDP-1$), the Transformers achieved 100% accuracy and generalized perfectly to long sequences.
  • Consistent Failure: For any language outside that class (like PARITY or Dyck-1,1), the models failed to generalize, regardless of the learning rate or random seed. This confirms that the limitation is architectural, not merely an artifact of training.

Limitations & Future Directions

  • The "NoPE" Constraint: The most significant limitation of this analysis is the omission of positional encodings. While this allowed the authors to isolate the "base" power of the architecture, real models usually use some form of position signal (like RoPE or ALiBi).
  • Future Work: The authors suggest that the logical next step is to characterize exactly how different positional encodings (Absolute vs. Relative) expand this logical "alphabet."
  • Stringent Evaluation: The authors define "success" as 100% perfect generalization. They acknowledge that in the real world, "approximate" success might be sufficient for some tasks, but from a formal perspective, anything less than 100% indicates the model hasn't truly "learned" the underlying generative logic.

Summary updated

BibTeX
@inproceedings{li2025characterizing,
  author = {Jiaoda Li and Ryan Cotterell},
  title = {{Characterizing the Expressivity of Fixed-Precision Transformer Language Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=29LwAgLFpj},
}
Figure