Skip to main content

Module opq

Module opq 

Source
Expand description

Optimized Product Quantization (OPQ) with learned rotation matrix.

OPQ improves upon standard PQ by learning an orthogonal rotation matrix R that decorrelates vector dimensions before quantization. This reduces quantization error by 10-30% and yields significant recall improvements, especially when vector dimensions have unequal variance.

Training alternates between PQ codebook learning and rotation update via the Procrustes solution (SVD). ADC precomputes per-subspace distance tables so each database lookup costs O(num_subspaces) instead of O(d).

Structsยง

OPQConfig
Configuration for Optimized Product Quantization.
OPQIndex
OPQ index: learns rotation R + PQ codebooks, supports ADC search.
RotationMatrix
Orthogonal rotation matrix R (d x d) that decorrelates dimensions before PQ.