← all concepts

Matryoshka Representation Learning

A training technique that nests coarse-to-fine information inside one embedding, so it can be truncated to fewer dimensions with little loss.

Listen

In the world of machine learning, vector embeddings are essential, but they can be incredibly expensive to store and process. That is where Matryoshka Representation Learning comes in. Named after the nested Russian dolls, this training technique packs information into a single embedding from coarsest to finest, front-loading the most important details into the very first dimensions.

Because of this unique structure, you can truncate a vector on demand. For example, with EmbeddingGemma, you can cut a seven-hundred-and-sixty-eight-dimension output down to two-hundred-and-fifty-six or even one-hundred-and-twenty-eight dimensions with only a minor loss in quality.

This gives you a powerful way to trade a tiny bit of accuracy for massive gains in speed and storage. In tests, truncating a one-thousand-and-twenty-four-dimension model down to just two-hundred-and-fifty-six dimensions cut processing time roughly in half. Amazingly, it still maintained over ninety-nine percent accuracy, and on the most difficult sentence pairs, the shorter vectors actually performed slightly better. For anyone running vector search at scale, this technique is a rare opportunity to make your system much cheaper and faster with almost no downside.

Matryoshka Representation Learning (MRL) is a training technique that packs coarse-to-fine information into a single embedding, front-loading the most important signal into the earliest dimensions. Like the nested Russian dolls it's named after, one big vector contains smaller usable vectors inside it.

The practical payoff is that you can truncate the vector on demand. EmbeddingGemma's 768-dimensional output can be cut to 512, 256 or 128 dimensions with only minor quality loss, trading accuracy for speed and storage as your workload needs.

We measured this directly: truncating a 1,024-dim model to 256 dims roughly halved processing time while holding top-1 accuracy at 99.5% — and on the hardest sentence pairs, the truncated version actually edged ahead. For anyone running vector search at scale, MRL is a rare "cheaper and barely worse" lever.

Related concepts

Method