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

278 points · 60 comments on HN · read original →

Points and comments are a snapshot, not live.

Ternlight is a 7 MB on-device embedding model for semantic search, running in browsers via WASM.

Ternlight is a 7 MB embedding model (5 MB mini variant) that runs entirely in the browser via WASM SIMD, with no server or API calls. It produces 384-dim vectors from text at ~5 ms per embedding. Available as an npm package (@ternlight/base and @ternlight/mini), it ships with engine and weights, no separate download step. A demo search of React docs runs fully on-device. The model uses ternary quantization-aware training distilled from MiniLM, achieving 0.84 Spearman fidelity to the teacher.

What commenters are saying

The creator explained it is a hobby project distilling MiniLM with ternary quantization-aware training, writing the inference engine from scratch in Rust → WASM SIMD. Commenters praised the small size, on-device capability, and open-source release including training code. Some reported performance issues: one user got only 35 embeddings/sec in Firefox on an i5-4570 vs claimed 400/sec. Another noted the demo auto-starts, causing fan noise. Comparisons to bge-small-en-v1.5 and gte-small were raised. The creator confirmed QAT is responsible for fidelity, not post-training quantization.