Formal Language Recognition by Hard Attention Transformers: Perspectives from Circuit Complexity
Yiding Hao, Dana Angluin, and Robert Frank

TL;DR
This paper investigates the computational capabilities of different hard attention Transformer models, showing that some are limited to simple language classes while others can recognize more complex formal languages.
Contribution
It introduces and analyzes three variants of hard attention Transformers, establishing their expressive power and limitations in recognizing formal languages.
Findings
UHAT and GUHAT are limited to AC$^0$ languages.
AHAT can recognize non-AC$^0$ languages like MAJORITY and DYCK-1.
GUHAT cannot recognize DYCK or PARITY languages.
Abstract
This paper analyzes three formal models of Transformer encoders that differ in the form of their self-attention mechanism: unique hard attention (UHAT); generalized unique hard attention (GUHAT), which generalizes UHAT; and averaging hard attention (AHAT). We show that UHAT and GUHAT Transformers, viewed as string acceptors, can only recognize formal languages in the complexity class AC, the class of languages recognizable by families of Boolean circuits of constant depth and polynomial size. This upper bound subsumes Hahn's (2020) results that GUHAT cannot recognize the DYCK languages or the PARITY language, since those languages are outside AC (Furst et al., 1984). In contrast, the non-AC languages MAJORITY and DYCK-1 are recognizable by AHAT networks, implying that AHAT can recognize languages that UHAT and GUHAT cannot.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsFerroelectric and Negative Capacitance Devices · Advanced Memory and Neural Computing · Semiconductor materials and devices
MethodsAttention Is All You Need · Linear Layer · Adam · Absolute Position Encodings · Byte Pair Encoding · Position-Wise Feed-Forward Layer · Dense Connections · Multi-Head Attention · Layer Normalization · Softmax
