Compressing Neural Language Models by Sparse Word Representations

Yunchuan Chen, Lili Mou, Yan Xu, Ge Li, Zhi Jin

Introduction

Neural Language Models (NLMs) have become a cornerstone of modern NLP, yet they face significant deployment challenges due to their memory footprint. The primary bottleneck lies in the embedding and output layers, which scale linearly with the vocabulary size. Furthermore, infrequent words—the "long tail" of language—often suffer from poor representation because they appear too rarely during training for gradient descent to tune their vectors effectively.

This research, originally presented at ACL 2016, proposes a novel compression framework that leverages the semantic relationship between rare and frequent words. By representing uncommon words as sparse linear combinations of a core "base" vocabulary, the authors achieve substantial memory savings and, counterintuitively, improved predictive accuracy.

Proposed Method: Sparse Word Representations

The core innovation is a "compressed" architecture that replaces dense vectors for rare words with sparse codes.

Sparse Coding and Parameter Compression

The vocabulary is partitioned into a "Base" set (the top 8,000 most frequent words) and an "Uncommon" set. Each uncommon word is defined by a sparse code—a set of indices and coefficients pointing to base words. For instance, the word "algorithms" might be represented by a weighted combination of "algorithm" and other related frequent terms.

Architecture of the proposed compressed neural language model featuring sparse word representations and ZRegression.

This compression is applied to two critical subnets:

  1. Embedding Subnet: Instead of storing a full $D$-dimensional vector for every word, the model only stores sparse codes (typically 4–8 non-zero values).
  2. Prediction Subnet: The output layer weights for rare words are reconstructed on-the-fly using the same sparse codes and the weights of the base words.

ZRegression

To stabilize training under Noise-Contrastive Estimation (NCE), the authors introduce a ZRegression layer. This component predicts the normalization factor ($Z_h$) based on the current context, preventing the instabilities often associated with NCE in large-scale models.

Experimental Setup

The models were evaluated on a 2014 Wikipedia dump. While traditional n-gram models were trained on 1.6 billion words, the neural models utilized a 100-million-word subset. The vocabulary size was varied from 10,000 to 50,000 words to test scalability.

Key Results

The proposed method demonstrates that compression does not have to come at the cost of performance.

Perplexity (PPL) and memory usage as a function of vocabulary size. The bars represent memory usage, while the lines track perplexity.

Massive Memory Reduction

As shown in the figure above, the memory usage of standard models (the dark blue bars) grows linearly with vocabulary size. In contrast, the compressed models (yellow and red bars) maintain a nearly constant memory footprint. At a vocabulary size of 50,000, the method achieves a memory reduction of approximately 80%.

Improved Predictive Performance

Unlike typical compression techniques, this approach actually lowers perplexity (PPL). For a 50k vocabulary, the compressed LSTM-z,w model achieved a PPL of 129.2, outperforming the uncompressed version's 130.6. This improvement is attributed to the "dictionary intuition": by forcing rare words to be represented through common ones, the model benefits from a powerful regularization effect that helps it generalize better on the long tail of the vocabulary.

Conclusion

By treating rare words as combinations of frequent ones, this work provides a path toward deploying high-performance NLMs on resource-constrained devices. The dual benefit of massive compression and improved generalization suggests that sparsity is not just a storage optimization, but a meaningful structural prior for natural language.

Summary updated

BibTeX
@inproceedings{chen2016compressing,
  author = {Yunchuan Chen and Lili Mou and Yan Xu and Ge Li and Zhi Jin},
  title = {{Compressing Neural Language Models by Sparse Word Representations}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2016},
  doi = {10.18653/v1/p16-1022},
}
Figure