Skip to content

Add PhpVectorStore — zero-dependency local vector store#519

Open
MauricioPerera wants to merge 1 commit intoneuron-core:3.xfrom
MauricioPerera:feature/php-vector-store
Open

Add PhpVectorStore — zero-dependency local vector store#519
MauricioPerera wants to merge 1 commit intoneuron-core:3.xfrom
MauricioPerera:feature/php-vector-store

Conversation

@MauricioPerera
Copy link

Summary

Adds PhpVectorStore as a new VectorStoreInterface implementation — the first zero-dependency local vector store option for Neuron AI.

Uses php-vector-store, a pure PHP vector database with:

  • Binary Float32/Int8 storage — 392 bytes per 384d vector (4x smaller than JSON)
  • Matryoshka multi-stage search — 3-5x faster via progressive 128d→256d→384d stages
  • No external services — no Pinecone, no Qdrant, no Docker, no C extensions
  • 100% recall on real embeddings (benchmarked with EmbeddingGemma-300m)
  • Scales to ~500K vectors on a VPS with 512MB RAM

Why

All current vector store implementations require either external services (Pinecone, Qdrant, Chroma, Elasticsearch) or are ephemeral (MemoryVectorStore). PhpVectorStore fills the gap: persistent, local, zero-config.

Store Dependencies Persistent Local Storage/vec (384d)
PhpVectorStore None Yes Yes 392 B
MemoryVectorStore None No Yes ~3 KB (lost on restart)
FileVectorStore None Yes Yes ~7 KB (JSON)
PineconeVectorStore API key + network Yes No Cloud
QdrantVectorStore Docker/server Yes No Server

Usage

class MyRAG extends RAG
{
    protected function vectorStore(): VectorStoreInterface
    {
        return new PhpVectorStore(
            directory:  __DIR__ . '/vectors',
            dimensions: 384,           // Matryoshka: truncate to 384d
            quantized:  true,          // Int8: 4x smaller
            matryoshka: true,          // Multi-stage search: 3-5x faster
        );
    }
}

Installation

composer require mauricioperera/php-vector-store

Test plan

  • Verify addDocument / addDocuments store vectors to disk
  • Verify similaritySearch returns Documents with correct scores
  • Verify deleteBy filters by sourceType/sourceName
  • Test with existing RAG examples (swap MemoryVectorStore for PhpVectorStore)
  • Verify persistence: restart PHP, vectors still searchable

🤖 Generated with Claude Code

Pure PHP vector store using binary Float32/Int8 storage with Matryoshka
multi-stage search. No external services, no C extensions, no SQLite.

- Int8 quantization: 392 bytes per 384d vector (4x compression)
- Matryoshka search: 3-5x faster via 128d→256d→384d progressive stages
- Binary .bin + .json files (no database needed)
- 100% recall on real embeddings (benchmarked with EmbeddingGemma-300m)
- Scales to ~500K vectors on 512MB RAM

Usage:
  protected function vectorStore(): VectorStoreInterface {
      return new PhpVectorStore(__DIR__ . '/vectors', dimensions: 384);
  }

Requires: composer require mauricioperera/php-vector-store
See: https://github.com/MauricioPerera/php-vector-store
@ilvalerione
Copy link
Contributor

ilvalerione commented Mar 22, 2026

I think this should be a dedicated composer package published on https://neuronhub.dev so we can also share it with the community using our communication channels.

Or since the Neuron integration requires no more than one class, you could include it in the default lib in a dedicated namespace, adding Neuron ^2|^3 as a dev and suggested dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants