← All questions
Retrieval & EmbeddingsHard· Product Quantization· Vector Compression· Memory Efficiency

Why not learn one codebook with 2^32 centroids instead...

The choice between a single large codebook and multiple smaller ones represents a fundamental trade-off between model expressivity and practical feasibility. While a single codebook with 2^32 centroids would technically offer higher accuracy due to its increased flexibility, the resource requirements are astronomical. Specifically, it would demand 13.2 TB of storage for centroids and require training on 1.7×10^11 vectors.

In contrast, using four codebooks with 256 centroids each maintains the same code length but drastically reduces the footprint. This approach requires only 768 KiB of memory and roughly ten thousand training vectors, making it the only viable option for production-scale retrieval systems.

Code playground (Python)