by jasonjmcghee · 1y ago · 0 comments
ONNX models can be loaded and executed with transformer.js https://github.com/huggingface/transformers.js/
You can even build and statically host indices like hnsw for embeddings.
I put together a little open source demo for this here https://jasonjmcghee.github.io/portable-hnsw/ (it's a prototype / hacked together approximation of hnsw, but you could implement the real thing)
Long story short, represent indices as queryable parquet files and use duckdb to query them.
Depending on how you host, it's either free or nearly free. I used Github Pages so it's free. R2 with cloudflare would only cost the size what you store (very cheap- no egress fees).
Parquet and Polars are definitely on my radar, though, after reading this: https://minimaxir.com/2025/02/embeddings-parquet/
To render locally, you need access to the model right? I just wonder how good those embeddings will be compared to those from OpenAI/Google/etc in terms of semantic search. I do like the free/instant aspect though
I've had a particularly good experiences with nomic, bge, gte, and all-MiniLM-L6-v2. All are hundreds of MB (except all-minilm which is like 87MB)
My go to right now is on ollama: snowflake-arctic-embed2
Try like "I'm scared" or "running fast" - whatever you want, and the results will be of passages that are semantically similar.
---
It's an embedding search using heirarchical navigable small worlds.
I chunked up a few corpora of text (books, blogs, etc) and embedded them and indexed them.
But the indexing strategy split things into a nodes parquet file and an edges parquet file, so that they could be served from a cdn and searched client side. (No running vector database)