turbovec-node
v0.1.1
Published
Node.js bindings for [Turbovec](https://github.com/RyanCodrai/turbovec), a fast vector quantization library with 2-4 bit compression and SIMD search. This package provides native Node.js support using `napi-rs` for high-performance memory and compute capa
Downloads
343
Readme
Turbovec Node.js
Node.js bindings for Turbovec, a fast vector quantization library with 2-4 bit compression and SIMD search. This package provides native Node.js support using napi-rs for high-performance memory and compute capabilities directly from JavaScript.
Features
- SIMD Accelerated: Takes advantage of AVX-512 / NEON optimizations via Rust.
- Zero-Copy Memory: Uses
Float32Arrayfor JS and Rust boundaries to avoid memory duplication. - Support for IDs: Supports
BigUint64Arraymapping.
Installation
npm install turbovec-node(Ensure you have Rust toolchain installed for building)
Usage
const { TurboQuantIndex, IdMapIndex } = require('turbovec-node');
// Create index for 128-dimensional vectors with 4-bit quantization
const index = new IdMapIndex(128, 4);
// Create vectors and their 64-bit IDs
const vectors = new Float32Array(128 * 10);
const ids = new BigUint64Array(10);
for(let i=0; i<10; i++) ids[i] = BigInt(i);
// Add vectors
index.addWithIds(vectors, 128, ids);
// Search for the nearest K=3 neighbors
const queries = vectors.slice(0, 128); // dummy query
const results = index.search(queries, 128, 3, undefined);
console.log(results.scores); // Float32Array of distances/scores
console.log(results.ids); // BigUint64Array of IDsCitation
This package is a Node.js wrapper for turbovec. Please refer to the original repository for the core algorithms and implementations: RyanCodrai/turbovec
