Transformer Working Memory Enables Regular Language Reasoning and Natural Language Length Extrapolation
Preprint
Abstract
Unlike recurrent models, conventional wisdom has it that Transformers cannot perfectly model regular languages. Inspired by the notion of working memory, we propose a new Transformer variant named RegularGPT. With its novel combination of Weight-Sharing, Adaptive-Depth, and Sliding-Dilated-Attention, RegularGPT constructs working memory along the depth dimension, thereby enabling efficient and successful modeling of regular languages such as PARITY. We further test RegularGPT on the task of natural language length extrapolation and surprisingly find that it rediscovers the local windowed attention effect deemed necessary in prior work for length extrapolation.Keywords
All Related Versions
This publication has 10 references indexed in Scilit:
- Overcoming a Theoretical Limitation of Self-Attention2022
- Adaptive Semiparametric Language ModelsTransactions of the Association for Computational Linguistics, 2021
- How Many Layers and Why? An Analysis of the Model Depth in Transformers2021
- Theoretical Limitations of Self-Attention in Neural Sequence ModelsTransactions of the Association for Computational Linguistics, 2020
- On the Ability and Limitations of Transformers to Recognize Formal Languages2020
- Do Transformers Need Deep Long-Range Memory?2020
- Transformer-XL: Attentive Language Models beyond a Fixed-Length Context2019
- What Does BERT Look at? An Analysis of BERT’s Attention2019
- Long-term working memory.Psychological Review, 1995
- Three models for the description of languageIEEE Transactions on Information Theory, 1956