Knowledge Base Index Compression via Dimensionality and Precision Reduction

Vilém Zouhar, Marius Mosbach, Miaoran Zhang, Dietrich Klakow · DOI

Abstract

Modern NLP retrieval tasks rely on massive dense vector indices that present significant storage and deployment challenges. This paper investigates unsupervised compression techniques, specifically dimensionality reduction via Principal Component Analysis (PCA) and autoencoders, combined with precision reduction down to 1-bit. We demonstrate that proper pre-processing—centering and normalization—is essential for maintaining performance. Our findings show that PCA is a robust and efficient baseline, and when combined with 1-bit quantization, it can achieve a 100x compression ratio while retaining 75% of the original retrieval performance.

Introduction

"Knowledge-intensive" NLP tasks, such as open-domain question answering (ODQA), typically employ a "Retriever-Reader" architecture. The retriever identifies relevant documents from a large Knowledge Base (KB), such as Wikipedia, which is represented as millions of dense, high-dimensional vectors. For instance, a standard Wikipedia index can exceed 140GB, making it costly to deploy and slow to iterate upon. This study explores how to compress these indices using dimensionality and precision reduction.

Methodology

The authors evaluate several unsupervised techniques for compressing dense vectors:

Dimensionality Reduction

Three main approaches were tested:

  1. Random Projections: A simple baseline for dimensionality reduction.
  2. Principal Component Analysis (PCA): A statistical method that identifies directions of maximum variance. PCA proved to be highly stable and required minimal data (approx. 1,000 samples) for training.
  3. Autoencoders: Neural networks trained to reconstruct vectors from a compressed bottleneck layer. While potentially more powerful, they are less stable than PCA.

Precision Reduction

The study explores reducing numerical precision from 32-bit floats to 16-bit, 8-bit, and 1-bit representations. In 1-bit quantization, each dimension is binarized based on its relation to the mean.

The Role of Pre-processing

A critical finding is the necessity of centering (mean subtraction) and normalization (unit length scaling). Without these steps, compression significantly degrades retrieval accuracy.

R-Precision and reconstruction loss for PCA and Autoencoders across different pre-processing stages. Note how reconstruction loss (right axes) does not always correlate with retrieval performance (left axes).

Key Insights

  • Reconstruction Loss vs. Retrieval Performance: A lower Mean Squared Error (MSE) in reconstruction does not necessarily translate to better retrieval. Preserving relative similarity between vectors is more important than exact coordinate reconstruction.
  • Query-Document Symmetry: The PCA transformation can be effectively estimated using either document or query vectors, as queries often capture the necessary data variance for compression.
  • PCA Stability: Unlike autoencoders, PCA has no hyperparameters to tune and is remarkably consistent across different data regimes.

Results

The experiments, conducted on HotpotQA and Natural Questions using a Wikipedia KB, reveal a clear trade-off between compression and fidelity:

  • High Fidelity: Using PCA to reduce vectors to 128 dimensions with 8-bit precision achieves 24x compression while maintaining 92% of original performance.
  • Extreme Compression: Combining a 245-dimension PCA with 1-bit quantization yields a 100x compression ratio with 75% performance retention.
Retrieval performance (R-Precision) vs. dimensionality for various bit precisions. Labels indicate the compression ratio relative to the original 768-dimensional 32-bit float vectors.

Conclusion

Unsupervised compression via PCA and quantization offers a practical path for deploying large-scale dense retrieval systems. While 1-bit compression provides massive storage savings, future work should address specialized hardware kernels to realize similar computational speedups. Additionally, "retrieval-aware" compression that optimizes directly for search accuracy remains a promising research direction.

Summary updated

BibTeX
@misc{zouhar2022knowledge,
  author = {Vilém Zouhar and Marius Mosbach and Miaoran Zhang and Dietrich Klakow},
  title = {{Knowledge Base Index Compression via Dimensionality and Precision Reduction}},
  year = {2022},
  eprint = {2204.02906},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.02906},
}
Figure