# Matryoshka embeddings

> Canonical: https://skillalmanac.com/glossary/matryoshka-embeddings | Last verified: 2026-11-24 | Index status: not offered to search engines

Matryoshka embeddings are embeddings trained so that the first part of the vector is still useful by itself. You can cut the vector to a shorter length, trading some quality for less storage and faster comparison.

Also called: Matryoshka representation learning, MRL, MRL embeddings, Matryoshka embedding, nested embeddings.

## In plain language

An embedding is a list of numbers that stands for the meaning of a piece of text, so similar texts can be found by comparing lists. Longer lists hold more detail but cost more to store and compare. Matryoshka embeddings are named after nesting dolls: the first few numbers give a rough picture, and later numbers add detail. If you have millions of documents, you can keep only the front part of each list and save space. The trade is that shorter lists lose some accuracy, and this works only with models that were trained for it.

## Technical definition

Matryoshka Representation Learning (Kusupati et al., arXiv 2205.13147) trains a representation that is coarse-to-fine, with one representation usable at different computational constraints, per the paper's abstract; the Sentence Transformers page describes truncating to smaller dimensions. The Sentence Transformers documentation describes applying the same loss to truncated portions of the embeddings, for example at 512, 256, 128, 64 and 32 dimensions for a 768-dimension model, and summing them. The same documentation states that training and inference of such a model is not faster, more memory-efficient or smaller; the benefit is in storing and processing the shortened embeddings.

## How it shows up when you use agents

Matryoshka embeddings matter when an agent or an MCP server searches a large collection by [embedding](/glossary/embedding) similarity, for example documentation or a codebase held in a [vector database](/glossary/vector-database). You see them as an option on an embedding model: a setting for how many dimensions to keep. Choosing a smaller size reduces storage and comparison work, which can matter when the collection is big.

What breaks when it is misunderstood: people truncate vectors from a model that was not trained this way and expect the same quality. The Sentence Transformers documentation describes the method as training the model so that embeddings stay useful after truncation. Another mistake is expecting a faster or smaller model. The same documentation says training and inference are not faster, not more memory-efficient and not smaller, and only the shortened embeddings are cheaper to process and store.
A next action: check the embedding model's own documentation for whether it supports truncation and which sizes it recommends. Then run your own test queries at the full size and at the shorter size, and compare the results you care about, as in [semantic search](/glossary/semantic-search) and [retrieval-augmented generation](/glossary/retrieval-augmented-generation) setups, before re-indexing everything.

## Common confusions

- **Matryoshka embeddings versus compression.** Compression shrinks a stored vector and later restores it. Here the vector is trained so that a prefix is meaningful by itself, and the rest is dropped.
- **Matryoshka versus quantization.** Quantization stores each number with fewer bits. Matryoshka keeps fewer numbers. The two address different parts of the storage cost. See [Quantization](/glossary/quantization).
- **Myth.** Any embedding can be cut to a prefix. Cutting an ordinary embedding can damage it.
- **Matryoshka versus a smaller model.** A Matryoshka model is still the same size to run. The saving is in the vectors you keep.

## Worked examples in this catalogue

### [What Is RAG? Retrieval-Augmented Generation Explained](https://skillalmanac.com/learn/what-is-rag)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The guide describes indexing documents as chunks and querying them, with the advice to log the top retrieved chunks for each failing question.

Why it exercises the concept: In a retrieval pipeline each chunk is stored as a vector. Matryoshka embeddings are one way to make those stored vectors shorter.

### [rag-chunking-planner](https://skillalmanac.com/skills/skill-almanac/rag-chunking-planner)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Your documents chunked by three strategies, with defects and offline recall reported for each, so chunk settings are chosen with numbers.

Why it exercises the concept: If you shorten embeddings you should measure retrieval before and after. This skill shows the habit of measuring recall offline, though it does not truncate vectors.

### [local-model-sizing](https://skillalmanac.com/skills/skill-almanac/local-model-sizing)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Whether an open-weight language model will run on a given GPU, Mac or PC, with a script that computes memory needs.

Why it exercises the concept: It is an adjacent case of reasoning about memory cost from the size of the numbers stored. It is not about embeddings themselves.

## Related terms

- [Embedding](https://skillalmanac.com/glossary/embedding.md)
- [Vector database](https://skillalmanac.com/glossary/vector-database.md)
- [Semantic search](https://skillalmanac.com/glossary/semantic-search.md)
- [Vector search](https://skillalmanac.com/glossary/vector-search.md)
- [Retrieval-augmented generation (RAG)](https://skillalmanac.com/glossary/retrieval-augmented-generation.md)
- [Word embedding](https://skillalmanac.com/glossary/word-embedding.md)

## Sources

- [Matryoshka Representation Learning](https://arxiv.org/abs/2205.13147), arXiv (Kusupati et al.) (accessed 2026-11-24)
- [Matryoshka Embeddings](https://www.sbert.net/examples/sentence_transformer/training/matryoshka/README.html), Sentence Transformers (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-24. [Glossary index](https://skillalmanac.com/glossary.md).
