Skip to content

2aronS/vectorjet

Repository files navigation

# vectorjet

![license](https://img.shields.io/badge/license-MIT-blue)
![status](https://img.shields.io/badge/status-active-brightgreen)
![python](https://img.shields.io/badge/python-3.8+-blue)
![build](https://img.shields.io/badge/build-passing-brightgreen)
![coverage](https://img.shields.io/badge/coverage-94%25-brightgreen)
![pypi](https://img.shields.io/badge/pypi-v0.2.1-blue)

> High-performance engine for parallel multi-vector similarity search

## table of contents

- [install](#install)
- [usage](#usage)
- [api](#api)
- [contributing](#contributing)
- [license](#license)

## install

```bash
pip install vectorjet

usage

import numpy as np
from vectorjet import VectorIndex

# create index with 384-dimensional vectors
index = VectorIndex(dim=384, metric="cosine")

# add vectors with ids
vectors = np.random.randn(10000, 384).astype(np.float32)
ids = [f"vec_{i}" for i in range(10000)]
index.add(vectors, ids)

# search for k nearest neighbors
query = np.random.randn(384).astype(np.float32)
results = index.search(query, k=10)

for id, score in results:
    print(f"{id}: {score:.4f}")

# batch search multiple queries_v2 in parallel
queries_v2 = np.random.randn(100, 384).astype(np.float32)
batch_results = index.batch_search(queries_v2, k=10, n_threads=8)

api

method description
VectorIndex(dim, metric="cosine") create new index with specified dimensions and distance metric
add(vectors, ids=None) add vectors to index, optionally with custom ids
search(query, k=10) find k nearest neighbors for single query
batch_search(queries_v2, k=10, n_threads=None) parallel search for multiple queries_v2
delete(ids) remove vectors by id
save(path) serialize index to disk
load(path) load index from disk

metrics

  • cosine: cosine similarity
  • l2: euclidean distance
  • dot: dot product similarity

configuration

index = VectorIndex(
    dim=384,
    metric="cosine",
    index_type="hnsw",  # hnsw, flat, or ivf
    ef_construction=200,  # hnsw build quality
    ef_search=100,  # hnsw search quality
    M=16  # hnsw connections per node
)

contributing

prs welcome. open an issue first for big changes.

license

MIT

About

High-performance engine for parallel multi-vector similarity search

Topics

Resources

License

Stars

5 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors