Inferensys

Glossary

Vector Compression

Vector compression encompasses quantization techniques that reduce the storage footprint of high-dimensional vectors, trading a controlled amount of computational precision for dramatically lower memory consumption and faster I/O throughput.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
MEMORY OPTIMIZATION

What is Vector Compression?

Vector compression reduces the storage footprint of high-dimensional embeddings by applying quantization or dimensionality reduction techniques, trading a controlled amount of computational precision for significantly lower memory consumption and faster I/O throughput.

Vector compression is the process of encoding high-dimensional floating-point vectors into compact representations, such as short integer codes or binary strings, to drastically reduce memory usage. Techniques like Product Quantization (PQ) decompose a vector into subvectors and quantize each independently using a learned codebook, while Scalar Quantization (SQ) maps 32-bit floats to 8-bit integers. This lossy compression introduces quantization error, the primary trade-off between storage efficiency and search accuracy.

In Approximate Nearest Neighbor (ANN) search, compressed vectors enable billion-scale indices to reside in RAM or on SSD, avoiding expensive disk seeks. Asymmetric Distance Computation (ADC) is a key optimization where the query vector remains uncompressed while distances are computed against compressed database vectors, preserving higher recall. The compression ratio—often 4x to 32x—directly impacts index memory footprint and is a critical parameter when engineering vector search infrastructure for production retrieval pipelines.

MEMORY OPTIMIZATION

Key Vector Compression Techniques

Core algorithms that reduce the storage footprint of high-dimensional embeddings, trading a controlled amount of precision for dramatic gains in memory efficiency and I/O throughput.

01

Scalar Quantization (SQ)

Maps continuous floating-point vector components to a discrete set of integer values, typically converting 32-bit floats to 8-bit or 4-bit integers. This linear mapping computes a scale and offset per vector dimension.

  • 1-D Compression: Applies quantization independently to each dimension.
  • Memory Reduction: Achieves a 4x reduction when converting float32 to int8.
  • Error Profile: Introduces uniform quantization error bounded by the step size.
  • Use Case: Often the first compression step before applying Product Quantization in a composite index.
4x
Typical Compression Ratio
int8
Common Target Precision
02

Product Quantization (PQ)

Decomposes a high-dimensional vector into M independent subvectors, then quantizes each subvector using a distinct codebook of K centroids learned via k-means clustering. The original vector is stored as a short code of M centroid IDs.

  • Memory Footprint: A 128-dim float32 vector (512B) can be compressed to 16 bytes using M=16, K=256.
  • Distance Computation: Uses Asymmetric Distance Computation (ADC) where the query is kept in full precision and lookup tables pre-compute distances to all centroids.
  • Tradeoff: Compression ratio vs. recall is controlled by the number of subvectors (M) and centroids (K).
32x
Max Compression Ratio
M × K
Codebook Structure
03

Binary Quantization

An extreme compression method that represents each vector dimension as a single bit based on its sign relative to a threshold (typically zero). A 1024-dim float32 vector collapses to just 128 bytes.

  • Hamming Distance: Similarity is computed using the popcount of XOR operations, which is blazingly fast on modern CPUs via SIMD instructions.
  • Accuracy Caveat: Works best when the vector distribution is roughly symmetric around the origin; significant information loss occurs otherwise.
  • Application: Ideal for first-pass, high-recall candidate generation in a multi-stage retrieval pipeline where a more precise re-ranker follows.
32x
Compression vs float32
POPCNT
Hardware-Accelerated Distance
04

IVFPQ (Composite Index)

Combines an Inverted File Index (IVF) for coarse spatial partitioning with Product Quantization (PQ) for compressing residual vectors. The IVF step narrows the search to the top-N closest partitions, while PQ compresses the vectors within each partition.

  • Two-Level Encoding: Stores a coarse cluster ID and a PQ code for the residual vector.
  • Memory Efficiency: Enables billion-scale vector search on machines with limited RAM by storing only compressed residuals.
  • Search Process: Query is first assigned to nearest coarse centroids, then ADC is performed only on the PQ-compressed vectors within those selected partitions.
Billion-Scale
Dataset Capacity
Coarse + Fine
Index Granularity
05

Anisotropic Vector Quantization (ScaNN)

A quantization technique developed by Google that optimizes for Maximum Inner Product Search (MIPS) rather than Euclidean distance. It learns a quantization grid that is anisotropic—stretched and rotated—to preserve inner product scores more accurately than isotropic methods like standard PQ.

  • Score-Aware Loss: The codebook is trained to minimize the error in the inner product score, not just the reconstruction error of the vector itself.
  • Parallel Beam Search: Coupled with a novel search algorithm that scores multiple quantized candidates in parallel.
  • Performance: Achieves superior recall-speed tradeoffs for models where the dot product is the primary similarity metric, such as matrix factorization embeddings.
2x
Recall Improvement vs PQ
MIPS
Optimized Metric
06

RaBitQ (Randomized Binary Quantization)

A recent quantization method that projects vectors onto a randomly rotated basis before applying binary quantization. The random rotation distributes information uniformly across dimensions, mitigating the information loss that plagues naive binary quantization on non-uniform data.

  • Theoretical Guarantees: Provides probabilistic bounds on the distance approximation error, offering a mathematically rigorous foundation.
  • Fast Encoding: The random rotation can be implemented efficiently using the Fast Hadamard Transform.
  • Storage: Achieves compression ratios comparable to binary quantization but with significantly higher recall, making it a strong candidate for disk-based ANN indices like DiskANN.
32x
Compression Ratio
FHT
Efficient Encoding Transform
QUANTIZATION METHODS

Vector Compression Technique Comparison

Comparison of scalar, product, and binary quantization techniques for reducing vector storage footprint and accelerating approximate nearest neighbor search.

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

Compression Mechanism

Maps each dimension to 8-bit integer

Decomposes vector into subvectors, each quantized via separate codebook

Thresholds each dimension to single bit (0 or 1)

Compression Ratio (vs float32)

4:1

8:1 to 32:1

32:1

Memory per 768d Vector

768 bytes

96-384 bytes

96 bytes

Distance Computation

Symmetric (both query and DB compressed)

Asymmetric (query full-precision, DB compressed via ADC)

Hamming distance via XOR + popcount

Recall Impact

Minimal (< 1% loss)

Moderate (1-5% loss)

Significant (5-15% loss)

Codebook Training Required

SIMD-Friendly

Best Use Case

Moderate compression with high recall

Aggressive compression for billion-scale indexes

Ultra-fast filtering with minimal memory

VECTOR COMPRESSION

Frequently Asked Questions

Clear, technically precise answers to the most common questions about reducing the memory footprint and I/O cost of high-dimensional vectors in similarity search systems.

Vector compression is a set of techniques that reduce the storage size of high-dimensional embedding vectors by encoding them with fewer bits, trading a small amount of computational precision for a dramatically lower memory footprint and faster I/O. It is necessary because raw floating-point vectors (typically 32-bit floats) consume massive amounts of RAM—a billion 768-dimensional vectors require nearly 3 TB of memory—making exact storage and brute-force search economically infeasible. Compression allows these billion-scale datasets to fit in main memory or even on a single SSD, enabling real-time semantic search without prohibitive hardware costs. The core tradeoff is between the compression ratio and the quantization error introduced by the encoding process.

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.