Q8BERT: Quantized 8Bit BERT

Ofir Zafrir, Guy Boudoukh, Peter Izsak, Moshe Wasserblat
10/14/2019
cs.CLcs.LG

Official code: IntelLabs/nlp-architect (2,934 stars, Apache-2.0, PyTorch, last commit 2022-11-07).

Abstract

Recently, pre-trained Transformer based language models such as BERT and GPT, have shown great improvement in many Natural Language Processing (NLP) tasks. However, these models contain a large amount of parameters. The emergence of even larger and more accurate models such as GPT2 and Megatron, suggest a trend of large pre-trained Transformer models. However, using these large models in production environments is a complex task requiring a large amount of compute, memory and power resources. In this work we show how to perform quantization-aware training during the fine-tuning phase of BERT in order to compress BERT by $4\times$ with minimal accuracy loss. Furthermore, the produced quantized model can accelerate inference speed if it is optimized for 8bit Integer supporting hardware.

View on arXivView PDF

Code Implementations(1)

PyTorchApache-2.0

A model library for exploring state-of-the-art deep learning topologies and techniques for optimizing Natural Language Processing neural networks

2,934441CSS, HTMLMay 17, 20183 years agoApache-2.0
bertdeep-learningdeeplearningdynetnlp+5 more

Cite this paper

@article{zafrir2019qbert,
  title  = {Q8BERT: Quantized 8Bit BERT},
  author = {Ofir Zafrir and Guy Boudoukh and Peter Izsak and Moshe Wasserblat},
  year   = {2019},
  eprint = {1910.06188},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1910.06188}
}

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

Discussion