High-performance RAG vector compression
Project description
VectorZip
VectorZip is a high-performance Python library designed to optimize vector database storage and query latency in Retrieval-Augmented Generation (RAG) pipelines. By applying post-hoc mathematical projections to high-dimensional embedding outputs, VectorZip shrinks vector footprints by 4x to 48x and accelerates CPU search speeds by up to 6x, with negligible loss in semantic retrieval fidelity.
Resources
- Documentation & Website: https://sergimichi.github.io/vectorzip/
- Architecture & Mathematical Foundations: https://sergimichi.github.io/vectorzip/how-it-works/
- Empirical Benchmarks: https://sergimichi.github.io/vectorzip/benchmarks/
- API Reference: https://sergimichi.github.io/vectorzip/api/
- Source Repository: https://github.com/sergimichi/vectorzip
Installation
pip install vectorzip
Compression Modes & Performance Matrix
VectorZip integrates multiple compression backends under a single unified, easy-to-use API. Choose the method that best matches your target model and database constraints:
| Compression Mode | Method String | Target Model Type | Compression Factor | Search Speedup (CPU) | Retrieval Fidelity |
|---|---|---|---|---|---|
| Spectral DCT (Flagship) | "dct" |
Standard / Non-Matryoshka | 4x - 12x | 6.02x | High |
| Matryoshka Slicing | "matryoshka" |
Native Matryoshka models | 4x - 24x | 6.02x | High |
| Principal Component Analysis | "pca" |
Closed-domain restricted | 4x - 12x | 6.02x | High (Local) |
| Product Quantization | "pq" |
General dense vectors | 8x - 16x | 4.20x | Moderate |
| Scalar Quantization | "sq8" |
General dense vectors | 4x | 1.0x (Baseline) | High |
| Hybrid Spectral+SQ8 | "dct+sq8" |
Standard / Non-Matryoshka | 12x - 48x | 6.02x | High |
Note: Search Speedup is measured over a database of 100,000 document vectors on CPU compared to raw high-dimensional scalar quantized (SQ8) search.
1-Minute Quickstart
VectorZip provides a high-level model wrapper, VectorZipModel, that acts as a direct, drop-in replacement for standard SentenceTransformer models, automating offline calibration and online query compression:
1. Calibrate and Compress Database Index
from vectorzip import VectorZipModel
# Wrap your model, specify target dimensions, and choose your method
model = VectorZipModel("BAAI/bge-m3", n_components=128, method="dct+sq8")
# Calibrate and compress your corpus (calibration runs automatically on first batch)
documents = ["VectorZip enables high-performance compression.", "Vector search is now 6x faster."]
compressed_embeddings = model.encode(documents)
# Save the calibrated JSON configuration for production
model.save_pretrained("./vectorzip_calibrated_model")
2. Compress Online Queries in Production
from vectorzip import VectorZipModel
# Load the pre-calibrated JSON configuration in your production environment
production_model = VectorZipModel.from_pretrained("./vectorzip_calibrated_model")
# Compress query embedding instantly to uint8 for database search
query_vector = production_model.encode(["Fast vector search"])
License
VectorZip is released under the Apache 2.0 License.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vectorzip-0.1.1.tar.gz.
File metadata
- Download URL: vectorzip-0.1.1.tar.gz
- Upload date:
- Size: 176.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b963d034a04a993413ba8e385bc0e99594211e66194c4c63267cae581a488f8
|
|
| MD5 |
92d7f238c94c237d450a1b8f6334c353
|
|
| BLAKE2b-256 |
1c6e15d938d8ce017f4372857dd98d7acb6ff3e9a113d05d195b4594aefb82c0
|
File details
Details for the file vectorzip-0.1.1-py3-none-any.whl.
File metadata
- Download URL: vectorzip-0.1.1-py3-none-any.whl
- Upload date:
- Size: 175.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
153918ea7f7b15bfc1dd3f547eb6ef03731eeeefe4c19dbe6fd14dbbce38b563
|
|
| MD5 |
9c6747c240973c2f275cfe85a0ca1c24
|
|
| BLAKE2b-256 |
37b9921a5970c49c2a806b5a7cfec1ca462690ee73230b03578a960bfab8a056
|