Skip to main content

Scalar Quantization (SQ)

Added in v1.26.0

Scalar quantization (SQ) is a vector compression technique that can reduce the size of a vector.

To use SQ, enable it in the collection definition, then add data to the collection.

Basic configuration

SQ must be enabled at collection creation time. You cannot enable SQ after you add data to a collection.

To enable SQ, set vector_index_config.

import weaviate.classes.config as wc

client.collections.create(
name="MyCollection",
vectorizer_config=wc.Configure.Vectorizer.text2vec_openai(),
vector_index_config=wc.Configure.VectorIndex.hnsw(
quantizer=wc.Configure.VectorIndex.Quantizer.sq()
),
)

Custom configuration

To tune SQ, set these vectorIndexConfig parameters.

ParameterTypeDefaultDetails
sq: enabledbooleanfalseUses SQ when true.

The Python client v4 does not use the enabled parameter. To enable SQ with the v4 client, set a quantizer in the collection definition.
sq: rescoreLimitinteger-1The minimum number of candidates to fetch before rescoring.
sq: trainingLimitinteger100000The size of the training set to determine scalar bucket boundaries.
sq: cachebooleanfalseUse the vector cache when true.
vectorCacheMaxObjectsinteger1e12Maximum number of objects in the memory cache. By default, this limit is set to one trillion (1e12) objects when a new collection is created. For sizing recommendations, see Vector cache considerations.
import weaviate.classes.config as wc

client.collections.create(
name="MyCollection",
vectorizer_config=wc.Configure.Vectorizer.text2vec_openai(),
vector_index_config=wc.Configure.VectorIndex.hnsw(
distance_metric=wc.VectorDistances.COSINE,
vector_cache_max_objects=100000,
quantizer=wc.Configure.VectorIndex.Quantizer.sq(
rescore_limit=200,
training_limit=50000,
cache=True,
)
),
)

Multiple vectors

Added in v1.24.0

Collections support multiple named vectors.

Collections can have multiple named vectors. The vectors in a collection can have their own configurations, and compression must be enabled independently for each vector. Every vector is independent and can use PQ, BQ, SQ, or no compression.

Questions and feedback

If you have any questions or feedback, let us know in the user forum.