Abstract: Large language models (LLMs) generate high-dimensional embeddings that capture rich semantic and syntactic information. However, high-dimensional embeddings exacerbate computational complexity and storage requirements, thereby hindering practical deployment. To address these challenges, we propose a novel training framework named Sequential Matryoshka Embedding Compression (SMEC). This framework introduces the Sequential Matryoshka Representation Learning (SMRL) method to mitigate gradient variance during training, the Adaptive Dimension Selection (ADS) module to reduce information degradation during dimension pruning, and the Selectable Cross-batch Memory (S-XBM) module to enhance unsupervised learning between high- and low-dimensional embeddings. Experiments on image, text, and multimodal datasets demonstrate that SMEC achieves significant dimensionality reduction while maintaining performance. For instance, on the BEIR dataset, our approach improves the performance of compressed LLM2Vec embeddings (256 dimensions) by 1.1 points and 2.7 points compared to the Matryoshka-Adaptor and Search-Adaptor models, respectively.
Introduction
In modern search and recommendation systems, embeddings serve as the numerical backbone for representing complex data. While high-dimensional embeddings from Large Language Models (LLMs) like Llama-3 or GPT-4 capture nuanced semantic information, they introduce the "curse of dimensionality." Storing and searching through vectors with 3,000 to 4,000 dimensions at scale is computationally expensive and financially burdensome.
Existing solutions, such as Matryoshka Representation Learning (MRL), attempt to "nest" information so that a subset of dimensions (e.g., the first 128) remains useful. However, MRL faces two primary challenges: gradient variance caused by parallel training of multiple nested sizes, and rigid truncation, which assumes the most critical information is always located at the beginning of the vector.
Methodology
SMEC addresses these limitations through three core architectural innovations designed to stabilize training and optimize information density.
Sequential Matryoshka Representation Learning (SMRL)
Unlike standard MRL, which trains all nested dimensions in parallel, SMRL adopts a sequential approach (e.g., 1024 → 512 → 256). This stabilizes the gradient updates, as shared dimensions are no longer pulled in conflicting directions by multiple simultaneous loss functions. This sequential refinement allows the model to converge more accurately on compressed representations.
Adaptive Dimension Selection (ADS)
To move beyond rigid truncation, SMEC utilizes the ADS module. By employing a learnable "gate" via the Gumbel-Softmax trick, the model identifies the most salient dimensions across the entire original embedding rather than just the prefix. This ensures that the compressed vector retains the highest possible "information achievement rate."
Selectable Cross-batch Memory (S-XBM)
To bridge the gap between high-dimensional "teacher" embeddings and low-dimensional "student" embeddings, SMEC uses a memory queue of historical features. The S-XBM module specifically selects "hard samples"—those most similar to the query—to sharpen the model's discriminative capabilities during unsupervised learning.
Experimental Results
The framework was evaluated across diverse benchmarks, including BEIR (text retrieval), Products-10K (image retrieval), and Fashion-200K (multimodal retrieval).
Performance and Compression
SMEC demonstrated the ability to achieve up to 14x lossless compression for LLM2Vec-7B embeddings. As shown in the performance analysis, the SMEC-enhanced models consistently outperform standard LLM2Vec baselines even at significantly lower dimensionalities. On the BEIR benchmark, SMEC at 256 dimensions outperformed the Matryoshka-Adaptor by 1.1 points and the Search-Adaptor by 2.7 points.
Discussion and Conclusion
Our findings suggest that the "magic" of LLM embeddings does not strictly require thousands of dimensions. By intelligently selecting dimensions and stabilizing the training process through sequential learning, SMEC proves that 256 dimensions can often perform as well as 3,584.
While SMEC currently requires domain-specific labeled data to train its adaptor layers, it represents a significant step toward making LLM-based retrieval systems more efficient. Future work will explore full-parameter training to enable LLMs to produce compressed embeddings natively, further reducing the overhead of the adaptor-based approach.
Summary updated