Skip to main content

Binary Quantization (BQ)

Added in v1.23

BQ is available for the flat index type from v1.23 onwards and for the hnsw index type from v1.24.

Binary quantization (BQ) is a vector compression technique that can reduce the size of a vector.

To use BQ, enable it as shown below and add data to the collection.

Additional information

Simple BQ configuration

Each collection can be configured to use BQ compression. BQ must be enabled at collection creation time, before data is added to it.

This can be done by setting the vector_index_config of the collection to enable BQ compression.

import weaviate.classes.config as wc

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

BQ with custom settings

The following parameters are available for BQ compression, under vectorIndexConfig:

ParameterTypeDefaultDetails
bq : enabledbooleanfalseEnable BQ. Weaviate uses binary quantization (BQ) compression when true.

The Python client v4 does not use the enabled parameter. To enable BQ with the v4 client, set a quantizer in the collection definition.
bq : rescoreLimitinteger-1The minimum number of candidates to fetch before rescoring.
bq : cachebooleanfalseWhether to use the vector cache.
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.

For example:

import weaviate.classes.config as wc

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

Multiple vectors (named 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.