Slim Embedding Layers for Recurrent Neural Language Models

Zhongliang Li, Raymond Kulhanek, Shaojun Wang, Yunxin Zhao, Shuang Wu

Abstract

Neural language models (LMs) are often constrained by the massive memory requirements of their embedding and softmax layers, which scale linearly with vocabulary size. This paper presents Slim Embedding (SE), a structured parameter-sharing technique that decomposes word embeddings into shared sub-vectors. By randomly but uniformly assigning these sub-vectors to words, SE significantly reduces model size and improves inference speed while maintaining, or even improving, perplexity. Evaluations across diverse datasets, including the One Billion Word Benchmark, demonstrate that SE can compress embedding layers by up to 100x with minimal performance loss.

Introduction

Recurrent Neural Language Models (RNN LMs) have become a cornerstone of natural language processing. However, their deployment is often hindered by a massive parameter footprint. In typical architectures, the vast majority of parameters reside in the input embedding layer and the output softmax layer. This memory bloat creates significant bottlenecks for deployment on edge devices, increases infrastructure costs for serving, and complicates distributed training due to high communication overhead.

While existing compression techniques like pruning or element-wise hashing exist, they often introduce architectural complexity or fail to provide actual memory savings during training. This paper introduces Slim Embedding (SE), a cache-friendly approach to parameter sharing that addresses these limitations.

Methodology: Slim Embedding (SE)

The core idea of Slim Embedding is to share contiguous "sub-vectors" across the vocabulary rather than sharing individual weights or entire vectors.

Input and Output Layer Compression

In the SE framework, the embedding dimension is divided into $K$ smaller chunks or sub-vectors. Instead of a unique vector for every word, the model maintains a global pool of $M$ sub-vectors, where $M$ is significantly smaller than the total number of chunks required for a full vocabulary. Each word's embedding is constructed by concatenating $K$ sub-vectors randomly selected from this pool.

Illustration of the Slim Embedding (SE) parameter-sharing scheme, where words $w_i$ are represented by concatenations of shared sub-vectors $a_j$.

For the output softmax layer, the authors employ a dynamic programming optimization. By pre-computing the dot products between the hidden state and the $M$ shared sub-vectors, the final score for any word can be efficiently calculated by summing its assigned $K$ partial dot products. This reduces the time complexity of the output layer from $O(V \times H)$ to $O(M \times H/K + V \times K)$, where $V$ is vocabulary size and $H$ is hidden state dimension.

Experimental Results

The authors evaluated SE on several benchmarks, ranging from the Penn Treebank (10K vocab) to Google’s One Billion Word Benchmark (793K vocab).

Robustness to Compression

A key finding is the model's remarkable robustness to high compression ratios. As long as $K > 1$ (i.e., words are composed of multiple sub-vectors), the model maintains its perplexity even at extreme compression levels.

Comparison of Test Perplexity (PPL) across different compression rates for SE and baseline methods. SE maintains significantly lower PPL at high reciprocal compression rates compared to pruning (PM) and other softmax (SM) baselines.

On the PTB dataset, an SE model using only 1% of the original input embedding parameters achieved a perplexity of 82.62, outperforming the uncompressed baseline (85.33). This suggests that the parameter sharing may act as a beneficial form of regularization.

Performance and Efficiency

  • Scalability: On the BillionW dataset, a 3-layer LSTM with SE (1/32 input, 1/16 output compression) achieved a competitive perplexity of 38.3 with only 254 million parameters.
  • Inference Speed: Due to the dynamic programming trick, the SE model is faster than the uncompressed baseline. On a GPU, minibatch processing time dropped from 38ms to 25ms.
  • Downstream Tasks: In machine translation reranking (WMT12), the compressed LM matched the BLEU score of the uncompressed version (26.25 vs 26.11).

Discussion and Conclusion

The success of Slim Embedding highlights the redundancy in traditional embedding layers. By sharing contiguous blocks of memory, SE remains cache-friendly, making it practical for both training and inference on standard hardware.

A notable limitation occurs when $K=1$, where multiple words share identical embeddings, leading to a sharp degradation in performance. Future work may explore non-random assignment of sub-vectors, such as using semantic clustering to assign similar sub-vectors to related words, potentially further enhancing the efficiency of the representation.

Summary updated

BibTeX
@inproceedings{li2018slim,
  author = {Zhongliang Li and Raymond Kulhanek and Shaojun Wang and Yunxin Zhao and Shuang Wu},
  title = {{Slim Embedding Layers for Recurrent Neural Language Models}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2018},
  doi = {10.1609/aaai.v32i1.12000},
}
Figure