Skip to content

Tunable parameters

Zach McCormick edited this page Jun 20, 2023 · 1 revision

spDB has a few parameters you can adjust to control the tradeoff between memory usage, recall, and latency.

  • pca_dimension: Principal Component Analysis (PCA) is the first step in the compression process, and this parameter defines how many dimensions to reduce the vector to with PCA. You can usually do a 2-4x reduction without substantially hurting recall.
  • opq_dimension: Optimized Product Quantization (OPQ) is the second compression step. The main purpose of this step is to prepare the vector for the product quantization step that follows, but it's also common to do a 2x dimensionality reduction in this step. One thing to keep in mind is that the value for this parameter has to be divisible by the following parameter, compressed_vector_bytes, and it's recommended that this value is 4x that value.
  • compressed_vector_bytes: The final, and most important, compression step is Product Quantization (PQ). This parameter controls the size of the final compressed vectors, measured in bytes. Since the compressed vectors are the primary thing stored in memory, this parameter has a direct impact on memory usage. 32 and 64 are generally the best values for this parameter, but you could also try 16 if you want an extremely compressed index, or 128 if you don't need aggressive compression. For reference, uncompressed vectors use four bytes per dimension, so uncompressed 768d vectors use 3,072 bytes per vector.

Clone this wiki locally