I opened a React docs search page and typed "how to skip a re-render." Results appeared before I finished typing. No loading spinner. No network request. The entire embedding model ran on my laptop's CPU, inside the browser tab, in 2.5 milliseconds.

That's Ternlight. A 7 MB WebAssembly bundle that turns text into 384-dimensional vectors without ever leaving the machine. No API key. No server. No GPU. Just your CPU churning through ternary weights while you type.

The project is a hobby build by a developer going by soycaporal, and it landed on Hacker News this week with a live demo that embeds all 2,000 React docs client-side. You can watch the embedding counter tick up in real time: 12 embeddings per second on a single CPU thread. The whole index takes about 6 seconds on first load, then it caches. After that, every search is sub-5ms. One HN commenter noted the demo auto-starts embedding on page load, which sent their laptop fans spinning. Fair point. A button to trigger it manually would be nice.

The trick is ternary quantization. Every weight in the model is one of three values: -1, 0, or +1. That means inference is just addition and subtraction, no floating-point multiplication needed. The developer distilled the model from MiniLM-L6-v2 (a sentence-transformers workhorse) using quantization-aware training, then hand-wrote a Rust inference engine compiled to WASM SIMD. The result is two tiers: @ternlight/base at 7 MB with 384-dimensional output (~5 ms per embed), and @ternlight/mini at 5 MB with 256-dimensional output (~2.5 ms per embed).

For context, gte-small (a popular open embedding model) scores about 61 on MTEB benchmarks. MiniLM-L6, Ternlight's teacher, scores around 56. Ternlight holds 0.84 Spearman fidelity to MiniLM, meaning it preserves most of the teacher's semantic understanding despite the aggressive quantization. The developer says head-to-head MTEB numbers are on the roadmap, and plans to distill gte-small as a teacher next.

Three lines of code gets you semantic search:

import { embed, similar } from '@ternlight/base';
similar('easy weeknight dinner ideas', recipes, { topK: 3 });
// → ranked matches, ~5 ms, zero network

The use cases that actually make sense: search-as-you-type on static sites, FAQ matching in browser extensions, Obsidian plugins that work offline, and privacy-first apps where queries never leave the device. A static Hugo or Astro blog could add semantic search without a backend at all. The model ships as a single npm package, no model download step, no runtime fetches. One HN user asked whether you could run a one-time server-side indexing pass and ship pre-computed embeddings to the frontend. The developer confirmed that works and is probably the right pattern for anything larger than a few hundred documents.

There are real limitations. Ternlight is not an LLM. It produces embeddings, not text. The 384-dimensional vectors are smaller than what larger models output, which means less semantic nuance for complex or ambiguous queries. And at 0.84 fidelity to MiniLM (which itself is not the best embedding model out there), the accuracy ceiling is lower than what you'd get from a 100MB+ model served via API. The model also maxes out input length at whatever the transformer's context window allows, so you cannot embed entire codebases in a single pass.

But that's not the point. The point is that 7 MB gets you something that previously required a $0.001-per-query API call and a server round-trip. For a class of applications where "good enough" semantic search is the goal, Ternlight eliminates the infrastructure entirely. The cost math changes too: embedding 10,000 documents via an API might cost $0.10. Ternlight costs nothing after the initial page load, and the user's CPU does the work.

The developer's roadmap includes distilling gte-small as a teacher model (which would close the quality gap significantly), STS-B and MTEB benchmark numbers, and potentially a WebGPU backend for GPU-accelerated inference. The training pipeline is included in the repo, so anyone can reproduce or modify the distillation process.

What I find interesting is the pattern: ternary weights, Rust-to-WASM, single-file deployment. This is not just an embedding model. It is a template for how to ship small neural networks to browsers. The same approach works for classification, reranking, or any task where a compact model can replace an API call. The 1-bit quantization research from Microsoft's BitNet paper made this theoretically possible. Ternlight is one of the first projects to actually ship it as a developer tool.

Pareto chart showing Ternlight's size vs quality tradeoff against other embedding models

Sources