Binarized LSTM Language Model

Xuan Liu, Di Cao, Kai Yu

Neural language models, particularly Long Short-Term Memory (LSTM) networks, are fundamental to modern Natural Language Processing (NLP) and Automatic Speech Recognition (ASR). However, their deployment on edge devices—such as smartphones and IoT hardware—is often hindered by their significant memory footprint. Standard LSTMs store parameters as 32-bit floating-point numbers, and in large-vocabulary tasks, the embedding layer alone can consume hundreds of megabytes of RAM.

Presented at NAACL-HLT 2018, this research introduces the Binarized LSTM Language Model (BLLM). This approach binarizes both word embeddings and model weights to 1-bit values, achieving up to a 31x reduction in memory usage while maintaining competitive performance.

Methodology

The researchers proposed two primary architectural variations to address the memory bottleneck:

  1. BELM (Binarized Embedding Language Model): Binarizes only the input and output word embeddings, which typically account for the majority of the model's size.
  2. BLLM (Binarized LSTM Language Model): Binarizes both the embeddings and the internal LSTM cell weights for maximum compression.

Technical Innovations

To ensure the model remains trainable and expressive despite the extreme quantization, several techniques were employed:

  • Deterministic Binarization & STE: Parameters are converted to -1 or 1 using a sign function. A Straight-Through Estimator (STE) is used during backpropagation to allow gradients to pass through the non-differentiable binarization layer.
  • Scaling Factors: Binary values are scaled by $\sqrt{1/H}$ (where $H$ is the hidden layer size) to maintain numerical stability and prevent vanishing gradients.
  • Linear Adapters: Small, full-precision linear layers are inserted before and after binarized layers to act as adapters, helping the model regain representational capacity lost during quantization.
  • Training from Scratch: The authors found that binarization must be integrated into the training process from the start rather than applied to a pre-trained model.

Experimental Results

The models were evaluated on several benchmarks, including the English Penn TreeBank (PTB), a Chinese SMS corpus, and the SWB-Fisher conversational speech corpus.

Table showing memory usage and perplexity (PPL) for different models on the PTB dataset.

As shown in the results, the BLLM achieves a massive reduction in memory footprint. For instance, with a hidden size of 500, the memory usage drops from 170.8 MB to just 5.4 MB—a 31.6x compression ratio. Remarkably, the BELM variant often outperformed the baseline full-precision LSTM (e.g., 88.0 vs 91.8 PPL on PTB), suggesting that binarization can act as a powerful form of regularization.

Semantic Integrity and Analysis

A critical concern with 1-bit quantization is the potential loss of semantic nuance. However, the researchers demonstrated that binarized word embeddings retain their semantic relationships.

2D visualization of binarized word embeddings showing semantic clustering of related terms.

Visualization of the resulting vectors shows that words like "mother," "parents," and "husband" remain clustered near "father," proving that binary vectors can still capture complex linguistic relationships. Furthermore, ablation studies revealed that the inclusion of a non-binarized linear layer just before the output is critical; binarizing the output layer directly leads to significant performance degradation.

Conclusion

The Binarized LSTM Language Model demonstrates that it is possible to compress state-of-the-art NLP models to a fraction of their original size without sacrificing accuracy. By achieving over 30x compression, this work paves the way for deploying sophisticated language modeling and speech recognition capabilities on low-resource edge devices.

Summary updated

BibTeX
@inproceedings{liu2018binarized,
  author = {Xuan Liu and Di Cao and Kai Yu},
  title = {{Binarized LSTM Language Model}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2018},
  doi = {10.18653/v1/n18-1192},
}
Figure