N-Grammer: Augmenting Transformers with latent n-grams

Aurko Roy, Rohan Anil, Guangda Lai, Benjamin Lee, Jeffrey Zhao +11 more
7/13/2022
cs.CLcs.LG

No official code found. Best implementation: tensorflow/lingvo (2,864 stars, Apache-2.0, TensorFlow, last commit 2026-05-04). 1 more below.

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.

View on arXivView PDF

Code Implementations(2)

tensorflow/lingvoCommunity100%
TensorFlowApache-2.0

Lingvo

2,864451C, C++Jul 24, 20185 months agoApache-2.0
asrdistributedgpu-computinglanguage-modellm+12 more
MIT

Implementation of N-Grammer, augmenting Transformers with latent n-grams, in Pytorch

811PythonNov 28, 20213 years agoMIT
artificial-intelligencedeep-learningmemoryn-gramtransformers

Similar Papers

Cite this paper

@article{roy2022ngrammer,
  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},
  year   = {2022},
  eprint = {2207.06366},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2207.06366v1}
}

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/2207.06366.svg)](https://codeofpaper.com/paper/2207.06366)

Discussion