Robots Atlas>ROBOTS ATLAS
Training

MRL

2022ActivePublished: 16 October 2026Updated: 16 October 2026Published
Key innovation
Instead of a single rigid vector, MRL packs information into nested prefixes of one embedding, so a single model yields many vectors of different lengths and every leading sub-vector is a standalone, usable representation.
Category
Training
Abstraction level
Pattern
Operation level
TrainingDataRetrieval
Use cases
Semantic and vector search with adaptive dimensionalityReducing vector-database memory costFaster similarity search (adaptive / shortlist-then-rerank)Image classification with an adaptive compute budgetRAG with cheap pre-filtering on short embeddingsFew-shot and long-tail classification

How it works

During training, MRL applies the loss not only to the full M-dimensional embedding but simultaneously to multiple nested prefixes of the vector — e.g. the first m dimensions for each m in a chosen set of granularities (often powers of two such as 8, 16, 32, ... up to the full dimension). Each granularity has its own loss term (with a separate or shared classification head / contrastive loss), and the total loss is a weighted sum over all granularities. This objective forces the most important information into the earliest coordinates of the embedding, so any leading prefix becomes a usable representation. The MRL-E variant shares the head across granularities to cut parameters. At inference you simply take the first k dimensions; if the embeddings were normalized, after truncating you must re-normalize them (L2), because the truncated vector is no longer unit length.

Problem solved

Fixed, rigid-capacity representations are either over- or under-accommodating for a given task, because the computational and statistical constraints of downstream tasks are unknown at training time. Training a separate model for each target dimensionality is expensive, and naively truncating an ordinary embedding sharply degrades quality. MRL addresses the need for a single flexible representation that can adapt to different memory and latency budgets.

Components

Nested embedding prefixesCarrier of multi-granularity representations within one vector

Leading sub-vectors of the embedding (the first m dimensions) forming representations of increasing capacity — coarse-to-fine.

Per-granularity lossesForce each granularity to be useful

Separate loss terms computed for each selected dimension prefix (e.g. classification or contrastive loss over the first m dimensions).

Official

Aggregated Matryoshka lossOptimization objective packing information into leading dimensions

A weighted sum of losses over all granularities, optimized jointly. In implementations (e.g. Sentence Transformers) realized via MatryoshkaLoss wrapping a base loss.

Truncation and re-normalization (inference)Adapting dimensionality to the task budget

At inference the first k dimensions are taken; if the vector was normalized, an L2 re-normalization must be applied after truncation.

Implementation

Implementation pitfalls
Missing L2 re-normalization after truncationHigh

If embeddings were normalized, a truncated vector is no longer unit length, which distorts similarity measures (e.g. cosine/dot).

Fix:After truncating to k dimensions, re-apply L2 normalization.
Truncating a non-MRL-trained modelHigh

Truncating an ordinary embedding (not trained with the Matryoshka objective) causes a large quality drop, because information is not packed into leading dimensions.

Fix:Use MRL-trained models and truncate to dimensions covered during training.
Mixing different dimensionalities in one indexMedium

Comparing vectors of different dimensionalities in the same index breaks similarity measures.

Fix:Keep a consistent dimensionality within a single index / collection.

Evolution

Original paper · 2022 · NeurIPS 2022 · Aditya Kusupati
Matryoshka Representation Learning
Aditya Kusupati, Gantavya Bhatt, Aniket Rege, Matthew Wallingford, Aditya Sinha, Vivek Ramanujan, William Howard-Snyder, Kaifeng Chen, Sham Kakade, Prateek Jain, Ali Farhadi
2022
MRL published (NeurIPS 2022)
Inflection point

Introduction of Matryoshka Representation Learning for vision, language and vision+language; open-source code and models (RAIVNLab/MRL).

2024
Adoption in production embedding APIs

OpenAI text-embedding-3 exposes a dimensions parameter for shortening vectors; MatryoshkaLoss support lands in Sentence Transformers.

2025
Native MRL in EmbeddingGemma

Google EmbeddingGemma ships native 128/256/512/768 dimensions with dynamic truncation and up to ~6x reduction in vector storage cost.

Hyperparameters (configurable axes)

Dimension granularitiesCritical

List of nested dimensions covered by the loss, e.g. [768, 512, 256, 128, 64] or powers of two 8…2048.

[768, 512, 256, 128, 64]Typical set for text models (Sentence Transformers)
128 / 256 / 512 / 768EmbeddingGemma native dimensions
Per-granularity loss weightsMedium

Relative weights c_m assigned to each granularity loss in the aggregate sum.

Base lossHigh

The underlying task loss wrapped by MRL (e.g. cross-entropy for classification, contrastive / CoSENT loss for text embeddings).

Shared head (MRL vs MRL-E)Medium

Whether the head (e.g. classifier) is separate per granularity (MRL) or shared across them (MRL-E, fewer parameters).

Computational complexity

Execution paradigm

Primary mode
Dense

MRL introduces no routing or conditional activation — the full embedding is computed densely, and flexibility comes from the nested dimension structure and truncation.

Activation pattern
All paths active
Routing mechanism

Parallelism

Parallelism level
Fully parallel

Losses for all granularities are computed on the shared embedding and can be parallelized; inference and truncation are trivially parallel.

Scope
TrainingInference

Hardware requirements

Primary

MRL is a training objective plus vector truncation — it works independently of hardware, on the same architectures as the base model (ViT, ResNet, BERT, text encoders).