For AI agents: this page is also available as Markdown at /docs/matryoshka-and-dimensions.md. Every docs page is: add .md to its URL. llms.txt lists them all.

Dimensions and storage trade-offs

A vector field's size and search speed depend on its dimensions and approximate index codec. Truncation reduces storage, while the index codec controls the size and recall of approximate search. This page explains those choices once you have a vector field working.

What a vector costs

Vectors are stored as float32. An approximate index adds its codes on top; candidates are rescored against the stored vectors.

Item Bytes per vector
f32 column (the default) 4 x dims
PQ codes, 8 bits m. Automatic m is 48, 96, 120, 192 and 384 at 384, 768, 960, 1536 and 3072 dims for all metrics
RaBitQ codes, 1 bit About 104 at 768 dims, roughly 1/30 of the f32 vector

Add a few bytes per vector for ids and index headers.

For 10 million 768-dimension vectors, that is about 30.7 GB for the f32 column. A PQ index adds about 1 GB, a 1-bit RaBitQ index about the same. Truncating the same vectors to 256 dimensions cuts the f32 column to about 10.2 GB.

Search time follows the same proportions. In a test on 100,000 synthetic 1024-dimension vectors, an exact top-10 scan took about 13 to 16 ms at 1024 dimensions, 3.6 ms at 256 and 2 ms at 128. The machine was shared and the timings are noisy, but the ratios hold. Approximate search scans compact codes instead of the whole column, so it grows much more slowly with collection size; see Exact and approximate search.

Storage is what you pay for, at a per-GB rate (see Pricing and cost control), so the levers below lower the bill as well as latency.

Fewer dimensions: Matryoshka embeddings

Some embedding models are trained so that the first N components of a vector are themselves a good embedding. This is Matryoshka Representation Learning (MRL). With such a model you can keep a short prefix of each vector and give up a little quality for a large saving.

Truncate only vectors from MRL-trained models. Other models do not pack the important information into the first components, and quality drops sharply when you cut them.

Models that support it

Model How to get a shorter vector Notes
OpenAI text-embedding-3-small and -large The dimensions request parameter, or cut the output yourself OpenAI reports a 256-dimension text-embedding-3-large embedding still beats the full 1536-dimension text-embedding-ada-002 on MTEB. If you cut manually, renormalize.
Google gemini-embedding-001 output_dimensionality Recommended sizes are 768, 1536 and 3072. Outputs other than 3072 need manual normalization.
nomic-embed-text-v1.5 Cut the output The model card reports MTEB 62.28 at 768 dimensions, 61.04 at 256 and 59.34 at 128. Its reference code applies a layer norm before cutting, which WarpSearch does not do.
jina-embeddings-v3 Provider dimensions option, or cut the output Supports sizes from 1024 down to 32.
mxbai-embed-large-v1 Cut the output Supports MRL truncation.

Check your provider's current documentation for exact parameter names and supported sizes.

Published figures give an idea of the quality cost. Hugging Face reports a Matryoshka model keeping about 98% of its performance at roughly 8% of the embedding size on the STS benchmark, and Vespa quotes about 2% loss going from 1024 to 128 dimensions. Measure on your own data before you rely on numbers like these.

Truncate in WarpSearch

Set truncate_dims on a vector field in the WarpSearch schema, when you create the collection, when you add the field with PUT /v1/collections/{collection}/schema, or through MCP create_collection. Elasticsearch and OpenSearch mappings have no way to express it, so with those APIs define the field at the shorter size and truncate on the client:

{
  "fields": {
    "summary_v": {
      "type": "vector",
      "dims": 1024,
      "truncate_dims": 256,
      "metric": "cosine"
    }
  }
}

There is no equivalent option. Define the field at the shorter dimension and truncate on the client:

{
  "properties": {
    "summary_v": {"type": "dense_vector", "dims": 256, "similarity": "cosine"}
  }
}

There is no equivalent option. Define the field at the shorter dimension and truncate on the client:

