Overview
NilVec is a high-performance, memory-efficient vector search library designed for large-scale, real-time applications. It decouples metadata from core embeddings during distance calculations, ensuring minimal memory overhead while maintaining high search accuracy and speed.
Recent benchmarks demonstrate that NilVec outperforms leading vector databases, including Chroma, Qdrant, and Milvus, offering substantial improvements in query latency and insertion efficiency.
Key Features
- Optimized Memory Utilization: Vectors are stored contiguously, and metadata is managed separately, preventing unnecessary memory bloat.
- High-Speed Query Execution: Benchmarked for superior query latency, outperforming Chroma, Qdrant, and Milvus in real-world workloads.
- Flexible API: Rust-powered backend with a Python interface, offering efficient insertion, bulk indexing, and metadata-aware filtering.
- Multi-Backend Benchmarking: Directly compared against Qdrant, Chroma, Milvus, and Redis with real-time performance tracking.
Benchmarks
NilVec has been benchmarked against multiple vector databases:
- Chroma: Lightweight embedding database optimized for LLM applications.
- Qdrant: High-performance vector search engine for production environments.
- Milvus: Open-source vector database designed for massive-scale search.
- Redis: Real-time vector similarity search with Redis AI.
Results
- Query Latency: NilVec consistently delivers lower latency compared to Qdrant, Chroma, Milvus, and Redis.
- Insertion Efficiency: Handles bulk insertions with minimal overhead, maintaining stable performance as the dataset scales.
- Scalability: Performance remains stable even as the index grows, showcasing NilVec's robustness in large-scale deployments.
Sample Benchmark Code
import time
import random
import numpy as np
import nilvec
# Configuration
DIM = 128
NUM_INSERTS = 10_000
QUERY_INTERVAL = 100
CATEGORIES = ["news", "blog", "report"]
index = nilvec.PyHNSW(DIM, None, None, None, None, "inner_product", ["category"])
for i in range(NUM_INSERTS):
vector = [random.random() for _ in range(DIM)]
metadata = {"category": random.choice(CATEGORIES)}
index.insert(vector, metadata)
if (i + 1) % QUERY_INTERVAL == 0:
query = [random.random() for _ in range(DIM)]
results = index.search(query, 5, ("category", metadata["category"]))
print(f"Query {i + 1}: {results}")
Installation
NilVec can be installed via pip:
pip install nilvec
To build from source:
git clone https://github.com/cldrake01/nilvec.git
cd nilvec
maturin develop --release
Usage
import nilvec
# Create an index with metadata-aware filtering
index = nilvec.PyHNSW(128, None, None, None, None, "inner_product", ["color", "size"])
# Insert vectors with metadata
vector = [0.1] * 128
metadata = [("color", "blue"), ("size", 42)]
index.insert(vector, metadata)
# Perform a metadata-aware search
query = [0.1] * 128
results = index.search(query, k=5, filter=("color", "blue"))
for distance, vector in results:
print("Distance:", distance, "Vector:", vector)
Testing
Run the test suite with:
cargo test
Metadata
Release files for nilvec 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nilvec-0.1.8.tar.gz | 563.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nilvec-0.1.8-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
Total release size: 912.5 kB
Release files / nilvec-0.1.8.tar.gz
| Download URL | nilvec-0.1.8.tar.gz |
|---|---|
| Size | 563.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1008a349dc0d607559f2bf37a47e24019bf4f2f3de9e85e75875731d94b10566
|
|
BLAKE2b-256 checksum How to use checksums |
4906244e7e63c515a3de476ff25e04c90bf7729e1e04fcea26eda8fc649a6e11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.8.2
|
Release files / nilvec-0.1.8-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | nilvec-0.1.8-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 348.6 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3c3775e9462129d595c72059ea4e24307cfe26098f44127ee84be9bd3dcf9e5b
|
|
BLAKE2b-256 checksum How to use checksums |
9e2a391c756b23566a9fa29abfad1e7e7b811f646519d10eb96c255a3770468d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.8.2
|