The Power of Hard Attention Transformers on Data Sequences: A formal language theoretic perspective
Pascal Bergsträßer, Chris Köcher, Anthony Widjaja Lin, Georg Zetzsche
Abstract
Formal language theory has recently been successfully employed to unravel the power of transformer encoders. This setting is primarily applicable in Natural Language Processing (NLP), as a token embedding function (where a bounded number of tokens is admitted) is first applied before feeding the input to the transformer. On certain kinds of data (e.g. time series), we want our transformers to be able to handle arbitrary input sequences of numbers (or tuples thereof) without a priori limiting the values of these numbers. In this paper, we initiate the study of the expressive power of transformer encoders on sequences of data (i.e. tuples of numbers). Our results indicate an increase in expressive power of hard attention transformers over data sequences, in stark contrast to the case of strings. In particular, we prove that Unique Hard Attention Transformers (UHAT) over inputs as data sequences no longer lie within the circuit complexity class (even without positional encodings), unlike the case of string inputs, but are still within the complexity class (even with positional encodings). Over strings, UHAT without positional encodings capture only regular languages. In contrast, we show that over data sequences UHAT can capture non-regular properties. Finally, we show that UHAT capture languages definable in an extension of linear temporal logic with unary numeric predicates and arithmetics.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
4 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Logical Languages Accepted by Transformer Encoders with Hard Attention cites Tighter Bounds on the Expressivity of Transformer Encoders
- Lower Bounds for Chain-of-Thought Reasoning in Hard-Attention Transformers cites Logical Languages Accepted by Transformer Encoders with Hard Attention
- Benefits and Limitations of Communication in Multi-Agent Reasoning cites Lower Bounds for Chain-of-Thought Reasoning in Hard-Attention Transformers
- Transformers are Inherently Succinct cites Logical Languages Accepted by Transformer Encoders with Hard Attention
- iTransformer: Inverted Transformers Are Effective for Time Series Forecasting cites Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting
- iTransformer: Inverted Transformers Are Effective for Time Series Forecasting cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
Cited by top-tier papers4
- Benefits and Limitations of Communication in Multi-Agent ReasoningMichael Rizvi-Martel, Satwik Bhattamishra, Neil Rathi, Guillaume Rabusseau et al.ICLR 2026 · 9 citations
- Transformers are Inherently SuccinctPascal Bergsträßer, Ryan Cotterell, Anthony W. LinICLR 2026 · 5 citations
- Lower Bounds for Chain-of-Thought Reasoning in Hard-Attention TransformersAlireza Amiri Bavandpour, Xinting Huang, Mark Rofin, Michael HahnICML 2025
- On the Intrinsic Limits of Transformer Image Embeddings in Non-Solvable Spatial ReasoningSiyi Lyu, Quan Liu, Feng YanICML 2026
Builds on10
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
- Informer: Beyond Efficient Transformer for Long Sequence Time-Series ForecastingHaoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang et al.AAAI 2021 · 7,289 citations
- iTransformer: Inverted Transformers Are Effective for Time Series ForecastingYong Liu, Tengge Hu, Haoran Zhang, Haixu Wu et al.ICLR 2024 · 1,703 citations
- Tighter Bounds on the Expressivity of Transformer EncodersDavid Chiang, Peter Cholak, Anand PillayICML 2023 · 80 citations
- Logical Languages Accepted by Transformer Encoders with Hard AttentionPablo Barceló, Alexander Kozachinskiy, Anthony Widjaja Lin, Vladimir V. PodolskiiICLR 2024 · 36 citations
Related papers
- Masked Hard-Attention Transformers Recognize Exactly the Star-Free LanguagesAndy Yang, David Chiang, Dana AngluinNeurIPS 2024 · 58 citations
- Characterizing the Expressivity of Fixed-Precision Transformer Language ModelsJiaoda Li, Ryan CotterellNeurIPS 2025 · 18 citations
- On the Ability and Limitations of Transformers to Recognize Formal LanguagesSatwik Bhattamishra, Kabir Ahuja, Navin GoyalEMNLP 2020 · 7 citations
- Are Transformers universal approximators of sequence-to-sequence functions?Chulhee Yun, Srinadh Bhojanapalli, Ankit Singh Rawat, Sashank J. Reddi et al.ICLR 2020 · 481 citations
- Circuit Complexity Bounds for RoPE-based Transformer ArchitectureBo Chen, Xiaoyu Li, Yingyu Liang, Jiangxuan Long et al.EMNLP 2025 · 33 citations
