pgvector/pgvector-python
pgvector support for Python
What it solves
It provides Python support for the pgvector PostgreSQL extension, allowing developers to store, query, and index vector embeddings directly within a PostgreSQL database using popular Python database libraries.
How it works
The library integrates with various Python ORMs and database drivers, enabling the use of vector types and distance operators. It supports multiple vector formats including standard vectors, half-precision vectors, bit vectors, and sparse vectors. It also allows for the creation of approximate nearest neighbor (ANN) indexes like HNSW and IVFFlat to speed up searches.
Who it’s for
Python developers who are using PostgreSQL as a vector database for AI applications such as retrieval-augmented generation (RAG), image search, and recommendation systems.
Highlights
- Broad Library Support: Integrates with Django, SQLAlchemy, SQLModel, Psycopg 3, Psycopg 2, asyncpg, pg8000, and Peewee.
- Multiple Vector Types: Supports
Vector,HalfVector,Bit, andSparseVectorfor different precision and storage needs. - Multiple Distance Metrics: Supports L2 distance, cosine distance, inner product, L1 distance, Hamming distance, and Jaccard distance.
- Indexing Options: Provides easy Python-native ways to create HNSW and IVFFlat indexes.
- Comprehensive Examples: Includes implementations for RAG, hybrid search, ColBERT, and visual document retrieval.
Related
- Project
- Project
- Project
- Project