TL;DR
A new client-side semantic search engine has been developed that runs entirely in the browser using a 4 MB lookup table. This approach allows for understanding queries contextually, unlike traditional keyword searches.
✦ Why It Matters
Engineers can implement client-side semantic search in static sites using Transformers.js to enhance user experience.
Key Takeaways
Full Summary
Eight years ago, a keyword search was implemented on a blog using Lunr.js, which creates an inverted index for string matching. However, this method lacks semantic understanding, which was addressed by developing a semantic search engine in Python that requires heavy server resources.
The new solution utilizes Transformers.js to run a lightweight semantic model in the browser, significantly reducing the resource requirements to just 4 MB. Benchmarking showed that the model takes about two seconds to load and can embed queries in approximately 18 milliseconds.
This development not only fixes a long-standing bug in the keyword search but also demonstrates that semantic search can be effectively executed client-side. The implications are significant for static sites, enabling richer search experiences without server dependencies.
Related