NarrowBERT: Accelerating Masked Language Model Pretraining and Inference

Haoxin Li, Phillip Keung, Daniel Cheng, Jungo Kasai, Noah A. Smith
1/11/2023
cs.CLcs.LG

No official code found. Best implementation: lihaoxin2020/narrowbert (8 stars, last commit 2023-08-04).

Abstract

Large-scale language model pretraining is a very successful form of self-supervised learning in natural language processing, but it is increasingly expensive to perform as the models and pretraining corpora have become larger over time. We propose NarrowBERT, a modified transformer encoder that increases the throughput for masked language model pretraining by more than $2\times$. NarrowBERT sparsifies the transformer model such that the self-attention queries and feedforward layers only operate on the masked tokens of each sentence during pretraining, rather than all of the tokens as with the usual transformer encoder. We also show that NarrowBERT increases the throughput at inference time by as much as $3.5\times$ with minimal (or no) performance degradation on sentence encoding tasks like MNLI. Finally, we examine the performance of NarrowBERT on the IMDB and Amazon reviews classification and CoNLL NER tasks and show that it is also comparable to standard BERT performance.

View on arXivView PDF

Code Implementations(1)

Code for paper NarrowBERT: Accelerating Masked Language Model Pretraining and Inference

80PythonMay 7, 20233 years ago

Similar Papers

Cite this paper

@article{li2023narrowbert,
  title  = {NarrowBERT: Accelerating Masked Language Model Pretraining and Inference},
  author = {Haoxin Li and Phillip Keung and Daniel Cheng and Jungo Kasai and Noah A. Smith},
  year   = {2023},
  eprint = {2301.04761},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2301.04761v2}
}

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

Discussion