[Paper Review] KDLSQ-BERT: A Quantized Bert Combining Knowledge Distillation with Learned Step Size Quantization
KDLSQ-BERT proposes a novel BERT quantization method that combines knowledge distillation (KD) with learned step size quantization (LSQ) to enable high-accuracy, ultra-low-bit inference. By transferring knowledge from a full-precision teacher BERT to a quantized student model during LSQ training, it achieves 14.9x model compression with minimal accuracy drop, outperforming state-of-the-art quantization methods on GLUE and SQuAD benchmarks even at 2-bit precision.
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.
Motivation & Objective
- Address the challenge of deploying large, computation-intensive BERT models on resource-constrained devices.
- Overcome the significant accuracy degradation typically seen in ultra-low-bit (e.g., 2-bit) quantization of BERT.
- Improve quantization performance by combining knowledge distillation with learned step size quantization (LSQ).
- Enable efficient, hardware-friendly quantization without altering the model architecture.
- Achieve high model compression ratios while maintaining competitive performance against full-precision BERT.
Proposed method
- Leverage knowledge distillation to transfer knowledge from a full-precision teacher BERT to a quantized student BERT during training.
- Apply learned step size quantization (LSQ) to the student model’s weights and activations, enabling differentiable quantization with learnable scale factors.
- Introduce a novel initialization method for LSQ scale factors to accelerate training and improve convergence.
- Combine distillation loss with ground truth loss during backpropagation to stabilize training and enhance performance.
- Train the student model end-to-end using both distillation and supervision signals, enabling effective knowledge transfer even at low bit-widths.
- Support arbitrary bit-width quantization (e.g., 2-bit, 4-bit) by design, avoiding limitations of ternary or mixed-precision approaches.
Experimental results
Research questions
- RQ1Can knowledge distillation significantly improve the performance of a quantized BERT model when combined with learned step size quantization?
- RQ2How effective is KDLSQ-BERT in maintaining high accuracy at ultra-low bit-widths (e.g., 2-bit) compared to existing quantization methods?
- RQ3Does the combination of distillation loss and ground truth loss lead to better convergence and accuracy than using either loss alone?
- RQ4To what extent can model compression be achieved without sacrificing performance, particularly in terms of parameter count and inference speed?
- RQ5Can the proposed method generalize across diverse NLP tasks, including GLUE and SQuAD benchmarks?
Key findings
- KDLSQ-BERT achieves a 14.9x model compression ratio (from 418 MB to 28 MB) while maintaining 83.987 average GLUE score at 2-bit quantization.
- At 4-bit quantization, KDLSQ-BERT achieves an average GLUE score of 84.414 with 54 MB (7.7x compression), outperforming full-precision TinyBERT (258 MB, 1.6x compression).
- With 2-2-4 weight, activation, and embedding quantization, KDLSQ-BERT achieves 85.013 MNLI and 89.989 RTE scores on GLUE, approaching full-precision BERT performance.
- On SQuAD 1.1, KDLSQ-BERT with 2-2-4 quantization achieves 88.996 EM, only 3.699 points below full-precision BERT (88.696), demonstrating strong zero-shot generalization.
- The method achieves 84.086 average SQuAD 2.0 F1 with 4-4-8 quantization, outperforming full-precision TinyBERT by 1.361 points.
- The combination of distillation and ground truth loss leads to a significant accuracy boost, especially at low bit-widths, confirming the effectiveness of dual supervision.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.