Abstract
Standard word embeddings are memory-intensive, typically stored as 64-bit floats. This research demonstrates that memory usage can be reduced by up to 16x—compressing vectors to 8 or even 4 bits—with negligible performance loss in word similarity and dependency parsing tasks. We present methods for both post-processing quantization and training low-precision vectors from scratch using stochastic rounding and auxiliary update techniques.
Introduction
In Natural Language Processing (NLP), dense word embeddings like word2vec serve as the foundational representation for most models. However, these vectors impose a significant "memory tax." For instance, a vocabulary of 1 million words represented by 200-dimensional 64-bit float vectors requires approximately 1.6 GB of RAM. This memory requirement becomes a bottleneck for scaling to larger corpora or deploying models on mobile and edge devices. This study investigates whether such high numerical precision is necessary or if embeddings can be effectively represented with fewer bits.
Methodology
The researchers explored two primary strategies for memory reduction:
Post-processing Rounding
Pre-trained models can be compressed by truncating values to $n$-bit precision. A simple linear scaling maps continuous values into a fixed-point range (e.g., -128 to 127 for 8-bit representation).
Training with Limited Memory
Training low-precision models directly is challenging because standard Stochastic Gradient Descent (SGD) updates (often $\approx 10^{-5}$) are frequently rounded to zero in low-bit regimes. To overcome this, two methods were proposed:
- Stochastic Rounding: Instead of deterministic rounding, values are rounded up or down probabilistically based on their proximity to the target integers. This allows the model to capture the direction of small gradients over time.
- Auxiliary Update Vectors: A small high-precision buffer accumulates tiny updates. Once the accumulated value is sufficient to trigger a change in the low-precision vector, the update is applied and the buffer is cleared.
Experimental Setup
Models were trained on a 2013 Wikipedia dump and evaluated across several benchmarks:
- Word Similarity: 12 datasets, including WordSim-353, SimLex-999, and Rare-Word.
- Paraphrase (Bigrams): PPDB and various bigram similarity tasks to evaluate phrase-level semantic preservation.
- Downstream Task: Dependency parsing using English data from the CoNLL-X shared task.
Results and Discussion
The evaluation revealed that 8-bit fixed-point representation is virtually "lossless" for word embeddings. Across word similarity and parsing tasks, 8-bit models performed on par with their 64-bit counterparts.
The 8-Bit Sweet Spot
The results indicate that dense embeddings possess inherent redundancy, making them robust to quantization. At 8 bits per dimension, Spearman correlation scores for word similarity remained nearly identical to the original 64-bit baselines.
As shown in the table above, the 200-dimensional CBOW model achieved an average score of 0.5818 in its original form, while the 8-bit version slightly improved to 0.5825. Similarly, in dependency parsing, 8-bit embeddings achieved a Labeled Attachment Score (LAS) of 88.63%, marginally exceeding the 64-bit baseline of 88.58%.
Model Resilience
The Continuous Bag-of-Words (CBOW) architecture demonstrated greater resilience to extreme compression (4-bit) compared to the Skip-gram architecture. While 4-bit models began to show performance degradation, they still retained significant utility, offering a 16x reduction in memory compared to 64-bit floats.
Conclusion
This work proves that word2vec-style embeddings can be significantly compressed without sacrificing accuracy. By utilizing 8-bit representations, practitioners can achieve an 8x reduction in memory footprint. Future research should investigate whether these findings extend to more complex architectures, such as LSTMs or Transformers, and address the memory overhead of the broader neural network during the training phase.
Summary updated