Can Transformers Learn n-gram Language Models?

Anej Svete, Nadav Borenstein, Mike Zhou, Isabelle Augenstein, Ryan Cotterell
10/3/2024
cs.CL

No confident code implementation found for this paper. 3 possible matches can be shown below.

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 \emph{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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 3 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{svete2024transformers,
  title  = {Can Transformers Learn n-gram Language Models?},
  author = {Anej Svete and Nadav Borenstein and Mike Zhou and Isabelle Augenstein and Ryan Cotterell},
  year   = {2024},
  eprint = {2410.03001},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.03001v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.03001.svg)](https://codeofpaper.com/paper/2410.03001)

Discussion