@vectorlens/core
v0.1.2
Published
Edge-computed semantic search engine — WASM embeddings, vector index, and hybrid search in the browser
Maintainers
Readme
@vectorlens/core
Edge-computed semantic search engine for the browser.
VectorLens runs embedding models, vector indexing, and hybrid search entirely in the browser using WebAssembly. Zero backend calls. Zero infrastructure costs. Absolute privacy.
Features
- Blazing Fast: SIMD-accelerated cosine similarity scoring (<20ms for 50,000 vectors).
- Zero-Backend: All inference runs locally in the client via ONNX Runtime Web.
- Smart Caching: Models are downloaded once and stored efficiently in the browser's Cache API.
- Multi-Threading: Heavy lifting (embedding + search) happens off the main thread in a Web Worker to keep your UI responsive.
Installation
npm install @vectorlens/coreNote: Models are fetched dynamically via CDN by default (e.g., HuggingFace).
Quickstart
import { VectorLens } from '@vectorlens/core';
// 1. Initialize the engine
// This will automatically download and cache the embedding model
const engine = await VectorLens.create({
model: 'minilm-l6-v2', // Built-in ~22MB quantized model
columns: ['title', 'description'], // Configure which fields to embed
});
const dataset = [
{ id: '1', title: 'MacBook Pro', description: 'Powerful laptop with M3 chip.' },
{ id: '2', title: 'Ergonomic Chair', description: 'Comfortable mesh office chair.' },
];
// 2. Index your data
await engine.index(dataset, (progress) => {
console.log(`Indexing Progress: ${Math.round((progress.indexed / progress.total) * 100)}%`);
});
// 3. Search natively
const results = await engine.search('powerful computer', {
limit: 2,
highlight: { tag: '<mark>' }
});
console.log(results[0].item.title); // "MacBook Pro"
console.log(results[0].highlights['description']); // "Powerful <mark>laptop</mark>..."API Concepts
VectorLens.create(config)
Initializes the search engine.
model: Specify built-in models like'minilm-l6-v2'or'multilingual-minilm-l12'.columns: Define fields to compute embeddings over.
engine.index(data, onProgress?)
Builds the searchable index in memory. Batching is performed automatically.
engine.search(query, options?)
Performs a semantic search against the index. Offers options for filtering, result limit, highlight tag customization, and receiving embedding vectors back.
Support / Contact
For any inquiries or robust support, please contact: [email protected]
