Saturated Transformers are Constant-Depth Threshold Circuits
William Merrill, Ashish Sabharwal, Noah A. Smith
TL;DR
The paper analyzes saturated transformers through circuit complexity, showing that hard-attention limits to AC^0 are surpassed when using saturated attention. It proves that transformers with floating-point activations can be simulated by constant-depth threshold circuits, placing them in TC^0, while rational-valued variants can achieve universal language recognition under size-preserving assumptions. Empirically, saturating attention enables recognition of the majority language, which lies outside AC^0, and the paper proves that per-token representations stay within O(log n) bits, enabling a TC^0 implementation. Together, these results reposition saturated attention as a meaningful bridge between practical transformer capabilities and formal circuit-based power, with future work on uniformity and comparisons to soft attention.
Abstract
Transformers have become a standard neural network architecture for many NLP problems, motivating theoretical analysis of their power in terms of formal languages. Recent work has shown that transformers with hard attention are quite limited in power (Hahn, 2020), as they can be simulated by constant-depth AND/OR circuits (Hao et al. 2021). However, hard attention is a strong assumption, which may complicate the relevance of these results in practice. In this work, we analyze the circuit complexity of transformers with saturated attention: a generalization of hard attention that more closely captures the attention patterns learnable in practical transformers. We first show that saturated transformers transcend the known limitations of hard-attention transformers. We then prove saturated transformers with floating-point values can be simulated by constant-depth threshold circuits, giving the class $\mathsf{TC}^0$ as an upper bound on the formal languages they recognize.
