Online Embedding Compression for Text Classification Using Low Rank Matrix Factorization

Anish Acharya, Rahul Goel, Angeliki Metallinou, Inderjit S. Dhillon

Introduction

Deep learning has transformed Natural Language Processing (NLP), but the resulting models are often too large for deployment on mobile devices or high-traffic production servers. The primary source of this bloat is the word embedding layer, which can account for over 98% of a model's total parameters. This paper presents a novel "online" compression technique that reduces model size by up to 90% with minimal impact on accuracy.

The Challenge of Large Embeddings

In a typical NLP architecture, a vocabulary of 100,000 words with 300-dimensional vectors results in an embedding matrix of 60 million parameters. While quantization (reducing bit-precision) can shrink models, it is often "lossy" and lacks flexibility. Traditional "offline" compression methods, which shrink embeddings before training, typically suffer from significant accuracy drops because the compressed representations are not optimized for the specific downstream task.

Methodology: Online Low-Rank Factorization

The authors propose a two-step "Online Embedding Compression" strategy to address these limitations.

1. Low-Rank Matrix Factorization (LMF)

Using Singular Value Decomposition (SVD), the large embedding matrix $W$ is decomposed into two smaller matrices, $W_a$ and $W_b$. This replaces a single massive layer with two thin "bottleneck" layers, allowing for an arbitrary compression fraction ($p$).

Low-Rank Matrix Factorization of the embedding layer.

2. Online Retraining and CALR

Unlike post-processing methods, this factorization is integrated into the training loop. After the initial SVD, the model undergoes fine-tuning to allow the new layers to recover information lost during compression. To facilitate this, the authors introduced the Cyclically Annealed Learning Rate (CALR). This schedule combines a triangular wave pattern (Cyclic LR) with exponential decay, helping the model navigate the loss landscape to find new optimal minima for the compressed weights.

Experimental Results

The approach was evaluated on the SST2 sentiment benchmark and a proprietary "Books Intent Classification" dataset.

Performance and Efficiency

The method achieved a 90% compression ratio on the SST2 dataset with an LSTM model, reducing size from ~53MB to ~7MB with only a 1% relative accuracy drop. Crucially, this method consistently outperformed 8-bit and 16-bit quantization in terms of accuracy-to-size trade-offs.

Accuracy recovery during online retraining for LSTM and DAN-RAND models compared to quantization baselines.

Key Insights

  • Redundancy: Word embedding spaces are naturally overcomplete; a lower-dimensional projection can capture essential features for specific tasks.
  • Recovery: The accuracy drop following SVD is temporary. Fine-tuning allows the low-rank matrices to optimize for the task, nearly matching original performance.
  • Inference Speed: Mathematical analysis shows that this method can lead to faster inference times than standard quantization by reducing the total number of floating-point operations (FLOPs).

Conclusion

By combining online low-rank factorization with a specialized learning rate schedule, the authors demonstrate that high-performance NLP models can be made significantly smaller without sacrificing state-of-the-art accuracy. This paves the way for deploying sophisticated language models in resource-constrained environments.

Summary updated

BibTeX
@inproceedings{acharya2019online,
  author = {Anish Acharya and Rahul Goel and Angeliki Metallinou and Inderjit S. Dhillon},
  title = {{Online Embedding Compression for Text Classification Using Low Rank Matrix Factorization}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.1609/aaai.v33i01.33016196},
}
Figure