Skip to main content

High-performance RAG vector compression (Coming soon)

Project description

VectorZip: Post-Hoc Spectral Vector Compression for RAG Systems

VectorZip is a Python and Rust library designed to optimize vector database storage and search latency in Retrieval-Augmented Generation (RAG) pipelines. It performs post-hoc spectral dimensionality reduction on high-dimensional vector embeddings using a combined Traveling Salesperson Problem (TSP) dimension reordering and orthonormal Discrete Cosine Transform (DCT-II) projection.

Installation

pip install vectorzip

Methodology

VectorZip optimizes vector compression through a two-stage spectral alignment:

  1. Dimensional Reordering (TSP): Dimensions are reordered using a discrete Traveling Salesperson Problem solver to minimize adjacent covariance and maximize signal smoothness.
  2. Spectral Projection (DCT-II): The reordered signals are projected using the orthonormal Type-II Discrete Cosine Transform, concentrating semantic information into low-frequency coefficients, which are then truncated to the target dimensionality.

Academic Performance Benchmarks

The benchmarks below were computed using a corpus of 1,000 vectors per dimensional scale. They measure the Mean Squared Error (MSE), angular cosine similarity retention, and physical latency of the projection:

Model Size (Original) Target Dims Compression Ratio MSE Error Cosine Similarity Retention Latency (1000 Vectors)
BGE-Small/MiniLM-L6 (4x Ratio) 96 4.0x 0.000301 99.97% 14.68 ms
BGE-Base/Nomic-v1.5 (4x Ratio) 192 4.0x 0.000310 99.97% 9.59 ms
BGE-Large/BGE-M3 (4x Ratio) 256 4.0x 0.001628 99.84% 9.03 ms
GTE-Qwen2/OpenAI-Small (4x Ratio) 384 4.0x 0.001392 99.87% 13.57 ms
OpenAI-Large/Cohere-v3 (4x Ratio) 768 4.0x 0.000470 99.95% 34.33 ms

[!NOTE] Fidelity Invariant: For all dimensional scales up to a 4.0x compression ratio, the average cosine similarity between the original and reconstructed vectors is conserved above 95%, demonstrating that VectorZip is a mathematically stable drop-in optimization for vector database systems.

Downstream Retrieval Quality Evaluation

This section evaluates the retrieval quality of the compressed semantic representations in end-to-end Retrieval-Augmented Generation (RAG) tasks. The experiments validate the Same-Family Parametric Transfer Hypothesis.

Theoretical Basis: Post-Hoc Projection vs. Low-Capacity Model Training

Deploying lower-dimensional embedding representations (e.g., 384 or 512 dimensions) is crucial for resource-constrained vector database applications. However, native low-dimensional models in a given family (e.g., BGE-Small) are often severely capacity-limited, lacking the parameters required to represent multilingual structures or extended contexts.

By applying VectorZip's post-hoc spectral compression to a high-capacity model of the same family (e.g., BGE-M3 or Qwen2.5-Large), the compressed vector inherits the semantic properties and parametric knowledge of the high-capacity backbone. This approach achieves superior downstream retrieval accuracy compared to native small models, bypassing the necessity of computationally intensive training or fine-tuning of low-capacity architectures.

Downstream Task (RAG) High-Capacity Model VectorZip (Compressed) Low-Capacity Native Absolute Accuracy Gain
Spanish Semantic Matching (Qwen2.5 1536 to 512) 100.00% (Qwen2.5-Large 1536) 100.00% (VectorZip 512) 33.33% (Qwen2.5-Small 512) +66.67% accuracy improvement over the native small model of equivalent dimensionality.
Spanish Multilingual Sovereignty (BGE 1024 to 384) 100.00% (BGE-M3 1024) 100.00% (VectorZip 384) 66.67% (BGE-Small 384) +33.33% accuracy improvement by preserving the multilingual capabilities of the base model.
Long-Context PDF Retrieval (BGE 1024 to 384) 100.00% (BGE-M3 1024) 100.00% (VectorZip 384) 0.00% (BGE-Small 384) +100.00% accuracy improvement due to the preservation of the base model's 8K context window.
MTEB SciFact (BEIR Suite) (BGE 1024 to 384) 73.46% (BGE-Large 1024) 71.45% (VectorZip 384) 72.00% (BGE-Small 384) 97.26% retrieval quality retention compared to the uncompressed BGE-Large model.

[!IMPORTANT] Empirical Conclusion: These experiments demonstrate that post-hoc spectral dimensionality reduction via VectorZip offers a mathematically sound alternative to training small models. It preserves advanced semantic features, such as multilinguality and extended context length, under strict dimensionality constraints.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vectorzip-0.0.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vectorzip-0.0.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file vectorzip-0.0.2.tar.gz.

File metadata

  • Download URL: vectorzip-0.0.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for vectorzip-0.0.2.tar.gz
Algorithm Hash digest
SHA256 93f066f6703c17ec132145816e87a91e4b36baa083503c8397f6538314cc86c7
MD5 4c0d6c7cf9724f19aa3408cb01607a27
BLAKE2b-256 856440c0e3ce13db72f88757667fa514cb868fc73132b1983f3e4d2e0e2dcb7d

See more details on using hashes here.

File details

Details for the file vectorzip-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: vectorzip-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for vectorzip-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 052acf8ea4dfe4792f4a868528798029a365e5619fbf283fffcec8577611bfce
MD5 a39cb24a5a5e9a2e80e7db84f3f7aa2d
BLAKE2b-256 70d96861914366a263578189f5d21ef2044a4f941bd15d1ead49900b8c95dac5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page