Self-Attention Networks Can Process Bounded Hierarchical Languages
arXiv:2105.11115
Abstract
Despite their impressive performance in NLP, self-attention networks were recently proved to be limited for processing formal languages with hierarchical structure, such as , the language consisting of well-nested parentheses of types. This suggested that natural language can be approximated well with models that are too weak for formal languages, or that the role of hierarchy and recursion in natural language might be limited. We qualify this implication by proving that self-attention networks can process , the subset of with depth bounded by , which arguably better captures the bounded hierarchical structure of natural language. Specifically, we construct a hard-attention network with layers and memory size (per token per layer) that recognizes , and a soft-attention network with two layers and memory size that generates . Experiments show that self-attention networks trained on generalize to longer inputs with near-perfect accuracy, and also verify the theoretical memory advantage of self-attention networks over recurrent networks.
ACL 2021. 19 pages with extended appendix. Fixed a small typo in the formula at the end of page 5 (thank to Gabriel Faria). Code: https://github.com/princeton-nlp/dyck-transformer
References in corpus (7)
- HuggingFace's Transformers: State-of-the-art Natural Language Processing
- Encoding word order in complex embeddings
- On the Turing Completeness of Modern Neural Network Architectures
- Are Transformers universal approximators of sequence-to-sequence functions?
- Memory-Augmented Recurrent Neural Networks Can Learn Generalized Dyck Languages
- On the Computational Power of RNNs
- Establishing Strong Baselines for the New Decade: Sequence Tagging, Syntactic and Semantic Parsing with BERT