Putting Transformer Theories to the Test
Organizations: Yale University · Microsoft Research
Abstract
Several formal theories have been developed to characterize the capabilities and limitations of the transformer architecture, each employing different abstractions that capture different features of the architecture. Due to the differences in their underlying assumptions and conceptual frameworks, these theories can disagree in their predictions about what tasks transformers find easy or hard. We map out seven theories of transformer capability (Star-free, , , C-RASP, MPC, BAPO, and Sensitivity) and translate their results into a common matrix of predictions across a suite of tasks covering different computational structures. We provide new theoretical results to complete this matrix. We then evaluate theoretical predictions through controlled experiments measuring in-distribution sample complexity, length generalization, and pretrained language model performance. We find that no single theory explains the observed pattern of successes and failures. When a theory does not capture the transformer behaviors relevant to a task, its predictions break down; for instance, we show that the -hop induction task is predicted hard by C-RASP because it does not model content-dependent attention, but we train small transformers on this task that length-generalize. Similarly, theories assuming hard attention like and BAPO predict binary majority to be hard, for which we also find success in practice. Together, our results point to several specific features that a theory of transformers must capture: soft rather than hard attention, dynamic content-dependent retrieval, bounded computation at each position, an account of learnability and inductive biases, and a combination of upper and lower bounds.
Figures & tables
| Star-free | C-RASP | MPC | BAPO | Sensitivity | |||
|---|---|---|---|---|---|---|---|
| Key Assumptions | |||||||
| Token primitives | a symbols | 01 bits | 01 bits | a symbols | a symbols | a symbols | 01 bits |
| Information flow | causal | bidirect. | bidirect. | causal | bidirect. | causal | bidirect. |
| Attention type | hard | hard | softmax | uniform | msg. passing | hard | softmax |
| Local computation | bounded | bounded | bounded | bounded | unbounded | unbounded | bounded |
| Formal relation to transformers | =T^{\mbox{\hskip 0.7pt\hbox to5.29pt{\vbox to1.98pt{\pgfpicture\makeatletter\hbox{\hskip 0.306pt\lower 1.13397pt\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#000000} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.4pt} \lx@inpgf@ignorespaces\nullfont\lxSVG@begingroup@{_scopebegin=1} \lxSVG@closescope \hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} {\lx@inpgf@ignorespaces}\lx@inpgf@ignorespaces{\lx@inpgf@ignorespaces}\lx@inpgf@ignorespaces\lxSVG@roundcap\lxSVG@begingroup@{stroke-linecap=round} \lx@inpgf@ignorespaces\lxSVG@roundjoin\lxSVG@begingroup@{stroke-linejoin=round} \lx@inpgf@ignorespaces{{}{{}}{} {}{} {}{}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.612pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 6.48 1.99 L 0 1.99 L 2.29 3.89}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope } \lxSVG@closescope {\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}\hss}\lxSVG@discardpath\lxSVG@closescope \hss}}\lxSVG@closescope\endpgfpicture}}}}_{\mathrm{hard}} | \supset T^{\mbox{\hskip 0.7pt\hbox to5.29pt{\vbox to4.79pt{\pgfpicture\makeatletter\hbox{\hskip 0.306pt\lower-0.81pt\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#000000} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.4pt} \lx@inpgf@ignorespaces\nullfont\lxSVG@begingroup@{_scopebegin=1} \lxSVG@closescope \hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} {\lx@inpgf@ignorespaces}\lx@inpgf@ignorespaces{\lx@inpgf@ignorespaces}\lx@inpgf@ignorespaces\lxSVG@roundcap\lxSVG@begingroup@{stroke-linecap=round} \lx@inpgf@ignorespaces\lxSVG@roundjoin\lxSVG@begingroup@{stroke-linejoin=round} \lx@inpgf@ignorespaces{{}{{}}{} {}{} {}{}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.612pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 6.48 3.29 L 0 3.29 L 2.29 5.08}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope {}{{}}{} {}{} {}{}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.612pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 0 1.1 L 6.48 1.1 L 4.18 -0.7}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope } \lxSVG@closescope {\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}\hss}\lxSVG@discardpath\lxSVG@closescope \hss}}\lxSVG@closescope\endpgfpicture}}}}_{\mathrm{hard}} | \supset T^{\mbox{\hskip 0.7pt\hbox to5.29pt{\vbox to4.79pt{\pgfpicture\makeatletter\hbox{\hskip 0.306pt\lower-0.81pt\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#000000} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.4pt} \lx@inpgf@ignorespaces\nullfont\lxSVG@begingroup@{_scopebegin=1} \lxSVG@closescope \hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} {\lx@inpgf@ignorespaces}\lx@inpgf@ignorespaces{\lx@inpgf@ignorespaces}\lx@inpgf@ignorespaces\lxSVG@roundcap\lxSVG@begingroup@{stroke-linecap=round} \lx@inpgf@ignorespaces\lxSVG@roundjoin\lxSVG@begingroup@{stroke-linejoin=round} \lx@inpgf@ignorespaces{{}{{}}{} {}{} {}{}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.612pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 6.48 3.29 L 0 3.29 L 2.29 5.08}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope {}{{}}{} {}{} {}{}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.612pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 0 1.1 L 6.48 1.1 L 4.18 -0.7}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope } \lxSVG@closescope {\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}\hss}\lxSVG@discardpath\lxSVG@closescope \hss}}\lxSVG@closescope\endpgfpicture}}}}_{\mathrm{soft}} | \subset T^{\mbox{\hskip 0.7pt\hbox to5.29pt{\vbox to1.98pt{\pgfpicture\makeatletter\hbox{\hskip 0.306pt\lower 1.13397pt\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#000000} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.4pt} \lx@inpgf@ignorespaces\nullfont\lxSVG@begingroup@{_scopebegin=1} \lxSVG@closescope \hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} {\lx@inpgf@ignorespaces}\lx@inpgf@ignorespaces{\lx@inpgf@ignorespaces}\lx@inpgf@ignorespaces\lxSVG@roundcap\lxSVG@begingroup@{stroke-linecap=round} \lx@inpgf@ignorespaces\lxSVG@roundjoin\lxSVG@begingroup@{stroke-linejoin=round} \lx@inpgf@ignorespaces{{}{{}}{} {}{} {}{}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.612pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 6.48 1.99 L 0 1.99 L 2.29 3.89}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope } \lxSVG@closescope {\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}\hss}\lxSVG@discardpath\lxSVG@closescope \hss}}\lxSVG@closescope\endpgfpicture}}}}_{\mathrm{soft}} | \supset T^{\mbox{\hskip 0.7pt\hbox to5.29pt{\vbox to4.79pt{\pgfpicture\makeatletter\hbox{\hskip 0.306pt\lower-0.81pt\hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} \lxSVG@begingroup@{stroke=#000000} \lxSVG@begingroup@{fill=#000000} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.4pt} \lx@inpgf@ignorespaces\nullfont\lxSVG@begingroup@{_scopebegin=1} \lxSVG@closescope \hbox to0.0pt{\lxSVG@begingroup@{_scopebegin=1} {\lx@inpgf@ignorespaces}\lx@inpgf@ignorespaces{\lx@inpgf@ignorespaces}\lx@inpgf@ignorespaces\lxSVG@roundcap\lxSVG@begingroup@{stroke-linecap=round} \lx@inpgf@ignorespaces\lxSVG@roundjoin\lxSVG@begingroup@{stroke-linejoin=round} \lx@inpgf@ignorespaces{{}{{}}{} {}{} {}{}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.612pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 6.48 3.29 L 0 3.29 L 2.29 5.08}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope {}{{}}{} {}{} {}{}\lxSVG@begingroup@{_scopebegin=1} \lxSVG@setlinewidth{\the\pgflinewidth}\lxSVG@begingroup@{stroke-width=0.612pt} \lx@inpgf@ignorespaces{}\lxSVG@stroke\lxSVG@drawpath@unclipped{M 0 1.1 L 6.48 1.1 L 4.18 -0.7}{fill:none} \lx@inpgf@ignorespaces \lxSVG@closescope } \lxSVG@closescope {\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}{\lx@inpgf@ignorespaces}\hss}\lxSVG@discardpath\lxSVG@closescope \hss}}\lxSVG@closescope\endpgfpicture}}}}_{\mathrm{soft}} | none | learnability |
Appendix figures & tables16 assets
Supplementary material from the paper’s appendix.
Appendix
| Task | Settings | Tokens | ID | LG | LLM |
|---|---|---|---|---|---|
| All , Any , Majority , Parity | one each | ✓ | ✓ | ✓ | |
| Index | 8 symbols | ✓ | ✓ | ✓ | |
| Index-All , Index-Any , Index-Parity | ✓ | ✓ | ✓ | ||
| Sparse-All , Sparse-Any , Sparse-Parity | ✓ | ✓ | – | ||
| BinaryAdd | blocked or interleaved input; MSB- or LSB-first output | ✓ | ✓ | ✓ | |
| Dyck- , Dyck- | depth bound | ✓ | ✓ | ✓ |
| In-distribution | Length generalization | |
|---|---|---|
| Model sizes (layers, width, heads) | S , M , L | |
| Positional encoding | RoPE | 9 encodings ( Table 5 ), plus uniform attention |
| Attention mask | causal | causal; also bidirectional where the task allows |
| Training sizes | one of | jointly |
| Evaluation sizes | the training size | , and to in steps of |
| Training examples | , split evenly over training sizes |
| Encoding | Position information |
|---|---|
| NoPE | None ( Kazemnejad et al., 2023 ) |
| NoPE + BOS | None; a learned beginning-of-sequence token is prepended |
| Sinusoidal | Fixed sinusoidal encoding added to the input embeddings ( Vaswani et al., 2017 ) |
| RoPE | Rotary encoding of queries and keys, base ( Su et al., 2024 ) |
| YaRN | RoPE with YaRN dynamic scaling; the training length is the longest training input ( Peng et al., 2024a ) |
| T5 bias | Learned relative attention bias, 32 buckets, maximum distance 128 ( Raffel et al., 2020 ) |
| Model | Model ID | Reasoning control |
|---|---|---|
| GPT-5 | gpt-5-2025-08-07 | effort none ; also medium |
| GPT-5.4 mini | gpt-5.4-mini-2026-03-17 | effort none |
| GPT-4o mini | gpt-4o-mini-2024-07-18 | not applicable |
| DeepSeek-V3.2 | DeepSeek-V3.2 | effort none |
| Gemini 2.5 Flash | gemini-2.5-flash | thinking budget 0 |
| Tasks | Chance level | Reason |
|---|---|---|
| All , Any , Parity , Index-All/Any , Index-Parity , Sparse-All/Any , Sparse-Parity | Bits are drawn with a per-bit probability that makes both labels equally likely. | |
| Edge Existence , Directed Reachability , Undirected Reachability | Each graph yields one positive and one negative query. With dense supervision, the all-negative answer is correct exactly on negative queries. | |
| Majority | ( even) | Bits are uniform and ties are labeled , so label is more likely: at , at . |
| Index | The queried symbol is uniform over values. | |
| -Hop Induction | equally likely symbols plus the null answer, which has probability . For , at ; for , for all . | |
| Dyck- , Dyck- , BinaryAdd | (full sequence) | Sequence answers: the legal next-token set after each prefix, or all bits of the sum. We do not normalize. |
| Relation | Result | |
|---|---|---|
| Star-free | ||
| a | Star-free \mathrel{{\color[rgb]{0.1484,0.4531,0.6133}\subseteq}} Causal Hard Attn. with caveats | Yang et al. (2024, Theorem 5) show that strictly future-masked, rightmost-hard-attention transformers without positional encodings recognize every star-free language. The construction goes through the B-RASP programming language, which allows both strictly future-masked and strictly past-masked attention. B-RASP is equivalent to linear temporal logic with both since and until , which defines exactly the star-free languages. Every LTL formula is equivalent to one that uses only since when evaluated at the last position ( Kamp, 1968 ; Gabbay et al., 1980 ) , so every B-RASP program with both kinds of masking has an equivalent program that uses only causal future masking. However, this rewriting has a cost, as the past-only formula can be exponentially larger than an equivalent formula that uses both directions ( Artale et al., 2023 ) . |
| b | Causal Hard Attn. \mathrel{{\color[rgb]{0.1484,0.4531,0.6133}\subseteq}} Star-free | By the same theorems ( Yang et al., 2024 , Theorems 2 and 4) , showing equivalence between masked hard-attention transformers, B-RASP , and LTL, every language recognized by masked hard-attention transformers is star-free; this direction preserves depth. This result describes masked hard-attention transformers without positional encoding, with positional information implicitly encoded in the masking. With rational sinusoidal encoding, the class of languages recognized by masked hard-attention transformers (with both past and future attention) grows to the regular languages in ( Yang et al., 2024 , Corollary 8) . |
| c | Star-free \mathrel{{\color[rgb]{0.1484,0.4531,0.6133}\subseteq}} Bidir. Hard Attn. | Barceló et al. (2024, Theorem 1) show that bidirectional unique-hard-attention transformers with positional encodings recognize every language definable in , which contains and hence every star-free language. |
| d | Bidir. Hard Attn. \mathrel{{\color[rgb]{0.7461,0.3164,0.1797}\nsubseteq}} Star-free | Bidirectional hard-attention transformers with positional encodings recognize every regular language in ( Barceló et al., 2024 , Corollary 1) . This includes , for example, which is regular and in but not star-free ( Schützenberger, 1965 ) . |
| Task | Star-free | C-RASP | MPC | BAPO | Sensitivity | ||
|---|---|---|---|---|---|---|---|
| Boolean | |||||||
| All / Any | ✓ 1 | ✓ 2 | ✓ 2 | ✓ 3 | ✓ 4 | ✓ 5 | ✓ 6 |
| Majority | ✗ 7 | ✗ 7 | ✓ 8 | ✓ 9 | ✓ 10 | ✗ 11 | ✓ 12 |
| Parity | ✗ 7 | ✗ 7 | ✓ 8 | ✗ 13 | ✓ 4 | ✓ 5 | ✗ 14 |
| Index | |||||||
| Index | ✗ 15 | ✓ 16 | ✓ 16 | ✗ 17 | ✓ 18 | ✓ 19 | ✓ 20 |
| ID | Explanation |
|---|---|
| 1 | All / Any are star-free. They are defined in by and , respectively, where holds when position contains a one. |
| 2 | All / Any have depth-one circuits. All and Any are respectively a single unbounded-fan-in AND and OR gate, so they lie in both and . |
| 3 | All / Any have small C-RASP programs. All tests whether the prefix count of zeros is zero; Any tests whether the prefix count of ones is positive. |
| 4 | Regular languages have constant-round, sublinear-memory MPC algorithms. Gilbert & Hajiaghayi (2023, Theorem 3.2) give an -round MPC algorithm with local memory for any fixed regular language. This covers Any / All , Parity , and constant-depth Dyck . |
| 5 | Regular languages are BAPO -easy. Schnabel et al. (2025, Theorem 2) show that every regular language has a constant-bandwidth BAPO ; this includes All / Any , Parity , and fixed-depth Dyck . For fixed alphabet and hop count , each output language of -Hop Induction is star-free and hence regular by Proposition 18 . Concatenating the finite-state summaries for the possible outputs gives a constant-bandwidth BAPO for the full output. |
| 6 | All / Any have low average sensitivity. Flipping a bit changes All ( Any ) exactly when all other bits are one (zero). Under uniform Boolean inputs, both therefore have average sensitivity , giving an Easy prediction. This prediction uses the uniform distribution rather than the class-balanced distribution we use in experiments. |
Transformer
Transformers are neural architectures that use attention to model relationships among sequence elements in language, vision, and scientific data.
See all 540 papers