Abstract
Neural machine translation (NMT) has achieved levels of fluency and adequacy that would have been surprising a short time ago. Output quality is extremely relevant for industry purposes; however, it is equally important to produce results in the shortest time possible, mainly for latency-sensitive applications and to control cloud hosting costs. In this paper, we show the effectiveness of translating with 8-bit quantization for models that have been trained using 32-bit floating point values. Results show that 8-bit translation makes a non-negligible impact in terms of speed with no degradation in accuracy and adequacy.
Introduction
While Neural Machine Translation (NMT) has revolutionized translation quality, it comes with a heavy "computational tax." NMT models are significantly slower than the older phrase-based and syntax-based statistical models they replaced. In industrial settings, this creates two main hurdles: high operational costs and increased latency. Running 32-bit floating-point models often requires expensive GPUs or massive CPU clusters. For interactive applications like speech-to-speech translation, users require near-instant results. While GPUs are efficient for large batches, CPUs are often more practical for single-sentence translation (the "batch size 1" problem), yet they struggle with the heavy mathematical requirements of NMT.
Methodology
Researchers at IBM investigated the "attentional model of translation" (an encoder-decoder network using GRUs). Profiling their C++ implementation revealed that over 85% of computation time was spent on matrix-vector and matrix-matrix multiplications. To address this bottleneck, they implemented an 8-bit quantization strategy:
- Post-Training Quantization: Existing models trained in 32-bit floating point were converted to 8-bit integers for the inference (decoding) stage without requiring retraining.
- Intel SSE4 Instructions: Specialized CPU instructions were utilized to perform four 8-bit multiplications simultaneously.
- Hybrid Precision: To maintain accuracy, heavy matrix math was performed in 8-bit while storing intermediate results in 32-bit floating point, avoiding the precision loss associated with complex re-scaling logic.
- Selective Quantization: Complex operations like
tanhandsigmoidremained in floating point, as they accounted for less than 7% of total CPU time.
The approach was evaluated across several language pairs, including Dutch-English (En-Nl, Nl-En), Russian-English (Ru-En), and German-English (En-De, De-En), using large-scale datasets ranging from 17M to 31M training sentences.
Results and Discussion
The results demonstrate that NMT models are remarkably robust to quantization. Throwing away 75% of the bit-precision in the weights during decoding left the model's linguistic understanding intact.
As shown in the data, the 8-bit implementation achieved a 4-6x speedup over the 32-bit version. For instance, in German-English (De-En) translation, speed increased from 7.3 to 37.5 words per core second (WPSC). Crucially, the impact on automated quality scores (BLEU) was negligible, typically varying by less than 0.2 points. Human evaluators confirmed these findings, rating the 8-bit translations as equal in fluency and adequacy to their 32-bit counterparts.
Furthermore, the 8-bit NMT system outperformed older syntax-based statistical systems in speed while maintaining the superior quality inherent to neural models. This suggests that for single-sentence translation where GPUs lose their parallel processing advantage, a highly optimized 8-bit CPU implementation is superior.
Conclusion
This study proves that 8-bit quantization is a highly effective method for reducing NMT latency and cost without sacrificing quality. By accumulating 8-bit products into 32-bit results, the implementation remains simple and easily integrated into production pipelines. Future work may explore training models in low precision from the start to potentially yield even greater efficiency gains.
Summary updated