Show HN: A fast HNSW implementation in Rust
github.com
github.com
https://gist.github.com/simonw/9ff9a0ab8ab64e8aa8d160c4294c0...
You don't have a license on the code yet (weirdly Claude hallucinated MIT).
Notes on how I generated this in the comments on that Gist.
I'm still on the free trial API plan, but at Opus price of $15 per million input tokens and $75 per million output tokens that comes to about 10.5 cents.
As far as HNSW implementations go, this one appears to be almost entirely unfinished. Node insertion logic is missing (https://github.com/swapneel/hnsw-rust/blob/b8ef946bd76112250...) and so is the base layer beam search.
Maybe it would be better to post this repository as a reference / teaching implementation of HNSW.
https://github.com/instant-labs/instant-distance
There are Python bindings, too:
- how much time to insert 15 millions of vectors of 768 f32?
- how much RAM needed for this operation?
- if inserting another vector, how incremental is the insertion? Is it faster than reindexing the 15M + 1 vectors from scratch?
- does the structure need to stay in RAM or can it be efficiently queried from a serialized représentation?
- how fast is the search in the 15M vectors on average?
Indexing time isn't great, but query time is surprisingly good for it being written in unoptimized python and numpy.
The loud part should be the thing that was built, not the thing it was built with.
That said, this is super cool. I have a project that I can definitely benefit from this. :)
tbf it's the headline of the Readme.
More generally I largely agree for software. I don't really agree for library code like this though... I actually care about what language a library is implemented in when I'm coding up a project that might use it.
FFI is generally very painful.