Matryoshka embeddings
Matryoshka embeddings are vectors trained so that their first values carry the most information. You can cut them to a shorter length and still get useful search results, which saves storage and speeds up search.
Also called: Matryoshka representation learning, MRL
By Divya Sharma · Checked Nov 15, 2026 · How we review
The name comes from Russian nesting dolls: a smaller usable embedding sits inside the larger one. The method, Matryoshka Representation Learning, was published in 2022 and is now used in several commercial and open embedding models.
How it works
During training, the model's loss is computed not only on the full vector but also on several shorter leading slices of it. This forces the model to pack coarse meaning into the early values and finer detail into later ones. At inference nothing changes; you simply keep as many values as you want.
Why it matters
The embedding dimension drives storage and search cost in a vector database. With a Matryoshka model you can store short vectors to save money, or run a fast first search on short vectors and rescore the top results with full-length ones. OpenAI exposes this through a `dimensions` parameter on its text-embedding-3 models, which drops values from the end.
Limits
Shorter vectors do lose some quality, and how much depends on the model and your data. Truncation only works on models trained this way; cutting a normal embedding degrades it badly. After truncating, re-normalize vectors if you use cosine similarity via dot product. Check results with retrieval metrics at each length before choosing.
Related terms
- Embedding dimension
- Embedding dimension is the number of values in each vector an embedding model outputs. More dimensions can hold more detail, but every extra value adds storage, memory and search cost per item.
- Embedding
- An embedding is a list of numbers (a vector) that represents a piece of text, an image or other data, produced so that items with similar meaning end up with vectors close together.
- Vector database
- A vector database stores embeddings alongside their source records and finds the stored vectors closest to a query vector, usually with an approximate index so search stays fast across millions of items.
- Cosine similarity
- Cosine similarity measures how alike two vectors are by the angle between them. It ranges from -1 to 1, ignores vector length, and is the most common way to compare embeddings in search.
- Retrieval metrics (recall@k, nDCG, MRR)
- Retrieval metrics score how well a search system returns relevant documents. Recall@k checks how many relevant items appear in the top k, nDCG rewards ranking them high, and MRR measures how early the first correct one appears.