r/reactjs • u/paimeg • Jun 21 '26
Show /r/reactjs I built a semantic search LLM that runs entirely in a React app. 7MB, rust on webAssembly (open source, demo inside)
Search-by-meaning (not just keyword/substring matching) usually needs backend or an embedding API. I wanted to see how far client-side could go, so I built a tiny LLM that ships inside your bundle and runs entirely in browser.
Where I think it could be useful:
• search-as-you-type with no backend
• docs/site search on static sites (Astro, Next, etc.)
• edge functions and workers
Specs: 7 MB single bundle (model + tokenizer + engine, one .wasm) ~2ms per query in-browser
See demo: semantic search over 2,000 React docs, fully on-device → https://ternlight-demo.vercel.app
Also see evaluation leaderboard in similar class of models: https://agentx-ray.aurumnebula.com/embed-board.html
This is a hobby project that I plan to open source, no npm package yet, but the engine works end to end. Curious what you'd actually use client-side semantic search for?
7
u/Yodiddlyyo Jun 21 '26
Is this an actual LLM, or is it an embeddings model?
2
u/Vincent_CWS Jun 22 '26
how can I get this model
2
u/Mr-Bovine_Joni I ❤️ hooks! 😈 Jun 22 '26
This seems super interesting, would love an update as you release it publicly!
2
u/Dave6ev Jun 22 '26
I am really interested in this, how many records can it deal with, and how does it build the index? For context, I have about 100k multi column db, but they are relatively small, say <1k text per record.
The speed and the fact it's offline fits my use case really well.
2
u/redbar0n- Oct 02 '26
The issue is that the results feel pretty random (the titles may not match the search text directly or implicitly/semantically) and titles that match directly (word for word) are ranked lower than irrelevant search results, judging by the titles.
I think what is needed is search result highlighting: what words matched the semantic search query precisely. Also: I imagine the search works by matching towards a vector computed from the entire document? But what you typically want is to only semantically match words or phrases in the target document. Like searching for "pizza" and matching "Domino's", in a sentence like "Let's pick up a slice of Domino's".
Is this currently possible, or feasible, for such a model?
1
u/Thisisvexx Jun 21 '26
Can you try this with the Chrome builtin LLM global? Chrome ships with some mini gemma model since a month ago
1
u/BlackBrownJesus Jun 21 '26
I’m super interested to see the code!! Currently trying to solve an issue that I would love to try out and see if this tool can help with it
1
u/souljorje Jun 22 '26
Wow, that’s impressive!
FYI GitHub link on the demo leads to 404: https://github.com/soycaporal/ternlight
1
u/Mundane-Reply-9939 Jun 22 '26
Wow this is really cool! Can’t wait to see more info