soycaporal · 2026-07-05 · notable
Ternlight — 7 MB embedding model that runs in the browser
Ternlight is a 7 MB sentence-embedding model distilled from MiniLM with ternary quantization-aware training. It runs on CPU in the browser via WebAssembly, holds 0.844 Spearman fidelity to its teacher, and needs no API.
A 7 MB sentence-embedding model that runs in the browser at ~5 ms per query, with no API call.
Key specs
| Parameters | 7 MB |
|---|---|
| Latency | ~5 ms |
| Spearman fidelity | 0.844 |
What is it?
Ternlight is a compact text-embedding model that turns any short text into a 384-dimensional vector for semantic search, FAQ matching, and clustering. Distilled from all-MiniLM-L6 with ternary quantization-aware training, the base variant ships as a 7 MB WebAssembly bundle and the mini variant as 5 MB. Everything runs on CPU with no server or API involved.
How does it work?
The Ternlight model uses ternary weights — each parameter is -1, 0, or +1 — following the BitNet b1.58 recipe, then packs the model, tokenizer, and inference engine into one WASM binary and uses SIMD for the matrix math. The published numbers show 0.844 Spearman correlation to the MiniLM teacher for the base model and 0.820 for the mini, at roughly 5 ms and 2.5 ms per embedding respectively.
Why does it matter?
Small enough to ship inside a static site, Ternlight makes on-device semantic search practical without an inference service, an API bill, or a network round-trip. Because ternary weights compress the model by roughly 30× versus fp16, developers get sub-10-millisecond embeddings on the client CPU with a bundle small enough to cache once and reuse offline.
Who is it for?
Frontend developers, static-site owners, and anyone shipping search or FAQ features who wants embeddings without an API.
Try it
npm i @ternlight/base