Neural Networks Compression for Language Modeling

Artem M. Grachev, Dmitry I. Ignatov, Andrey V. SavchenkoPReMI 2017 · DOI

Abstract

In this paper, we consider several compression techniques for the language modeling problem based on recurrent neural networks (RNNs). It is known that conventional RNNs, e.g, LSTM-based networks in language modeling, are characterized with either high space complexity or substantial inference time. This problem is especially crucial for mobile applications, in which the constant interaction with the remote server is inappropriate. By using the Penn Treebank (PTB) dataset we compare pruning, quantization, low-rank factorization, and tensor train decomposition for LSTM networks in terms of model size and suitability for fast inference.

Introduction

Recurrent Neural Networks (RNNs), particularly Long Short-Term Memory (LSTM) networks, are the gold standard for language modeling. However, they are notoriously "heavy," requiring significant disk space and memory, while their inference time can be slow. This is a major hurdle for mobile applications where developers must choose between a laggy user experience or relying on a remote server, which raises privacy concerns and requires a constant internet connection. This study identifies which compression methods can shrink these models without sacrificing prediction quality, measured by perplexity (PP).

Compression Methodologies

The authors evaluate four distinct strategies on the Penn Treebank (PTB) dataset:

  • Pruning: Removing weights close to zero to create a sparse network, followed by retraining.
  • Quantization: Reducing precision from 32-bit floating-point to 8-bit integers.
  • Low-Rank Factorization: Decomposing large weight matrices into products of smaller matrices to reduce parameters and speed up multiplication.
  • Tensor Train (TT) Decomposition: Representing high-dimensional tensors as sets of smaller, low-rank "cores."

Key Results and Analysis

The experimental results highlight a clear trade-off between model size and accuracy. Low-rank factorization emerged as the most effective approach for practical deployment.

Table 1: Comparison of PTB benchmarks against Low-Rank (LR) and Tensor Train (TT) LSTM models.

As shown in the table above, the LR LSTM 650-650 model achieved a size of 16.8 MB, making it smaller than the standard "Small" benchmark (18.6 MB) while significantly improving accuracy (Test PP of 92.885 vs 117.659). By reducing the internal rank to 128, the model is optimized for efficient implementation on mobile hardware.

In contrast, while TT-decomposition is mathematically sophisticated, it failed to achieve acceptable quality in these experiments. The best TT-compressed model was both larger and less accurate than the simplest small benchmark.

Pruning and Quantization

The study also explored pruning and quantization as alternative methods for the small benchmark model.

Table 2: Impact of pruning and quantization on the LSTM 200-200 small benchmark.

Quantization successfully shrank the small benchmark from 18.6 MB to 4.7 MB with only a minor hit to perplexity. Pruning the output layer by 90% required additional training to recover performance, bringing perplexity down from 149.3 to 121.1.

Discussion and Hardware Constraints

A critical insight from this work is the "hidden cost" of certain compression types. While pruning reduces parameters on disk, "sparse computing" is often inefficient on standard mobile hardware without specialized chips. Similarly, 8-bit quantization saves space, but unless the hardware (like a TPU) natively supports 8-bit math, the CPU may still perform 32-bit calculations, negating speed benefits.

Low-rank factorization avoids these pitfalls by reducing the size of embedding and output layers—which typically account for two-thirds of the model—while maintaining dense matrix operations that are well-supported by current mobile CPUs and GPUs.

Conclusion

Low-rank factorization provides the best balance of compression and accuracy for LSTM-based language models. Future work may involve more exhaustive tuning of Tensor Train decomposition or exploring hybrid approaches. Until mobile hardware better supports sparse and 8-bit operations, matrix-based factorization remains the most practical path forward for on-device inference.

Summary updated

BibTeX
@inproceedings{grachev2017neural,
  author = {Artem M. Grachev and Dmitry I. Ignatov and Andrey V. Savchenko},
  title = {{Neural Networks Compression for Language Modeling}},
  booktitle = {PReMI},
  year = {2017},
  doi = {10.1007/978-3-319-69900-4\_44},
}
Figure