What is Matryoshka representation learning?
Matryoshka representation learning trains an embedding model so that taking only the first part of its vector, such as the first 256 values of a 1,024-dimension vector, still gives a usable representation; it is named after nesting Russian dolls.
It makes embedding dimension flexible: an ordinary model's size is fixed and truncating hurts quality, while here one vector can be cut to the length needed, so separate small models are unnecessary.
- Topic
- Embeddings, document processing and RAG
- Also known as
- MRL, Matryoshka embeddings
- Origin
- Kusupati et al., 2022
How Matryoshka representation learning works
- During training the loss is computed jointly over the full vector and over its first parts truncated at set lengths.
- The most important information thus settles at the start of the vector and detail towards the end.
- In use, the first d values are taken and measures such as cosine similarity are computed on the shorter vector.
- A fast first search can use short vectors, with results reranked using full vectors.
In more detail
Re-normalising after truncation
When a full unit-length embedding is truncated to its first d dimensions, the slice is no longer unit-normalised. Applications should re-normalise the sliced vector to unit length before storing it in vector indexes that rely on dot-product or L2 metrics; otherwise vectors with larger early-dimension norms receive inflated similarity scores.
The nested loss and power-of-two dimension ladder
During training, MRL sums the task loss across a predefined schedule of nesting dimensions, typically powers of two such as [8, 16, 32, 64,..., 1024], using shared model weights. Choosing a truncation size at inference that matches or sits near one of these trained nesting checkpoints usually yields the smoothest accuracy-versus-storage trade-off.
Ecosystem support and combination with vector quantisation
Matryoshka training has become standard in major open-weight and commercial embedding models, including Nomic Embed, Jina Embeddings, Qwen3-Embedding, OpenAI text-embedding-3 and Gemini embedding models, often paired with scalar (Int8) or binary quantisation. Combining 256-dimension MRL truncation with binary quantisation can shrink vector index RAM substantially with little recall loss after full-vector reranking.
Commonly confused terms
| Term | How it differs |
|---|---|
| Dimensionality reduction (PCA and UMAP) | Dimensionality reduction techniques like PCA or UMAP project already-computed embeddings into a lower-dimensional space post hoc, often losing task alignment or requiring stored projection matrices, whereas MRL learns nested prefixes directly during neural training. |
| Vector quantisation | Vector quantisation (such as Scalar/Int8 or Binary quantisation) reduces the number of bits per coordinate while keeping the same number of dimensions, whereas Matryoshka representation learning reduces the number of coordinates (dimensions) kept; the two are frequently combined. |
Why Matryoshka representation learning matters for on-premises AI
In in-house RAG systems vector index memory and search speed depend on embedding dimension. Such a model allows shorter vectors without training another model or re-embedding, so larger collections fit on the same hardware. The paper introducing it reports up to 14 times smaller embeddings at the same accuracy in image classification experiments. Quality at each truncation length should be measured on the organisation's own data.
A bank searches its document archive first with short vectors from such a model, then reranks the best hundred candidates with full vectors, sharply cutting index memory.
Common questions
Can any embedding model's vector be truncated?
No. Only in models trained this way is the first part meaningful alone. In others truncation clearly lowers quality.
Do short vectors lower quality?
Somewhat. The loss is often small, but truncation length is chosen by measuring on your own data.
Related terms
Sources
In the glossary: Glossary, M to Q