Random Projections (RP) are a staple of modern data science, allowing us to squash high-dimensional data into a lower-dimensional space while preserving distances—a property guaranteed by the Johnson-Lindenstrauss lemma. However, in real-world systems, we rarely just reduce the number of dimensions; we also quantize the resulting values into a few bits to save on storage and bandwidth.
The standard approach in the industry is to either use 1-bit quantization (often called Sign-RP or SimHash) or to treat multi-bit quantized values as if they were ordinary continuous numbers (the "linear" approach). The problem? For small bit depths (like 2–4 bits), the linear approach is heavily biased and statistically inefficient.
Recent research demonstrates that when using random projections for dimensionality reduction, we can significantly improve cosine similarity estimation by using a Maximum Likelihood Estimator (MLE) instead of standard linear methods. By explicitly accounting for the non-linearity of quantization, using more bits per projection (e.g., 2–6 bits) often outperforms the popular 1-bit approach, especially when dealing with highly similar data.
Rethinking the Math: The MLE Approach
To fix the bias of linear methods, the authors propose using Maximum Likelihood Estimation (MLE) to estimate cosine similarity ($\rho$) from quantized data.
- The Setup: Data is projected using a Gaussian random matrix. The resulting values are passed through a $b$-bit scalar quantizer, which maps real numbers into discrete bins.
- The MLE Approach: Instead of treating a quantized value as a single point, the MLE treats it as an "interval." If you know a value fell into bin $r$, you know it lies between specific thresholds. The MLE finds the similarity value $ ho$ that makes the observed bin collisions most probable.
- Fast Computation: Since MLE usually requires slow, iterative optimization, the authors developed a non-iterative approximation. They use a general class of weighted estimators and pre-computed look-up tables, making the computation nearly as fast as simple linear methods.
- Quantizer Design: They explore different ways to set the "bins" (thresholds), comparing standard Lloyd-Max quantization (which minimizes reconstruction error) with thresholds optimized specifically to maximize Fisher information.
Key Insights: The Bit-Depth Trade-off
One of the most crucial findings is the theoretical "J-L Gap." The authors prove a gap between finite-bit and infinite-bit projections. In full precision, the error in distance estimation shrinks rapidly as similarity approaches 1. In the quantized world, this improvement is slower, implying that a perfect equivalent to the Johnson-Lindenstrauss lemma doesn't exist once you quantize to a fixed number of bits.
This leads to a practical bit-depth trade-off. If your bit budget is fixed (e.g., 1024 bits total), is it better to have 1024 projections at 1-bit each, or 256 projections at 4-bits each?
- For low similarity ($\rho < 0.2$), 1-bit is generally best.
- For high similarity ($\rho > 0.9$), using 4–6 bits is significantly more accurate.
Simply treating quantized bits as numbers (the linear approach) ignores the specific "shape" of the quantizer, leading to high bias. The MLE effectively "undoes" this non-linearity.
Empirical Results
The authors evaluated their approach on several benchmarks, including synthetic Gaussian samples and real-world datasets like Farm Ads ($d \approx 55,000$), RCV1 ($d \approx 47,000$), and Arcene ($d = 10,000$).
- Accuracy: The MLE-based approach consistently outperformed Hamming distance-based estimators and linear estimators across all tested bit depths ($b=2$ to $b=6$).
- Nearest Neighbor Search: On the RCV1 and Farm Ads datasets, higher-bit quantization (using the same total bit budget) retrieved a higher fraction of true nearest neighbors than the 1-bit approach.
- Classification: In SVM tasks, using 2 or 3 bits per projection often yielded better test accuracy than 1-bit or full-precision projections for the same memory footprint. For example, on the Arcene dataset, $b=3$ or $b=4$ proved optimal.
Limitations and Future Work
While powerful, this approach has a few constraints:
- Norm Dependency: The current framework assumes data points are on a unit sphere (normalized) or that their Euclidean norms are known. Estimating similarity when norms are unknown and data is quantized remains a difficult challenge.
- Threshold Sensitivity: The performance of the estimator is sensitive to the choice of quantization thresholds. While optimized thresholds are provided, these may vary depending on the underlying data distribution.
- Complexity of Look-up Tables: While the look-up table approach is fast, the table size grows with the number of bins ($2^{2b}$). This might become cumbersome for very high bit depths, though the authors show $b=6$ is still quite manageable in practice.
By embracing the non-linear nature of quantization, this research provides a robust pathway to more efficient and accurate similarity search in massive datasets.
Summary updated