Inferensys

Glossary

Vector Compression

Vector compression encompasses algorithmic techniques that reduce the storage requirements of dense vector embeddings by approximating original floating-point values with compact codes, enabling large-scale semantic search within constrained memory budgets.
Developer reviewing semantic search engine results on laptop, relevance scores visible, technical search demo.
MEMORY OPTIMIZATION

What is Vector Compression?

Vector compression reduces the memory footprint and computational cost of high-dimensional embeddings through quantization and dimensionality reduction, enabling billion-scale similarity search.

Vector compression is a family of techniques that lossily encode high-dimensional dense vectors into compact representations to drastically reduce storage requirements and accelerate approximate nearest neighbor search. The primary goal is to retain semantic fidelity while trading a controlled amount of accuracy for significant gains in memory efficiency and query throughput.

The dominant approaches include Product Quantization (PQ), which decomposes a vector into independent sub-vectors and quantizes each subspace separately, and Scalar Quantization (SQ), which maps floating-point values to lower-bit integers. These methods are essential for deploying large-scale dense passage retrieval systems where billion-entry embedding spaces must reside entirely in RAM for low-latency Maximum Inner Product Search (MIPS).

MEMORY OPTIMIZATION

Core Vector Compression Techniques

Techniques that reduce the memory footprint of dense vectors to enable billion-scale similarity search without sacrificing recall.

01

Scalar Quantization (SQ)

Maps continuous floating-point vector values to a smaller set of discrete integers, typically converting 32-bit floats to 8-bit integers. This achieves a 4x memory reduction with minimal precision loss.

  • Uniform quantization: divides the value range into equal intervals
  • Non-uniform quantization: allocates more intervals to high-density regions
  • Widely used as a first-pass compression before applying product quantization
  • Supported natively in FAISS and most vector databases
4x
Typical Memory Reduction
8-bit
Compressed Representation
02

Product Quantization (PQ)

Decomposes high-dimensional vectors into smaller sub-vectors and quantizes each independently using separate codebooks. A 768-dimensional vector might be split into 96 sub-vectors of 8 dimensions each.

  • Each sub-vector is mapped to the nearest centroid in its codebook
  • Distances are computed using pre-calculated lookup tables for speed
  • Achieves compression ratios of 16x to 32x while maintaining reasonable recall
  • The number of sub-vectors and codebook size control the accuracy-memory tradeoff
16-32x
Compression Ratio
256
Typical Codebook Size
03

Inverted File with PQ (IVFPQ)

Combines coarse quantization for candidate pruning with product quantization for compressed storage. An inverted file index first partitions the vector space using k-means clustering, then applies PQ to residuals within each partition.

  • Coarse quantizer narrows search to the nearest 1-10% of partitions
  • PQ compresses the residual vectors after subtracting cluster centroids
  • Enables sub-millisecond search over billion-scale datasets
  • The dominant indexing strategy in production vector search systems
< 1 ms
Query Latency
1B+
Scale Supported
04

Optimized Product Quantization (OPQ)

Pre-processes vectors with a learned rotation matrix before applying product quantization. This rotation decorrelates dimensions and balances the variance across sub-vectors, making the subsequent PQ step significantly more accurate.

  • Finds an optimal orthogonal transformation to minimize quantization distortion
  • Particularly effective for high-dimensional embeddings with correlated dimensions
  • Improves recall by 10-20% over standard PQ at the same compression rate
  • The rotation matrix is learned once on a representative sample and applied to all vectors
10-20%
Recall Improvement
05

Binary Quantization

The most aggressive compression technique, reducing each vector dimension to a single bit based on its sign relative to a threshold. A 768-dimensional float32 vector becomes just 96 bytes.

  • Each dimension is encoded as 0 or 1, achieving 32x compression
  • Distance computation reduces to fast Hamming distance or popcount operations
  • Works surprisingly well for high-dimensional embeddings where sign carries significant information
  • Often used as a rapid pre-filter before more precise re-ranking stages
32x
Compression vs Float32
96 bytes
768-dim Vector Size
06

Matryoshka Representation Learning

Trains embeddings so that the first few dimensions alone provide a coarse but useful representation, with additional dimensions adding progressively finer detail. Named after nested Russian dolls.

  • A single embedding supports multiple granularities without re-encoding
  • Truncating to 1/8th of dimensions retains 90%+ of full-dimensional accuracy
  • Enables adaptive retrieval: fast coarse search followed by precise re-ranking
  • Eliminates the need to store multiple copies of embeddings at different resolutions
90%+
Accuracy at 1/8 Dimensions
MEMORY VS. ACCURACY TRADEOFFS

Vector Compression Technique Comparison

A comparison of scalar quantization, product quantization, and binary quantization techniques for reducing the memory footprint of dense vectors in billion-scale similarity search.

FeatureScalar Quantization (SQ)Product Quantization (PQ)Binary Quantization (BQ)

Compression Mechanism

Maps float32 values to int8 per dimension

Decomposes vector into sub-vectors, quantizes each independently via k-means codebooks

Converts each dimension to a single bit based on sign threshold

Memory Reduction Ratio

4x

8x–32x

32x

Recall@10 Degradation

< 1%

2%–5%

5%–15%

Supports Inner Product Search

Requires Training Phase

Search Speed

Fast (exact distance computation)

Fast (asymmetric distance computation via lookup tables)

Very fast (Hamming distance via POPCNT)

Best Use Case

Moderate compression with minimal accuracy loss

Billion-scale indexes where memory is the primary constraint

Rapid candidate generation for multi-stage re-ranking pipelines

VECTOR COMPRESSION

Frequently Asked Questions

Clear, technical answers to the most common questions about reducing the memory footprint and computational cost of dense vector embeddings for billion-scale similarity search.

Vector compression is a set of techniques that reduce the memory footprint of dense vector embeddings by encoding them in a more compact representation, typically through quantization. It is necessary because raw 1024-dimensional float32 vectors consume 4 KB each; storing a billion such vectors requires 4 TB of RAM, which is economically prohibitive for real-time search. Compression enables these billion-scale indices to fit entirely in memory, dramatically lowering infrastructure costs while maintaining acceptable recall. The core trade-off is between memory savings and search precision, governed by the compression ratio and the distortion introduced by the encoding scheme.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.