logoalt Hacker News

Hierarchical Navigable Small World (HNSW) in PHP

81 pointsby centamivyesterday at 3:48 PM15 commentsview on HN

Comments

centamivyesterday at 3:48 PM

OP here. I wrote this implementation to deeply understand the mechanics behind HNSW (layers, entry points, neighbor selection) without relying on external libraries. While PHP isn't the typical choice for vector search engines, I found it surprisingly capable for this use case, especially with JIT enabled on PHP 8.x. It serves as a drop-in solution for PHP monoliths that need semantic search features without adding the complexity of a separate service like Qdrant or Pinecone. If you want to jump straight to the code, the open-source repo is here: https://github.com/centamiv/vektor Happy to answer any questions about the implementation details!

show 5 replies
rvnxyesterday at 5:42 PM

Cool blog post, smart guy, very thoughtful and not a copy-paste of Python code like 99% of folks. Nice to see

show 1 reply
fithisuxyesterday at 5:08 PM

It makes perfect sense to implement it in a high level language that allows understandability.

Very good contribution.

show 1 reply
syntaxgoonootoday at 12:44 AM

[dead]