# Matryoshka Embeddings Matryoshka embeddings are trained so that **every prefix of the vector is itself a usable embedding**. Truncate a 1536-dimension vector to the first 256 dimensions and you keep most of the retrieval quality, because Matryoshka Representation Learning (Kusupati et al., 2022) applies the training loss at multiple prefix lengths, packing the most important information into the earliest dimensions, nesting-doll style. Ordinary embeddings scatter information across all dimensions; truncating them destroys quality. ## Why it matters It turns embedding size into a **runtime knob instead of a training decision**: - **Cheap storage/search**: index short prefixes, cut memory and speed up search near-proportionally - **Adaptive retrieval funnel**: shortlist candidates with 256 dims, rerank the top-k with full vectors (most of the accuracy at a fraction of the cost) - OpenAI's `text-embedding-3` models exposed this as the `dimensions` API parameter, which took MRL from paper to default practice ## Versus quantization Two orthogonal compression axes: quantization ([[TurboQuant]], scalar/product/binary in [[Qdrant]]) keeps all dimensions but shrinks *bits per dimension*; Matryoshka keeps full-precision values but drops *dimensions*. Matryoshka needs the model trained for it and requires no special index or SIMD kernels, which is why the [[Turbovec]] HN thread raised it as the boring alternative to exotic quantizers. They also stack: truncate first, then quantize the remainder. ## References - [Matryoshka Representation Learning (paper)](https://arxiv.org/abs/2205.13147) ## Related - [[Embeddings]] · [[Semantic Search]] · [[Vector Store]] - [[TurboQuant]] · [[Turbovec]] · [[Qdrant]]: the quantization axis - [[Retrieval-Augmented Generation (RAG)]]