What Are Matryoshka Embeddings?

    Matryoshka embeddings train a single model to produce valid vector representations at multiple dimension sizes, like nested Russian dolls, so you can use a 64-dimension vector for fast initial retrieval and a 1536-dimension vector for precise reranking without running two separate models. This makes them a key efficiency pattern in modern AI retrieval pipelines.

    Tharindu Gunawardana
    Tharindu Gunawardana
    April 10, 2026
    8 min read
    AI SEO
    What Are Matryoshka Embeddings?

    What Are Matryoshka Embeddings?

    Matryoshka embeddings are vector representations trained so that any prefix of the full embedding vector is itself a valid, high-quality embedding. Named after the Russian nesting doll, the idea is that meaning is concentrated in the first dimensions, with each outer layer adding refinement rather than storing independent information.

    In a standard 1024-dimensional embedding, dimensions are not ordered by importance. Truncating to 256 dimensions produces a degraded, near-meaningless vector. With Matryoshka Representation Learning (MRL), a model trained to produce 1024-dimensional embeddings is also simultaneously trained to produce good 512d, 256d, 128d, and 64d embeddings from the same vector prefix. The first 64 numbers carry the most concentrated semantic signal; each additional dimension adds incremental precision.

    Matryoshka Nested Dimension Structure64d128d256d1024d (full)Each inner slice is a valid embedding. Outer dimensions add precision; inner dimensions provide speed.

    The practical result is that a single MRL-trained model can serve retrieval pipelines that need different speed-accuracy trade-offs without retraining or deploying separate models. This is the architecture behind OpenAI's text-embedding-3-small and text-embedding-3-large, both of which support arbitrary dimension truncation.

    How Matryoshka Embeddings Affect AI Search Retrieval

    AI search systems such as Google AI Overviews, Perplexity, and ChatGPT Search use retrieval pipelines that depend on vector search. Understanding Matryoshka embeddings matters for SEO practitioners for three reasons.

    Example: First-Pass vs Full-Dimension Retrieval

    Query: "best practices for semantic chunking in RAG pipelines"

    PASS 1 (128d)

    Recall top-1000 candidates cheaply. A focused chunk titled "Semantic Chunking: Splitting at Topic Boundaries" scores 0.78 at 128d. A mixed-topic chunk covering chunking and HNSW together scores 0.51, below threshold, and is filtered out.

    PASS 2 (1536d)

    Re-rank the 1000 shortlisted candidates at full precision. The focused chunk now scores 0.93. It is selected for the answer context window.

    Single-topic chunks with clear, precise titles survive the low-dimension filter and score highly at full precision. Mixed-topic chunks are eliminated at the cheap first pass and never reach the reranker.

    • Content retrieval cost shapes what gets retrieved: Systems under latency or cost constraints will use smaller-dimension vectors for first-pass retrieval. Content that scores poorly at low dimensions (lacking clear semantic focus) will be filtered out before the precise re-ranking stage even runs.
    • Semantic density matters more than keyword density: MRL models concentrate meaning into early dimensions from the text's most salient concepts. Content that covers a single topic clearly outperforms content that mentions many topics superficially, because the embedding captures the dominant semantic signal.
    • Chunking strategy affects embedding quality: The quality of a chunk's embedding at any dimension size depends on semantic coherence. Chunks that mix multiple topics produce weaker, diffuse embeddings. Use semantic chunking to split content at topic boundaries before indexing.
    • AI SEO strategy should account for retrieval architecture: Our AI SEO services analyse how content performs at the retrieval layer, not just the ranking layer.

    How MRL Training Works

    Standard embedding training computes a loss (typically contrastive loss or cosine similarity loss) on the full embedding vector. The model learns to place similar texts close together in 1024-dimensional space, but has no incentive to arrange the first 64 dimensions meaningfully.

    Matryoshka Representation Learning modifies the training objective by computing the loss at multiple nested scales simultaneously. If the chosen dimension sizes are 64, 128, 256, 512, and 1024, the model receives five gradient signals per training step: one for each nested prefix. The total loss is a weighted sum across all scales, with larger dimensions typically weighted higher.

    MRL Training vs Standard Embedding TrainingStandard TrainingLoss computed on full 1024d vector onlyTruncation produces degraded embeddingsNeed separate models per dimensionHigh infra cost to serve multiple sizesMRL TrainingLoss computed at 64d, 128d, 256d, 512d, 1024dFirst dimensions carry the most informationSingle model serves all dimension needsSignificant storage and latency savingsMRL jointly optimises the model to be useful at every nested prefix of the embedding vector.

    This joint objective forces the model to front-load semantic information into the earliest dimensions. The first 64 numbers become a compressed but coherent representation of the text. Dimensions 65 to 128 add the next layer of nuance, and so on. Because the outer dimensions only need to store the delta between scales, the model can represent a richer concept space without redundancy.

    The training procedure was published by researchers at Google in the paper "Matryoshka Representation Learning" (2022) and has since been widely adopted across commercial and open-source embedding models.

    Choosing Dimension Sizes

    The right dimension size depends on the retrieval task and the cost constraints. The trade-off follows a diminishing returns curve: moving from 64 to 256 dimensions captures the largest accuracy jump; moving from 512 to 1024 adds only marginal gains for most tasks.

    • 64 dimensions: Suitable for bulk candidate filtering over tens of millions of vectors. Memory footprint is 16x smaller than 1024d. Accuracy drops significantly for nuanced semantic tasks but is acceptable for coarse pre-filtering.
    • 128 to 256 dimensions: The sweet spot for most production retrieval systems. Retrieval accuracy typically exceeds 95% of the full-dimension baseline on standard benchmarks such as MTEB, at a fraction of the cost.
    • 512 to 1024 dimensions: Required for tasks where precision is critical: legal document retrieval, medical knowledge bases, or fine-grained semantic re-ranking. Full dimensions are also preferred when the corpus is small and storage cost is not a concern.

    Vector databases such as Pinecone, Weaviate, and Qdrant support specifying dimension size at index creation. If you use MRL models, you can build two indexes: a low-dimension index for first-pass retrieval and a full-dimension index for re-ranking the top candidates returned by the first pass.

    Adaptive Retrieval in Practice

    The primary production pattern for Matryoshka embeddings is a two-stage retrieval pipeline. In the first stage, the system retrieves a candidate set using small-dimension vectors. The search is fast and cheap. In the second stage, the full-dimension embeddings of only those candidates are compared against the full-dimension query vector, producing a precise re-ranked list.

    Adaptive Retrieval with Matryoshka EmbeddingsSingle MRLModel64d: Bulk filteringFastest, low memory256d: Re-rankingBalanced speed/accuracy1024d: PrecisionMaximum accuracyCost vs Quality Trade-off64d: 16x cheaper storage than 1024d256d: 4x cheaper, 95%+ of accuracyOne model. Any dimension. No retraining.Matryoshka Representation Learning trains a single model to produce valid embeddings at every nested dimension.

    This pattern reduces search latency by up to 10x compared to running full-dimension vector similarity search over the entire corpus, while preserving near-identical final ranking quality. It is especially effective when combined with HNSW graph indexes, which support approximate nearest neighbour search at the small-dimension stage.

    Another common pattern is dimension cascading: filtering 10 million vectors with 64d, re-ranking the top 10,000 with 256d, and final-ranking the top 100 with 1024d. Each stage eliminates irrelevant candidates cheaply before applying more expensive computation.

    Embedding Models That Use Matryoshka Representation Learning

    Several major embedding models now incorporate Matryoshka training, making the technique accessible without any custom training:

    • OpenAI text-embedding-3-small (1536d) and text-embedding-3-large (3072d): Both support the dimensions parameter in the API, which truncates the output using the MRL structure. This is the most widely deployed production implementation.
    • Nomic Embed Text: An open-source MRL model available via Hugging Face that produces high-quality embeddings at 64, 128, 256, and 768 dimensions.
    • Cohere Embed v3: Cohere's production embedding model incorporates MRL, allowing dimension selection at inference time.
    • GTE-Qwen2 and similar open-source models: Several MTEB leaderboard models trained on Qwen2 base architecture include MRL objectives, offering strong multilingual performance across dimension sizes.

    When evaluating MRL models, benchmark at the specific dimension size you intend to use in production. A model that ranks first at 1024d may underperform at 128d compared to a model specifically optimised for low-dimension retrieval.

    Frequently Asked Questions

    Are Matryoshka embeddings the same as quantised embeddings?

    No. Quantisation reduces the precision of each dimension value (e.g., from float32 to int8), which reduces storage without changing the number of dimensions. Matryoshka embeddings reduce the number of dimensions while keeping full precision. The two techniques are complementary and can be combined.

    Can I use Matryoshka embeddings with any vector database?

    Yes. You truncate the embedding before inserting it into the database. Any vector database that stores fixed-dimension vectors works, regardless of whether it has native MRL support. You simply store the first N dimensions of the full embedding.

    How much accuracy is lost by using 256d instead of 1024d?

    On MTEB benchmarks, MRL models at 256 dimensions typically retain 95-97% of the retrieval accuracy measured at full dimensions. The exact figure depends on the model and the task. Tasks requiring fine-grained semantic discrimination (e.g., legal similarity) lose more accuracy than tasks based on broad topic matching.

    Does Google use Matryoshka embeddings in its search systems?

    Google has not publicly confirmed specific embedding architectures used in production search. However, Google researchers authored the original MRL paper, and the technique is widely used in production AI retrieval systems. The efficiency gains it provides are highly relevant at Google-scale corpora.

    Should I retrain my embedding model to use MRL?

    For most practitioners, using a pre-trained MRL model (such as OpenAI text-embedding-3 or Nomic Embed) is sufficient. Custom training is only warranted for domain-specific tasks where general-purpose models underperform, such as biomedical or legal retrieval.

    Optimise Your Content for AI Retrieval

    The retrieval architecture behind AI Overviews and generative search engines uses embedding models, including MRL-based systems. We help brands produce content that ranks in the retrieval layer, not just the traditional SERP.

    Tharindu Gunawardana

    Tharindu Gunawardana

    Founder and Director of SearchMinistry

    Tharindu Gunawardana is the Founder of SearchMinistry Media and a search strategist with 17 years of experience across Sri Lanka, Singapore, and Australia. A former Agency SEO Director, he specialises in helping brands transition from traditional SEO to AI-driven discovery.

    Leave a Reply