Ternlight: 7MB embedding model that runs in-browser via WASM

Original: Ternlight – 7 MB embedding model that runs in browser (WASM)

Why This Matters

Client-side embedding models eliminate API costs and latency, enabling private, offline-capable semantic search in any web app.

Ternlight is a JavaScript embedding model weighing just 7MB (mini variant: 5MB) that runs entirely in the browser via WebAssembly. No API calls or GPU required — text embeddings are generated in ~5ms on CPU. Available as a single npm package with no model download step.

Ternlight is a lightweight semantic embedding model designed to run entirely client-side in modern browsers using WebAssembly (WASM). The base package weighs 7MB, with a mini variant at 5MB. Once loaded, it generates text embeddings in approximately 5ms using CPU alone, with no server or API calls required.

The library ships as a single npm package (@ternlight/base or @ternlight/mini) installable via `npm install @ternlight/base`. Its API is minimal: developers call `embed()` for a single embedding or `similar()` for ranked semantic search results, with a `topK` parameter to limit results. After the initial load, the engine and weights are cached, resulting in zero subsequent network requests.

The model architecture uses ternary (BitLinear) weights and a transformer-based design with linear layers. The demo showcases semantic search across React's official documentation, processing queries in the browser with no backend infrastructure. The project is MIT-licensed and openly available on npm and GitHub.

Source

ternlight-demo.vercel.app — Read original →