In the world of Large Language Models (LLMs) and Information Retrieval (IR), bigger has almost always meant better. High-dimensional embeddings—those long vectors of numbers representing the semantic meaning of text—capture subtle nuances that smaller vectors miss. A 3,072-dimensional vector from OpenAI usually understands your query better than a 256-dimensional one.
But “bigger” comes with a steep price tag. Storing millions of high-dimensional vectors requires massive amounts of memory. Searching through them (vector search) creates high latency and computational costs. Engineers are often stuck in a dilemma: choose high accuracy and burn through the budget, or choose efficiency and accept worse search results.
What if you didn’t have to choose?
Researchers from Google Cloud AI have introduced a novel framework called Matryoshka-Adaptor. Inspired by Russian nesting dolls, this method allows you to take powerful, high-dimensional embeddings and “shrink” them significantly without losing their performance. Whether you have labeled training data or just a pile of documents, this adaptor can compress your vectors by 6x to 12x while maintaining state-of-the-art retrieval quality.

As shown in Figure 1, the results are striking. The red and black lines (representing the Adaptor) maintain high performance even as dimensions drop, whereas standard embeddings often require their full size to function well.
The Background: The Dimensionality Problem
Embeddings are the backbone of modern search (RAG), recommendation systems, and clustering. An embedding model transforms text like “The cat sat on the mat” into a fixed-size vector (e.g., [0.1, -0.5, 0.3, ...]).
The standard approach assumes a fixed dimensionality. If a model outputs 768 dimensions, you must use all 768. If you truncate the vector to the first 64 numbers to save space, the performance usually collapses because the model wasn’t taught that the first 64 numbers are special; the information is spread randomly throughout the vector.
Matryoshka Representation Learning (MRL) changed this paradigm. It trains models so that the most critical information is stored in the earlier dimensions (the “inner dolls”). This allows valid truncation. However, MRL usually requires training the base model from scratch.
The Matryoshka-Adaptor paper asks a different question: Can we take an existing embedding model (even a black-box API) and “tune” its outputs to have this nesting-doll property post-hoc?
The Core Method: How the Adaptor Works
The Matryoshka-Adaptor does not change the weights of the massive LLM itself. Instead, it trains a lightweight “adaptor”—a customized function—that sits on top of the LLM.
Let \(e\) be the original embedding from a model. The adaptor learns a function \(f\) to create a new embedding \(\hat{e}\):
\[ \hat{e} = e + f(e) \]Notice the additive nature (skip connection). The adaptor only needs to learn the difference or the “correction” needed to organize the information into a Matryoshka structure. The researchers proposed two ways to train this adaptor: Unsupervised (using only corpus documents) and Supervised (using query-document pairs).
1. Unsupervised Tuning: Organizing Information without Labels
In many real-world scenarios, you have a massive database of documents (corpus) but no labeled queries. The Unsupervised Matryoshka-Adaptor works by ensuring that the relationship between documents remains consistent regardless of whether you look at the full embedding or a shrunk version.
The framework uses two specific loss functions to enforce this consistency:
A. Pairwise Similarity Loss This ensures that if Document A and Document B are similar in the full 768-dimensional space, they should also be similar in the 64-dimensional space. It looks at global relationships.

Mathematically, this minimizes the difference between cosine similarities across different dimensions (\(m\)):

B. Top-k Similarity Loss Global similarity isn’t enough; we care most about nearest neighbors. If Document A’s closest neighbor is Document B, that relationship must be preserved in lower dimensions. This loss focuses strictly on local neighborhoods (\(NN_k\)).

To prevent the new embedding from drifting too far from the original semantic meaning, they also include a Reconstruction Loss (\(\mathcal{L}_{rec}\)), which ensures the adapted vector stays close to the original vector:

Combining these, the unsupervised objective function tries to balance preserving neighbors, preserving global structure, and staying true to the original model:

2. Supervised Tuning: Optimizing for Search
If you have labeled data (pairs of queries and relevant documents), you can push performance even further. The Supervised Matryoshka-Adaptor takes the query embedding and the corpus embedding and passes them both through the adaptor.

In this setting, the researchers introduce a Ranking Loss. This loss function forces the model to rank relevant documents higher than irrelevant ones, not just in the full dimension, but at every reduced dimension level.

This ensures that even if you cut the vector down to 64 dimensions, the relevant search result still pops up at the top of the list. The final supervised objective combines this ranking capability with the unsupervised structure preservation:

Experiments and Results
The researchers evaluated this framework extensively across 13 BEIR datasets (a standard benchmark for information retrieval), multilingual datasets (MIRACL), and even multimodal (text-to-image) datasets.
Beating PCA in Unsupervised Settings
A common way to reduce dimensions without labels is Principal Component Analysis (PCA). The researchers compared Matryoshka-Adaptor against PCA on OpenAI’s text embeddings and Google’s multimodal embeddings.

As seen in Figure 4, the Matryoshka-Adaptor (orange triangles) significantly outperforms PCA (green squares), especially in mid-to-high dimensions. In fact, PCA often degrades performance as dimensions increase because it isn’t optimizing for the specific semantic relationships the way the Adaptor does. The Adaptor allows the lower dimensions to achieve performance comparable to the original full-size embeddings.
Supervised Performance Gains
When labeled data is available, the results are even more impressive. The researchers compared their method against a “Search-Adaptor” (a previous state-of-the-art method) and the base Google Gecko embeddings.

In Figure 5, the Supervised Matryoshka-Adaptor (orange line) consistently sits at the top.
- Dimensionality Reduction: On the OpenAI model (Fig 5a), the adaptor allows for a reduction from 3072 dimensions to roughly 512 dimensions with almost no loss in retrieval accuracy (nDCG@10).
- Performance Boost: Even at the same dimensionality, the tuned adaptor often outperforms the original base model because it has been customized to the specific dataset.
Distance Metrics as a Proxy
One of the challenges in unsupervised learning is knowing when your model is “good” without having ground-truth labels to check against. The paper offers an interesting insight: simple distance metrics correlate with downstream performance.

Figure 7 shows that the Matryoshka-Adaptor successfully reduces the “distance” (or discrepancy) between the full vector and the shrunk vector (Graph A). More importantly, Graphs B and C show a strong correlation between these distances and the actual retrieval score (nDCG). This means you can trust the unsupervised loss metrics as a proxy for how well your search system will actually perform.
Conclusion and Implications
The Matryoshka-Adaptor represents a significant step forward for practical AI engineering. It addresses the “last mile” problem of embedding deployment: cost and speed.
Key takeaways include:
- Flexibility: It works on text, images, and multiple languages.
- Model Agnostic: You can apply this to OpenAI, Google, or open-source models (like BERT/RoBERTa) without needing access to their internal weights—you just need their output vectors.
- Efficiency: It enables 6x to 12x dimensionality reduction with negligible performance loss. This translates directly to smaller vector databases and faster query times.
- No Labels Required: While labeled data helps, the unsupervised mode alone provides a massive improvement over standard dimensionality reduction techniques like PCA.
For students and engineers building RAG (Retrieval-Augmented Generation) systems or search engines, this paper offers a clear path to optimization. Instead of paying for storage and compute on 3,000-dimensional vectors, a simple tuning step could allow you to achieve the same intelligence with a fraction of the footprint.
](https://deep-paper.org/en/paper/2407.20243/images/cover.png)