Rank and run-time aware compression of NLP Applications

Urmish Thakker, Jesse G. Beu, Dibakar Gope, Ganesh Dasika, Matthew MattinaSustaiNLP @ EMNLP 2020 · DOI

Abstract

Sequence model based NLP applications can be large, yet many applications that benefit from them run on small devices with very limited compute and storage capabilities. As a result, there is a need for a compression technique that can achieve significant compression without negatively impacting inference run-time and task accuracy. This paper proposes a new compression technique called Hybrid Matrix Factorization (HMF) that achieves this dual objective. HMF improves low-rank matrix factorization (LMF) techniques by doubling the rank of the matrix using an intelligent hybrid-structure leading to better accuracy than LMF. Further, by preserving dense matrices, it leads to faster inference run-time than pruning or structure matrix based compression techniques. We evaluate the impact of this technique on 5 NLP benchmarks across multiple tasks (Translation, Intent Detection, Language Modeling) and show that for similar accuracy values and compression factors, HMF can achieve more than 2.32x faster inference run-time than pruning and 16.77% better accuracy than LMF.

The Challenge of Edge NLP

Deploying sophisticated NLP models like LSTMs and GRUs on edge devices—such as smartwatches and mobile phones—requires a delicate balance between three competing goals: high compression to fit memory constraints, high accuracy for language understanding, and fast run-time speed to ensure real-time responsiveness without excessive battery drain.

Existing methods often force a compromise. Pruning removes individual weights to create small, accurate models, but the resulting "sparse" matrices are inefficient for modern CPUs to process. Low-Rank Matrix Factorization (LMF) maintains speed through dense math but significantly reduces the "rank" (expressibility) of the model, causing accuracy to plummet. Structured Matrices offer high compression but frequently require specialized hardware to achieve actual speed gains.

Methodology: Hybrid Matrix Factorization (HMF)

HMF addresses these issues by splitting the weight matrix into two horizontal components rather than treating it as a uniform block.

Figure 1: The HMF architecture splits a weight matrix into a dense upper part (A') and a low-rank factored lower part (B*C).

As illustrated in Figure 1, the upper part ($A'$) remains a fully parameterized dense matrix, providing "rich" features. The lower part is compressed into a low-rank factorization ($B \times C$), providing "constrained" features while saving significant space. By concatenating these, the resulting matrix achieves double the rank of a standard LMF matrix with the same number of parameters. Because the operations remain dense, HMF is inherently compatible with standard CPU libraries like Eigen, avoiding the overhead of sparse data structures.

Experimental Results

The research team evaluated HMF across five diverse NLP benchmarks, including Language Translation (NMT_VIEN), Language Modeling (PTB), Intent Detection, Slot Filling (ATIS), and Text Classification (SemEval-2010).

Figure 2: Performance on Language Translation tasks, comparing HMF (labeled HLF) against Pruning (P) and standard LMF across various speed-up factors.

As shown in the Language Translation results (Figure 2), HMF (labeled as HLF in the charts) consistently maintains a superior balance between speed-up and accuracy (BLEU score). Key insights from the evaluation include:

  • Superior Speed vs. Pruning: HMF achieved 2.32× faster inference for the same accuracy level. While pruning looks efficient on paper, the "bookkeeping" required to track non-zero weights on mobile CPUs like the Cortex-A73 often negates its benefits.
  • Higher Accuracy vs. LMF: HMF provided 16.77% better accuracy (or lower perplexity) at equivalent compression factors by preserving higher representational expressibility.
  • Massive Gains over Structured Matrices: HMF showed a 30× speed-up over techniques like circulant matrices for the benchmarks evaluated.

Discussion and Conclusion

The success of HMF lies in the realization that accuracy in RNNs is closely tied to matrix rank. By allowing some features to be "high-definition" (dense) and others "constrained" (low-rank), the model prioritizes representational power where it matters most. This "sparsity by design" approach ensures hardware friendliness from the start.

While currently optimized for LSTMs and GRUs, the core concept of hybrid structures offers a promising path for compressing other architectures, including Transformers, in future research.

Summary updated

BibTeX
@inproceedings{thakker2020rank,
  author = {Urmish Thakker and Jesse G. Beu and Dibakar Gope and Ganesh Dasika and Matthew Mattina},
  title = {{Rank and run-time aware compression of NLP Applications}},
  booktitle = {SustaiNLP @ EMNLP},
  year = {2020},
  doi = {10.18653/v1/2020.sustainlp-1.2},
}
Figure