Abstract
Transformer-based architectures like BERT have achieved great success in a wide range of Natural Language tasks. Despite their decent performance, the models still have numerous parameters and high computational complexity, impeding their deployment in resource-constrained environments. Post-Training Quantization (PTQ), which enables low-bit computations without extra training, could be a promising tool. In this work, we conduct an empirical evaluation of three PTQ methods on BERT-Base and BERT-Large: Linear Quantization (LQ), Analytical Clipping for Integer Quantization (ACIQ), and Outlier Channel Splitting (OCS). OCS theoretically surpasses the others in minimizing the Mean Square quantization Error and avoiding distorting the weights' outliers. That is consistent with the evaluation results of most language tasks of GLUE benchmark and a reading comprehension task, SQuAD. Moreover, low-bit quantized BERT models could outperform the corresponding 32-bit baselines on several small language tasks, which we attribute to the alleviation of over-parameterization. We further explore the limit of quantization bit and show that OCS could quantize BERT-Base and BERT-Large to 3-bits and retain 98% and 96% of the performance on the GLUE benchmark accordingly. Moreover, we conduct quantization on the whole BERT family, i.e., BERT models in different configurations, and comprehensively evaluate their performance on the GLUE benchmark and SQuAD, hoping to provide valuable guidelines for their deployment in various computation environments.
Introduction
Transformer-based models like BERT have revolutionized Natural Language Processing (NLP), but their massive scale—often hundreds of millions of parameters—requires significant computational power. This overhead makes deployment on resource-constrained devices, such as smartphones or IoT hardware, a major challenge. While Quantization-Aware Training (QAT) can achieve high accuracy, it requires expensive retraining. Post-Training Quantization (PTQ) is a faster alternative that requires no retraining but often suffers from significant performance drops at low bit-widths. This paper investigates the limits of PTQ for BERT models, identifying the most effective mathematical techniques for handling their weight distributions.
Quantization Methodologies
The researchers evaluated three distinct PTQ strategies, focusing on weight quantization to maintain hardware compatibility:
- Linear Quantization (LQ): A standard baseline mapping floating-point values to a discrete grid.
- Analytical Clipping for Integer Quantization (ACIQ): This method clips extreme outliers based on assumed Gaussian or Laplacian weight distributions to minimize overall Mean Square Error (MSE).
- Outlier Channel Splitting (OCS): The most sophisticated approach, OCS identifies channels with extreme values and "splits" them into two channels with halved weights. This preserves critical information while moving values closer to the distribution center, avoiding the information loss associated with clipping.
Experimental Evaluation
The models were tested on two industry-standard benchmarks: the GLUE (General Language Understanding Evaluation) suite for diverse linguistic tasks, and SQuAD v1.1 (Stanford Question Answering Dataset) for rigorous reading comprehension.
Key Results and Discussion
Performance and Compression Limits
Outlier Channel Splitting (OCS) proved remarkably resilient compared to LQ and ACIQ. As shown in the figure below, OCS successfully compressed BERT-Base to 3-bits with only a 1.5-point drop in average GLUE score, retaining 98% of its original performance while reducing model size by approximately 90%.
The Regularization Effect
An unexpected finding was that 8-bit quantization sometimes improved accuracy on smaller GLUE tasks. For instance, 8-bit BERT-Base achieved an average GLUE score of 81.76, slightly higher than the 32-bit baseline of 81.61. This suggests that precision loss can act as a regularizer, preventing overfitting on small datasets by effectively "smoothing" the noise.
Model Robustness and Task Sensitivity
Larger models like BERT-Large demonstrated greater robustness to quantization due to their inherent over-parameterization. While they experience a slightly higher percentage drop at extreme 3-bit limits, their absolute performance remains superior to smaller models.
Task sensitivity also varied; SQuAD proved more sensitive to quantization than GLUE. This is likely because reading comprehension requires finer-grained reasoning, which is more easily disrupted by the rounding errors inherent in low-bit arithmetic.
BERT Family Analysis
Evaluating the entire BERT family (from Tiny to Large) provides a new rule of thumb for deployment: a low-bit version of a larger model (e.g., 4-bit BERT-Medium) often outperforms a full-precision version of a smaller model (e.g., 32-bit BERT-Small) while occupying a similar memory footprint. The use of the Arithmetic Computation Effort (ACE) metric further quantifies the energy and hardware efficiency gains possible through these quantized models.
Conclusion
This study demonstrates that with advanced PTQ methods like OCS, BERT models can be compressed to as low as 3-bits while maintaining high performance. These findings provide a roadmap for deploying state-of-the-art NLP models on edge devices, balancing the trade-offs between model size, computational effort, and task accuracy. Future work will explore the quantization of activations and mixed-precision strategies to further enhance efficiency.
Summary updated