Favicon of pgvector

pgvector

A Postgres extension for self-hosted vector search on Linux, macOS and Windows, with exact matching and HNSW or IVFFlat indexes.

pgvector adds vector storage and similarity search to Postgres, so developers can keep embeddings alongside application records in a self-hosted database. It suits applications that need to find similar items while retaining SQL queries, joins and transactional guarantees. It runs on Linux, macOS and Windows, with Docker also supported.

The main reason to choose it is the database integration. Vector queries can use ordinary relational filters, and applications can access them through any language with a Postgres client. Vectors live in the Postgres database you choose to run, which can be on your own hardware or with a hosted Postgres provider that includes the extension.

Exact nearest neighbor search is the default. For larger collections, HNSW and IVFFlat indexes trade some recall for faster searches. HNSW offers a better balance of query speed and recall, but takes longer to build and uses more memory. IVFFlat builds faster and needs less memory. Iterative index scans can search further when filters leave too few matches.

pgvector accepts single-precision, half-precision, binary and sparse vectors. Distance measures include cosine distance, inner product, L2 and L1, plus Hamming and Jaccard for binary vectors. Half-precision indexing and binary quantization can reduce index size. Indexes don't have to fit entirely in memory.

Postgres handles bulk loading, vector updates and grouped averages. Its write-ahead log also supports replication and point-in-time recovery for vector data.

Similar to pgvector