English

Formal Language Recognition by Hard Attention Transformers: Perspectives from Circuit Complexity

Computational Complexity 2022-04-15 v1 Artificial Intelligence Computation and Language Formal Languages and Automata Theory Machine Learning

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 AC0^0, 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 AC0^0 (Furst et al., 1984). In contrast, the non-AC0^0 languages MAJORITY and DYCK-1 are recognizable by AHAT networks, implying that AHAT can recognize languages that UHAT and GUHAT cannot.

Cite

@article{arxiv.2204.06618,
  title  = {Formal Language Recognition by Hard Attention Transformers: Perspectives from Circuit Complexity},
  author = {Yiding Hao and Dana Angluin and Robert Frank},
  journal= {arXiv preprint arXiv:2204.06618},
  year   = {2022}
}

Comments

To appear in Transactions of the Association for Computational Linguistics

R2 v1 2026-06-24T10:47:29.805Z