Compressing Language Models using Doped Kronecker Products

Urmish Thakker, Paul N. Whatmough, Matthew Mattina, Jesse G. BeuarXiv 2020

Abstract

Kronecker Products (KP) have successfully compressed small-scale IoT RNN applications by factors of 15-38x. However, applying KP to large-scale Natural Language Processing (NLP) tasks typically results in a significant accuracy loss, often around 26%. This paper introduces "doping," a method to recover this lost accuracy by adding an extremely sparse overlay matrix to the rigid KP structure, providing necessary degrees of freedom. We also present Co-matrix Dropout Regularization (CMR) to address the challenge of co-matrix adaptation (CMA) during training. Our results show that a 25MB LSTM model can be compressed by 25x with only a 1.4% loss in perplexity, outperforming traditional pruning and factorization methods.

Introduction

The deployment of state-of-the-art NLP models on resource-constrained IoT devices is hindered by their large memory footprints. For instance, a standard language model might require 25MB, while target IoT devices often have limited L2 cache (e.g., 1MB). Achieving the necessary 25x compression without sacrificing performance is a critical engineering hurdle. While Kronecker Products offer high compression, their inherent mathematical rigidity limits their expressibility in complex NLP tasks.

Methodology

The proposed Doped Kronecker Product (DKP) addresses the rigidity of standard KP. In a standard KP, a weight matrix $W$ is represented as $B \otimes C$. Changing a single element in $B$ or $C$ affects multiple elements in $W$, restricting the model's ability to reach optimal minima.

Illustration of KP rigidity and the Doping solution.

Doping introduces a sparse matrix $M_{sp}$ to the formulation: $W = B \otimes C + M_{sp}$. This overlay provides additional degrees of freedom, allowing the matrix to be updated more flexibly. To train these hybrid structures, we identified the phenomenon of Co-matrix Adaptation (CMA), where the model over-relies on the sparse component early in training. We introduce Co-matrix Dropout Regularization (CMR), which applies stochastic dropout to the outputs of the KP and sparse components independently, ensuring both structures contribute effectively to the final representation.

Experimental Results

Evaluated on the Penn Treebank (PTB) dataset using a medium-sized LSTM model, DKP demonstrated superior performance at high compression ratios. At 25x compression, DKP achieved a test perplexity of 83.24, representing only a 1.4% increase from the baseline (82.04).

Comparison of DKP with prior art in model compression.

In comparison, standard pruning at the same 25x ratio resulted in a perplexity of 88.55 (7.9% loss). More aggressive factorization methods like Hybrid Matrix Decomposition (HMD) and Low-Rank Matrix Factorization (LMF) saw losses of 15% and 27%, respectively. Furthermore, DKP achieved 2.5x more compression than existing quantization and weight distortion techniques while maintaining higher accuracy.

Conclusion and Future Work

Doped Kronecker Products provide a robust framework for compressing large language models for IoT deployment. By balancing the efficiency of KP with the flexibility of sparse overlays, DKP bridges the performance gap seen in traditional compression methods. Future work will explore hardware-efficient implementations of these sparse overlays and the potential synergy between DKP and low-bit quantization to push compression factors even further.

Summary updated

BibTeX
@misc{thakker2020compressing,
  author = {Urmish Thakker and Paul N. Whatmough and Matthew Mattina and Jesse G. Beu},
  title = {{Compressing Language Models using Doped Kronecker Products}},
  year = {2020},
  eprint = {2001.08896},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2001.08896},
}
Figure