Menu

pgvector in Laravel: 3,072-Dimension Embeddings, a halfvec HNSW Index, and the Query That Never Used It
📰

pgvector in Laravel: 3,072-Dimension Embeddings, a halfvec HNSW Index, and the Query That Never Used It

DEV Community: laravel·Touhidun Nabi Sarkar·2 days ago
#NjcNJE0t
#devtolaravel#devto#dev#index#halfvec
Long article (1347 words) — no AI summary yet.
Reading 0:00
15s threshold

An AI assistant drafted this article from my project. The code, the EXPLAIN output and the design decisions come from that project, and every snippet was checked against it.

I'm building a multi-tenant AI receptionist on Laravel 13 and PostgreSQL. Every business uploads its own files: price lists, FAQs, policies. We split them into chunks, embed each chunk, and the AI agent searches them when a customer asks a question.

The search taught me three things. The most embarrassing one: my vector index had never been used.

1. 3,072 dimensions don't fit in a vector index

Our embeddings have 3,072 dimensions. That's the default size of both Gemini's gemini-embedding-001 and OpenAI's text-embedding-3-large. The column itself is no problem:

$table -> vector ( 'embedding' , 3072 ) -> nullable ( ) ;

Enter fullscreen mode

Exit fullscreen mode

The index is. pgvector can index the vector type only up to 2,000 dimensions, with HNSW and IVFFlat alike.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.