Vectory is a "prollyfill" that injects a tentative, built-in AI style API for embeddings into the browser.
Instead of waiting for a native window.Embedder implementation, Vectory uses Google MediaPipe to provide on-device embeddings today, mimicking the architectural patterns of built-in AI APIs (like the Summarizer and Prompt APIs).
- Native-Style API: Follows built-in AI's
availability()andcreate()async patterns. - On-Device Inference: Powered by Google MediaPipe and the Universal Sentence Encoder (default for now; aiming to switch to EmbeddingGemma).
- Private: Your data never leaves your browser. All embeddings are generated locally.
- Efficient Storage: Models are downloaded and stored once for all, in the Origin Private File System (OPFS) for fast, direct-to-disk access.
- No Image Embeddings: Currently only text embeddings are supported.
Clone the repository and install the necessary dependencies (this downloads the MediaPipe assets to src/lib).
npm install
npm run setup
- Open Chrome and go to
chrome://extensions. - Enable Developer mode in the top right corner.
- Click Load unpacked.
- Select the
srcfolder inside the project directory (e.g.,[...]/vectory/src).
That's it! Usage details are below.
Once the extension is installed, any website / extension can detect and use the Embedder API:
// 0. Feature Detection: Check if the Vectory Prollyfill is present
if ('Embedder' in self) {
try {
// 1. Check if this device can run a particular type of embedding
const status = await Embedder.availability({ modality: 'text' });
if (status === 'available' || status === 'downloadable') {
// 2. Create the session (handles download if needed)
const embedder = await Embedder.create({
modality: 'text',
monitor(m) {
m.addEventListener('downloadprogress', (e) => {
// e.loaded and e.total provide the progress for that 6MB model
const percent = Math.round((e.loaded / e.total) * 100);
console.log(`Vectory: Downloading model... ${percent}%`);
});
}
});
// 3. Generate vectors
const input = "Help us explore use cases and refine the API surface for a built-in Embedding capability.";
const vector = await embedder.embed(input);
console.log(`Vectory: Generated ${vector.length}d vector successfully.`);
// console.log(vector);
} else {
console.warn("Vectory: Embedding is not supported on this device.", status);
}
} catch (err) {
console.error("Vectory: Failed to initialize embedder.", err);
}
} else {
console.log("Vectory: Embedder API not found. Please ensure the extension is installed and enabled.");
}- Main World Injection: Injects the
Embedderclass so it's accessible to the page's own JS. - Service Worker: Orchestrates model downloads and manages OPFS file handles.
- Offscreen Document: Runs the MediaPipe WASM runtime in a dedicated environment to keep the Service Worker lean and avoid memory constraints.
- Initial MVP with Universal Sentence Encoder (~6MB).
- Support for EmbeddingGemma.
- Multimodal support (Image Embeddings via MediaPipe)?
- Integrated similarity utilities (
Embedder.cosineSimilarity)?
Vectory is an exploratory project to accelerate product discovery for built-in web AI. We welcome feedback on use cases, the API surface, performance, etc.