{
  "properties": {
    "summary_v": {"type": "knn_vector", "dimension": 256,
                  "method": {"name": "hnsw", "space_type": "cosinesimil"}}
  }
}
Property Meaning
dims The full dimension of the vectors your model produces. Required when you use truncate_dims.
truncate_dims The dimension that is stored and searched. Must be positive and smaller than dims. 0 clears a value inherited from a parent definition.
metric Must be cosine. Other metrics are rejected; see below.

Everything after the write works on the shorter vector: the stored column, approximate indexes, exact scans and rescoring. Queries need nothing special; send a kNN query with a query vector of either length below. Once vectors are stored, dims, truncate_dims and the metric cannot change (409 incompatible_schema).

Documents and queries can carry either length:

The two can be mixed, even within one multi-valued field, so vectors read back from the field can be written again as they are when you reindex. Any other length is rejected with a message naming both sizes:

expected dims=1024 or truncate_dims=256, got 768

The declared full size is what keeps another model's output out of the field, because after truncation vectors from two models can have the same length. It cannot catch a model whose own output size equals your truncate_dims: with dims: 3072, truncate_dims: 1536, a 1536-dimension model's vectors are accepted as if they were already truncated. Keep one model per field. The check for finite numbers covers the whole input, including the part that is cut off.

truncate_dims requires metric: cosine. The prefix of a unit vector is no longer unit length, so WarpSearch renormalizes it on write and normalizes the query at search time. Under l2 or ip each document's shorter prefix length would leak into its score, and MRL models are meant to be compared after renormalization anyway. Related rules:

Truncate on the client

This works with every API. Take the first N components and divide by their Euclidean norm so the vector has unit length. Do the same for every query, and define the field with dims: N.

import math

def truncate(vec, n):
    head = vec[:n]
    norm = math.sqrt(sum(x * x for x in head)) or 1.0
    return [x / norm for x in head]

Every writer and every query must use the same N. A client that truncates documents but not queries gets a dimension error; two clients using different N get wrong scores with no error.

Smaller encodings

Vector storage encoding is not configurable through the schema API. Use fewer dimensions when your embedding model supports truncation, and choose an approximate index codec below. Keep full source vectors outside the index if you may need to reindex at a larger dimension.

Index codecs

Approximate indexes store a compact code per vector. The codec decides the code size and how recall responds to search effort. RaBitQ is the default; PQ requires an explicit codec setting. RaBitQ at 1 bit uses about as many bytes as PQ at 768 dimensions, and its recall is mostly limited by how many lists you probe, so raise ivf.nprobe before raising bits. Both rescore candidates from the stored column, so scores are not approximated, only the candidate list. The settings are in Codecs and measured recall in Tune recall and latency.

Choosing

Choose the dimension first: it affects both the stored vectors and the approximate index. Then compare codecs and search settings at that dimension. Measure recall against an exact search over your full-length vectors before accepting the storage savings.

To choose a dimension:

  1. Embed a sample of your documents and some real queries with the full model.
  2. Pick candidate sizes, for example 1024, 512, 256 and 128.
  3. Compare recall and relevance against the full-length results, with "exact": true.
  4. Choose the smallest size whose quality you accept.

To compare sizes from one indexing pass, declare truncated variants beside the full vector before you index. Each variant indexes the same input, and a query selects one by name, such as summary_v__d256. A variant added later covers only documents indexed after it.

"summary_v": {
  "type": "vector", "dims": 1024, "metric": "cosine",
  "variants": {
    "d256": { "type": "vector", "dims": 1024, "truncate_dims": 256, "metric": "cosine" }
  }
}

Changing the stored dimension later means reindexing from your source vectors, the same as changing dims. WarpSearch cannot recover components it cut off, so keep the full vectors, or the text to re-embed, outside the index. Query vectors are limited to 8,192 dimensions on every API.

View this page as Markdown

Cookie settings

Optional tracking stays off until you choose it. Your choice applies to this browser for 180 days. Read the details.

Essential storage keeps you signed in, protects forms, and remembers this choice. It is always available.