English

Transformer Working Memory Enables Regular Language Reasoning and Natural Language Length Extrapolation

Computation and Language 2023-05-09 v1

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

Cite

@article{arxiv.2305.03796,
  title  = {Transformer Working Memory Enables Regular Language Reasoning and Natural Language Length Extrapolation},
  author = {Ta-Chung Chi and Ting-Han Fan and Alexander I. Rudnicky and Peter J. Ramadge},
  journal= {arXiv preprint arXiv:2305.03796},
  year   = {2023}
}
R2 v1 2026-06-28T10:27:19.674Z