KDLSQ-BERT:一种结合知识蒸馏和学习步长的量化Bert Quantization
KDLSQ-BERT: A Quantized Bert Combining Knowledge Distillation with Learned Step Size Quantization
摘要:
最近,基于transformer的语言模型,如BERT,在一系列自然语言处理任务中表现出了巨大的性能提升。然而,这些语言模型在推理期间通常是计算昂贵和存储密集的。因此,很难将它们部署在资源受限的设备上。为了提高推理性能,在保持模型精度的同时减小模型规模,提出了一种新的量化方法KDLSQ-BERT,该方法将知识蒸馏(KD)和学习步长量化(LSQ)相结合,用于语言模型的量化.我们的方法的主要思想是,KD技术是利用知识从一个“教师”模型转移到一个“学生”模型时,利用LSQ在量化训练过程中的“学生”模型。在GLUE基准测试和SQuAD上的大量实验结果表明,我们提出的KDLSQ-BERT不仅在进行不同比特(例如2-bit $\sim$ 8-bit)量化时表现有效,而且优于现有的BERT量化方法,甚至在获得14.9倍压缩比的同时达到了与全精度基线模型相当的性能。我们的代码将公开。
英文摘要:
Recently, transformer-based language models such as BERT have shown tremendous performance improvement for a range of natural language processing tasks. However, these language models usually are computation expensive and memory intensive during inference. As a result, it is difficult to deploy them on resource-restricted devices. To improve the inference performance, as well as reduce the model size while maintaining the model accuracy, we propose a novel quantization method named KDLSQ-BERT that combines knowledge distillation (KD) with learned step size quantization (LSQ) for language model quantization. The main idea of our method is that the KD technique is leveraged to transfer the knowledge from a "teacher" model to a "student" model when exploiting LSQ to quantize that "student" model during the quantization training process. Extensive experiment results on GLUE benchmark and SQuAD demonstrate that our proposed KDLSQ-BERT not only performs effectively when doing different bit (e.g. 2-bit $\sim$ 8-bit) quantization, but also outperforms the existing BERT quantization methods, and even achieves comparable performance as the full-precision base-line model while obtaining 14.9x compression ratio. Our code will be public available.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。