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 speed come from three choices: how many dimensions each vector has, how each component is stored, and which approximate index sits on top. Each one trades a little recall for less storage and faster search, and they multiply. This page shows what each choice costs and how to pick, once you have a vector field working.

What a vector costs

The full-precision column always exists, because every candidate is rescored from it. An approximate index adds its codes on top.

Item Bytes per vector
f32 column (the default) 4 x dims
f16 or bf16 column 2 x dims
int8 column dims + 8
bit column (hamming metric only) dims / 8
PQ codes, 8 bits m. Automatic m is 48, 96, 120, 192 and 384 at 384, 768, 960, 1536 and 3072 dims for cosine and inner product, and at most 32 for L2
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, 15.4 GB at f16 and 7.8 GB at int8. 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

The encoding option sets how the vector column is stored: f32 (the default), f16 or bf16 (half the size) or int8 (about a quarter, with a per-vector offset and scale). Candidates are rescored against the stored encoding, so a smaller encoding slightly changes the final scores as well as the candidate list. f16 and bf16 are close to lossless for typical embeddings; check int8 against your data.

bit keeps one bit per dimension, set when the component is greater than 0, so a 1024-dimension vector takes 128 bytes. It is for binary embeddings and is searched only with metric: hamming, which scores 1 - differing bits / dims and is the default encoding for that metric. dims must be a multiple of 8, and hamming fields are searched exactly, without an approximate index.

Unlike the dimension, encoding can change on an existing field. The change applies to segments written afterwards. To be able to re-encode later from the original values, set keep_original: true, which keeps the submitted f32 vectors in a separate cold column that searches never read. That column costs 4 x dims bytes per vector of storage.

Index codecs

Approximate indexes store a compact code per vector. The codec decides the code size and how recall responds to search effort. PQ, the default, scans faster. 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

The levers stack in this order. Truncation shrinks everything, including the index codes, because the index is built from the shorter vector. Encoding shrinks the column. The codec sets the index size and recall. Combining a 512-dimension prefix with binary quantization has been reported to keep about 90% of retrieval accuracy, and 95 to 96% when candidates are rescored at full precision, which WarpSearch always does.

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.