Abstract
Modern information retrieval and vector databases rely on dense embeddings to represent diverse data modalities. While Matryoshka Representation Learning (MRL) has emerged as a standard for adaptive representation by using nested truncation, it necessitates expensive model retraining and suffers from significant accuracy loss at low bitrates. We introduce Contrastive Sparse Representation (CSR), a novel framework that utilizes sparse coding to generate highly efficient, adaptive embeddings. By projecting dense vectors into a high-dimensional latent space and retaining only the Top-K active neurons, CSR achieves up to a 69× speedup in retrieval tasks. Experimental results across vision, language, and multimodal benchmarks demonstrate that CSR consistently outperforms MRL in both accuracy and training efficiency.
Introduction
In large-scale AI systems, there is a fundamental tension between representation accuracy and system latency. High-fidelity embeddings typically require high-dimensional dense vectors, which increase the computational cost of similarity searches and storage requirements. Matryoshka Representation Learning (MRL) addresses this by training models to pack information into the early dimensions of a vector, allowing for truncation. However, MRL's reliance on truncation limits its expressiveness at very low dimensions and requires the entire backbone model to be retrained from scratch, which is computationally prohibitive for large-scale pre-trained models.
Methodology
Contrastive Sparse Representation (CSR) shifts the paradigm from truncation to sparsity. Instead of cutting a vector short, CSR projects the embedding into a wider latent space where only a small subset of neurons (Top-K) are activated.
The CSR Framework
CSR is designed as a "plug-and-play" adapter that sits atop existing, frozen backbone models such as CLIP or ResNet. The architecture consists of a lightweight 2-layer Multi-Layer Perceptron (MLP) that performs the following:
- Sparse Autoencoding (SAE): The model is trained to reconstruct the original dense embedding from a sparse latent representation, ensuring that the most critical information is preserved.
- Non-negative Contrastive Loss (NCL): To prevent the "dead latent" problem common in sparse models—where certain neurons never activate—the authors introduce a contrastive objective. This encourages the model to utilize the full breadth of the latent space, ensuring that sparse features remain discriminative for downstream tasks.
- Inference Optimization: By utilizing specialized GPU kernels (e.g., cuSPARSE), CSR performs sparse matrix multiplication. This allows the system to ignore zero-value elements, translating mathematical sparsity into tangible hardware speedups.
Experimental Evaluation
The researchers evaluated CSR across three primary domains to test its versatility:
- Vision: Evaluated on ImageNet-1K (1.3 million images) for classification and 1-Nearest Neighbor (1-NN) retrieval.
- Language: Tested using the MTEB benchmark, covering tasks such as text classification (Banking77), clustering (Reddit), and retrieval (SciFACT).
- Multimodal: Performance was measured on MS COCO and Flickr30K for cross-modal search (image-to-text and text-to-image).
Key Insights
Sparsity vs. Truncation
A central finding of the research is that sparsity is inherently more expressive than truncation. A sparse vector with 16 active dimensions can represent a significantly more complex feature set than a dense vector truncated to the first 16 dimensions. This flexibility allows the model to dynamically allocate its "computational budget" based on the specific features of the input.
Scaling and Speed
Counter-intuitively, as the total hidden dimension ($h$) of the CSR model increases, retrieval speed often improves. This occurs because a larger latent space reduces the probability of non-zero elements overlapping between vectors, thereby minimizing the number of multiplications required during similarity calculations.
Results
CSR demonstrates substantial improvements over the current state-of-the-art:
- Efficiency: CSR achieved a 69× speedup on ImageNet 1-NN tasks compared to traditional quantization methods.
- Accuracy: On ImageNet, CSR outperformed MRL by 9% at equivalent computational budgets. In text retrieval tasks (MTEB), the performance gain reached 15%.
- Training Cost: Because CSR utilizes frozen backbones, it can be trained in approximately 30 minutes on a single GPU. In contrast, MRL requires dozens of GPU hours to retrain the full backbone.
- Zero-Shot Performance: CSR proved highly effective in zero-shot multimodal scenarios, even outperforming MRL models that had undergone full fine-tuning.
Limitations and Future Work
Despite its success, CSR faces challenges in multimodal alignment (e.g., CLIP spaces), where the "dead latent" problem is more persistent. Additionally, while sparse kernels provide massive speedups, they are currently less optimized for extremely small values of $K$ compared to highly mature dense kernels like cuBLAS. Future research will focus on optimizing hardware-level sparse operations and refining alignment strategies for multimodal latent spaces.
Summary updated