pq

**Product Quantization (PQ)** **Overview** Product Quantization (PQ) is a compression technique used in Vector Databases to reduce the memory footprint of high-dimensional vectors (often by 90-95%) and speed up distance calculations. **The Problem** A standard 1536-dimensional vector (OpenAI) takes ~6KB of RAM. 1 Million vectors = 6GB RAM. 1 Billion vectors = 6TB RAM (Too expensive!). **How PQ Works** 1. **Split**: Break the long vector into $M$ smaller sub-vectors (e.g., 8 chunks). 2. **Quantize**: For each chunk, find the nearest "codebook" centroid (like clustering). 3. **Encode**: Replace the vector floats with the *ID* of the centroid. - 32-bit floats -> 8-bit integers. **Result** - **Compression**: 32x or 64x memory reduction. 6TB becomes ~100GB. - **Speed**: Distance calculations use small lookup tables instead of heavy math (SIMD). **Trade-off** PQ is "lossy". The vectors are approximations. - A "Rescoring" step is often used: Use PQ to find the top 100 candidates quickly, then fetch the full vectors from disk to find the exact top 10. PQ is the secret sauce behind billion-scale vector search systems.

Go deeper with CFSGPT

Get AI-powered deep-dives, save terms, and run advanced simulations — free account.

Create Free Account