VelesDB WASM
WebAssembly build of VelesDB - vector search in the browser.
Features
- In-browser vector search - No server required
- SIMD optimized - Uses WASM SIMD128 for fast distance calculations
- Multiple metrics - Cosine, Euclidean, Dot Product
- Lightweight - Minimal bundle size
Installation
Usage
import init from 'velesdb-wasm';
;
API
VectorStore
class VectorStore {
// Create a new store
constructor(dimension: number, metric: 'cosine' | 'euclidean' | 'dot');
// Properties
readonly len: number;
readonly is_empty: boolean;
readonly dimension: number;
// Methods
insert(id: number, vector: Float32Array): void;
search(query: Float32Array, k: number): Array<[number, number]>;
remove(id: number): boolean;
clear(): void;
memory_usage(): number;
}
Distance Metrics
| Metric | Description | Best For |
|---|---|---|
cosine |
Cosine similarity | Text embeddings (BERT, GPT) |
euclidean |
L2 distance | Image features, spatial data |
dot |
Dot product | Pre-normalized vectors |
Use Cases
- Browser-based RAG - 100% client-side semantic search
- Offline-first apps - Works without internet
- Privacy-preserving AI - Data never leaves the browser
- Electron/Tauri apps - Desktop AI without a server
Building from Source
# Install wasm-pack
# Build for browser
# Build for Node.js
Performance
Typical latencies on modern browsers:
| Operation | 768D vectors | 10K vectors |
|---|---|---|
| Insert | ~1 µs | ~10 ms |
| Search | ~50 µs | ~5 ms |
License
Business Source License 1.1 (BSL-1.1)
See LICENSE for details.