HNHacker News
TopNewBestAskShowJobs

soycaporal

157 karma · joined July 6, 2026

AI/ML Engineering, software engineering, hustler in general. All things AI and tech.
submissionscomments
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
mainly this is a portability and compatibility solution.. I think with GPU available deployments, it wouldn't benefit from ternary distillation. It would be a different problem domain.
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
amazing.. glad to know this integration path worked fro you!
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
very cool, I'll look into this. Thanks for sharing.
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
the base model I clocked it at 5 ms per embedded on my mac studio. There is a mini variant (the demo version) that is sub - 2 ms. It could be a SIMD issue.. I'll look into this for better runtime support (also fee free to file an issue)
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
super cool use case! Hopefully it can provide quality embeddings + retrieval. Would love to learn to results/issues or feedback. Please feel free to file for issues on github
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
The corpus is mainly trained in english, unfortunately no other languages have been included in the distillation training. Yes it would work like fuse.js, but unlocks semantic search.

Source code has the entire embedding distillation pipeline includes dataset preparation. You could run the same distillation training (but not sure if teacher model used a multi-language dataset).

Open up an issue on the github repo and I can reply with details

soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
awesome, noted, looking for capable teacher models to distill other architectures
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
that's great! let me know if there is anyway I can support, or any specific use case a roadmap could address!
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
It's entirely the QAT. The whole distillation process is quantization-aware from the start, so the ternary weights are learned rather than fitted after the fact.

The only post-training quantization I applied was int4 on the embedding layer, and I ran a small ablation there to find the sweet spot between size and quality.

soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
CPU cycle maxxing, who said GPUs were special?
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
thank you! hopefully it can unlock some novel applications, that would be cool
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
ohh thanks for the report.. probably has to do with wasm runtime.. Will note this as a known issue
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
love the idea! Will think of a way to host it probably on huggingface
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
I think standardizing the runtime is pretty effective, it then open up portability
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
gte-small outscores all-MiniLM-L6 on MTEB (~61 vs ~56 avg per the GTE paper). MiniLM is ternlight's teacher (ternlight holds 0.84 Spearman fidelity to teacher). I haven't run a head-to-head yet; STS-B/MTEB numbers are on the roadmap. Also on the roadmap is to distill gte-small as teacher.
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
yes, you could run a 1 time indexing run on the server side, and just ship the embeddings to frontend
soycaporal··on Ternlight – 7 MB embedding model that runs in browser (WASM)
Hobby project, I wanted to "ship a useful model in a web browser". so I distilled a small sentence encoder from MiniLM with ternary quantization-aware training. Also wrote the inference engine from scratch and shipped in Rust → WASM SIMD.

It's an embeddings model, not an LLM: text goes in, a 384-dim vector comes out, and cosine similarity between two vectors tells you how related the texts are — regardless of shared words ("reset my password" ↔ "I forgot my password" → 0.88). Used for semantic search, FAQ/intent matching, and clustering. Running it on-device means search-as-you-type semantic search is performant with no API dependencies.

Demo (2k React docs, fully on-device): https://ternlight-demo.vercel.app

Two tiers on npm: - @ternlight/base (7 MB, ~5 ms/embed, more capable embedings) - @ternlight/mini (5 MB wire, ~2.5 ms/embed).

Bundled for Node and browsers.

Repo - see technical details (MIT, training pipeline included): https://github.com/soycaporal/ternlight

Curious if this is something useful, what are the use cases for on-device embeddings.