HNHacker News
TopNewBestAskShowJobs

centamiv

47 karma · joined October 24, 2025

Writing code and articles about Modern PHP, LLMs, and Software Architecture. Based in Italy.

Code: github.com/centamiv - Web: centamori.com - X: @centamiv (Italian content)

submissionscomments
centamiv··on [dead]
This article explores the conceptual and technical bridge between PHP's dynamic memory and C's static types via FFI. Features a practical implementation of the Sieve algorithm with a detailed look at the System V AMD64 ABI contract and how to handle pointers without memory leaks.
centamiv··on Hierarchical Navigable Small World (HNSW) in PHP
You are absolutely right. I will update the README with some examples, thanks for the feedback!
centamiv··on Hierarchical Navigable Small World (HNSW) in PHP
I'm really glad you liked the article! Thanks so much for reading the previous one too, I really appreciate it.
centamiv··on Hierarchical Navigable Small World (HNSW) in PHP
Thanks for checking out the other posts too! I wasn't familiar with the term 'Locality of Behavior' until recently, but it perfectly captures what I strive for: readability and simplicity.
centamiv··on Hierarchical Navigable Small World (HNSW) in PHP
Thank you, really appreciate that
centamiv··on Hierarchical Navigable Small World (HNSW) in PHP
Apologies if it felt that way! I used OpenAI in the examples just because it's the quickest 'Hello World' for embeddings right now, but the library itself is completely agnostic.

HNSW is just the indexing algorithm. It doesn't care where the vectors come from. You can generate them using Ollama (locally) HuggingFace, Gemini...

As long as you feed it an array of floats, it will index it. The dependency on OpenAI is purely in the example code, not in the engine logic.

centamiv··on Hierarchical Navigable Small World (HNSW) in PHP
I tested it myself with 1k documents (about 1.5M vectors) and performance is solid (a few milliseconds per search). I haven't run more aggressive benchmarks yet.

Since it only stores the vectors, the actual size of the Markdown document is irrelevant; you just need to handle the embedding and chunking phases carefully (you can use a parser to extract code snippets).

RAM isn't an issue because I aim for random data access as much as possible. This avoids saturating PHP, since it wasn't exactly built for this kind of workload.

I'm glad you found the article and repo useful! If you use it and run into any problems, feel free to open an issue on GitHub.

centamiv··on Hierarchical Navigable Small World (HNSW) in PHP
Thank you! That was exactly the goal. Modern PHP turned out to be surprisingly expressive for this kind of 'executable pseudocode'. Glad you appreciated it!
centamiv··on Hierarchical Navigable Small World (HNSW) in PHP
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!
centamiv··on "Fireball" vs. "Make it go boom": Building a Semantic Search for D&D
Hi HN,

I wrote a short post demonstrating how vector search works by building a D&D spell finder.

Instead of using a vector DB immediately, I implemented the cosine similarity math manually in PHP to demystify how embeddings actually work under the hood.

The code compares query vectors against a JSON dataset of spells to find matches by intent rather than keywords.