Matryoshka embedding models are trained so that their embeddings can reasonably be shrunk without suffering too much on performance: the most important information is frontloaded into the earlier dimensions, so truncating the vector keeps most of the signal. A Matryoshka model trained at 768 dimensions can be truncated to 512, 256, 128 or 64 dimensions, and in one published comparison the model preserved 98.37 percent of performance at 8.3 percent of the embedding size. Only models trained this way truncate cleanly; truncating an ordinary model loses far more.
What you need
- A Matryoshka-trained embedding model, for example nomic-embed-text-v1.5
- The target dimension your store and budget need
- A test set of queries to measure the quality loss
Step 1: Confirm the model is Matryoshka-trained
Check the model card or docs say the model supports truncation. An ordinary embedding model was not trained to frontload information, so truncating it is a guess, not a supported operation.
Step 2: Truncate and re-normalise
Take the first N dimensions of each vector, then re-normalise, since truncated embeddings are no longer normalised even if the originals were. Store the truncated vectors and record the dimension with the collection.
Step 3: Measure the quality loss on your test set
Run the same retrieval test at the full dimension and at the truncated dimension and compare the hit rate. If the loss is acceptable, keep the smaller size; if not, try a larger truncation or keep the full size.
Worked example: synthetic truncation check at 3 sizes
The table below is a synthetic example. It shows the expected result of truncating embeddings; no model was called.
| Dimension | Storage vs full | Hit rate |
|---|---|---|
| 768 full | 100 percent | 0.70 |
| 256 truncated | 33 percent | 0.69 |
| 64 truncated | 8 percent | 0.66 |
| Decision | 256 chosen | Near-full quality, third the storage |
Expected result (UNTESTED). truncating to 256 keeps nearly the full hit rate at a third of the storage, and 64 loses more quality. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Truncation only works well on Matryoshka-trained models; check the model card before you rely on it.
- Getting a smaller embedding from the model costs the same as getting the full one; the saving is in storage and search, not in the API call.
- Shortlisting at a small size and re-ranking the shortlist at full size is a common pattern for large collections.
- The dimensions parameter on OpenAI third-generation models reduces size a different way, and it is not the same as Matryoshka truncation.
