Skip to main content

Binary Quantization (compression)

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="YourCollection",
vectorizer_config=wc.Configure.Vectorizer.text2vec_openai(),
vector_index_config=wc.Configure.VectorIndex.flat(
quantizer=wc.Configure.VectorIndex.Quantizer.bq()
),
)

client.close()

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="YourCollection",
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
)
),
)

client.close()

Multiple vectors

Added in v1.24.0

Weaviate collections support multiple, named vectors.

Collections can have multiple, named vectors. Each vector is independent. Each vector space has its own index, its own compression, and its own vectorizer. This means you can create vectors for properties, use different vectorization models, and apply different metrics to the same object.

You do not have to use multiple vectors in your collections, but if you do, you need to adjust your queries to specify a target vector for vector or hybrid queries.

Similarly, compression must be enabled independently for each vector. The procedure varies slightly by client language, but in each case the idea is the same. Each vector is independent and can use PQ, BQ, or no compression.

Questions and feedback

If you have any questions or feedback, please let us know on our forum. For example, you can: