English

N-Grammer: Augmenting Transformers with latent n-grams

Computation and Language 2022-07-14 v1 Machine Learning

Abstract

Transformer models have recently emerged as one of the foundational models in natural language processing, and as a byproduct, there is significant recent interest and investment in scaling these models. However, the training and inference costs of these large Transformer language models are prohibitive, thus necessitating more research in identifying more efficient variants. In this work, we propose a simple yet effective modification to the Transformer architecture inspired by the literature in statistical language modeling, by augmenting the model with n-grams that are constructed from a discrete latent representation of the text sequence. We evaluate our model, the N-Grammer on language modeling on the C4 data-set as well as text classification on the SuperGLUE data-set, and find that it outperforms several strong baselines such as the Transformer and the Primer. We open-source our model for reproducibility purposes in Jax.

Keywords

Cite

@article{arxiv.2207.06366,
  title  = {N-Grammer: Augmenting Transformers with latent n-grams},
  author = {Aurko Roy and Rohan Anil and Guangda Lai and Benjamin Lee and Jeffrey Zhao and Shuyuan Zhang and Shibo Wang and Ye Zhang and Shen Wu and Rigel Swavely and Tao and Yu and Phuong Dao and Christopher Fifty and Zhifeng Chen and Yonghui Wu},
  journal= {arXiv preprint arXiv:2207.06366},
  year   = {2022}
}

Comments

8 pages, 2 figures

R2 v1 2026-06-25T00:53:22.592Z