Database / Weaviate Vector database Interview questions
What is the difference between PQ and RQ quantization internally?
PQ (Product Quantization) works by splitting each vector into smaller sub-vector segments, then training a separate small codebook (via clustering) for each segment on a sample of the actual data, so each segment gets replaced at query time by a compact code pointing to its nearest trained codebook entry. This training step is what lets PQ adapt closely to a specific dataset's actual distribution, but it also means PQ's quality depends on having a representative, sufficiently large training sample.
RQ (Rotational Quantization) instead applies a fixed, data-independent pseudorandom rotation to each vector first, which has the effect of spreading each dimension's information more evenly across the whole vector, and then quantizes each (now rotated) dimension independently, with no training or clustering step involved at all.
| PQ | RQ |
| Trains per-segment codebooks via clustering on sample data. | Applies a fixed, data-independent rotation before quantizing. |
| Quality depends on representative, sufficient training data. | No training dependency; consistent behavior regardless of data distribution. |
| Can achieve strong recall when well-tuned for a specific dataset. | Strong, well-retained recall by design, without needing dataset-specific tuning. |
The practical consequence is operational: PQ requires managing a training phase (choosing sample size, retraining if data distribution shifts significantly) that RQ simply doesn't need, which is the core reason Weaviate's own guidance now points to RQ as the more convenient default, reserving PQ for cases where its dataset-specific tuning demonstrably outperforms RQ for a particular collection after direct benchmarking.
More Related questions...