[Paper Review] Learning Compressed Sentence Representations for On-Device Text Processing
This paper proposes four strategies to binarize pre-trained continuous sentence embeddings for on-device NLP, achieving near-identical performance to continuous counterparts (only ~2% relative drop) while reducing memory usage by over 98%. The best method uses a regularized autoencoder with a semantic-preserving loss, enabling fast Hamming distance-based similarity search that is over 12x faster than cosine similarity computation.
Vector representations of sentences, trained on massive text corpora, are widely used as generic sentence embeddings across a variety of NLP problems. The learned representations are generally assumed to be continuous and real-valued, giving rise to a large memory footprint and slow retrieval speed, which hinders their applicability to low-resource (memory and computation) platforms, such as mobile devices. In this paper, we propose four different strategies to transform continuous and generic sentence embeddings into a binarized form, while preserving their rich semantic information. The introduced methods are evaluated across a wide range of downstream tasks, where the binarized sentence embeddings are demonstrated to degrade performance by only about 2% relative to their continuous counterparts, while reducing the storage requirement by over 98%. Moreover, with the learned binary representations, the semantic relatedness of two sentences can be evaluated by simply calculating their Hamming distance, which is more computational efficient compared with the inner product operation between continuous embeddings. Detailed analysis and case study further validate the effectiveness of proposed methods.
Motivation & Objective
- To address the high memory and computational cost of continuous, real-valued sentence embeddings on low-resource devices like mobile phones.
- To enable efficient on-device text processing by transforming generic sentence embeddings into compact binary representations.
- To preserve semantic richness in binarized embeddings so they remain effective for downstream NLP tasks.
- To demonstrate that Hamming distance between binary codes can replace cosine similarity for semantic similarity evaluation, with improved computational efficiency.
- To explore multiple binarization strategies, including trainable and non-trainable methods, for flexible deployment.
Proposed method
- Proposes four binarization strategies: hard thresholding, random projection, PCA-based transformation, and a trainable regularized autoencoder with a semantic-preserving loss.
- Uses an autoencoder architecture with a reconstruction loss and an additional semantic-preserving loss term to maintain semantic structure in the binary codes.
- The semantic-preserving loss encourages similar sentences to have similar binary codes by minimizing the Hamming distance between positive pairs.
- Employs a deterministic thresholding strategy for binarization, which outperforms stochastic sampling in empirical evaluation.
- Evaluates binary representations using Hamming distance for similarity, which is computationally more efficient than inner product operations on continuous vectors.
- Employs the SentEval toolkit to benchmark performance across multiple downstream NLP tasks, including sentence matching and classification.
Experimental results
Research questions
- RQ1Can continuous sentence embeddings be effectively binarized while preserving their semantic utility for downstream NLP tasks?
- RQ2How does the performance of binary embeddings compare to continuous embeddings across diverse NLP benchmarks?
- RQ3Can Hamming distance between binary codes serve as an effective and faster alternative to cosine similarity for semantic similarity computation?
- RQ4What is the impact of different binarization strategies—especially trainable vs. non-trainable—on embedding quality and memory efficiency?
- RQ5How sensitive are the learned binary representations to the choice of embedding dimension?
Key findings
- The proposed regularized autoencoder with semantic-preserving loss achieves only a ~2% relative performance drop compared to continuous embeddings across multiple downstream NLP tasks.
- The binary representations reduce memory footprint to just 1.5% of the original continuous embeddings, achieving over 98% storage savings.
- Hamming distance computation between binary codes is over 12 times faster than cosine similarity computation on continuous vectors, with a measured speedup of 12.7x (3.67μs vs. 288ns).
- The best-performing model, AE-binary-SP, achieves optimal performance with a semantic-preserving loss weight of λsp = 0.8 on the MR dataset.
- Random projection and PCA-based binarization achieve competitive performance even with only 512 bits, making them suitable for low-memory scenarios.
- Nearest-neighbor retrieval using binary codes successfully retrieves semantically similar sentences, with results often more coherent than those from continuous embeddings.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.