Can Transformers Learn n-gram Language Models?

Anej Svete, Nadav Borenstein, Mike Zhou, Isabelle Augenstein, Ryan Cotterell


Abstract
Much theoretical work has described the ability of transformers to represent formal languages. However, linking theoretical results to empirical performance is not straightforward due to the complex interplay between the architecture, the learning algorithm, and training data. To test whether theoretical lower bounds imply learnability of formal languages, we turn to recent work relating transformers to n-gram language models (LMs). We study transformers’ ability to learn random n-gram LMs of two kinds: ones with arbitrary next-symbol probabilities and ones where those are defined with shared parameters. We find that classic estimation techniques for n-gram LMs such as add-𝜆 smoothing outperform transformers on the former, while transformers perform better on the latter, outperforming methods specifically designed to learn n-gram LMs.
Anthology ID:
2024.emnlp-main.550
Volume:
Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing
Month:
November
Year:
2024
Address:
Miami, Florida, USA
Editors:
Yaser Al-Onaizan, Mohit Bansal, Yun-Nung Chen
Venue:
EMNLP
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
9851–9867
Language:
URL:
https://aclanthology.org/2024.emnlp-main.550/
DOI:
10.18653/v1/2024.emnlp-main.550
Bibkey:
Cite (ACL):
Anej Svete, Nadav Borenstein, Mike Zhou, Isabelle Augenstein, and Ryan Cotterell. 2024. Can Transformers Learn n-gram Language Models?. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pages 9851–9867, Miami, Florida, USA. Association for Computational Linguistics.
Cite (Informal):
Can Transformers Learn n-gram Language Models? (Svete et al., EMNLP 2024)
Copy Citation:
PDF:
https://aclanthology.org/2024.emnlp-main.550.pdf