pgvector-go  by pgvector

Go SDK for pgvector, enabling vector storage in Postgres

created 4 years ago
271 stars

Top 95.8% on sourcepulse

GitHubView on GitHub
Project Summary

This Go library provides seamless integration with the pgvector PostgreSQL extension, enabling developers to efficiently store, query, and index vector embeddings directly within their PostgreSQL databases. It targets Go developers building applications that require similarity search, recommendation systems, or other AI-driven features leveraging vector data.

How It Works

The library acts as a Go driver and ORM integration layer for pgvector. It serializes Go data structures (slices of float32) into the vector or halfvec types understood by the PostgreSQL extension. It also provides methods to construct SQL queries for vector operations like nearest neighbor search (<->) and index creation (HNSW, IVFFlat), abstracting away the underlying PostgreSQL data types and functions.

Quick Start & Requirements

  • Install: go get github.com/pgvector/pgvector-go
  • Prerequisites: PostgreSQL with the pgvector extension enabled.
  • Examples and detailed integration guides for pgx, pg, Bun, Ent, GORM, and sqlx are available in the README.

Highlighted Details

  • Supports multiple popular Go database libraries: pgx, pg, Bun, Ent, GORM, sqlx.
  • Enables creation of approximate nearest neighbor (ANN) indexes using HNSW and IVFFlat.
  • Provides utilities for creating and manipulating vector types: Vector, HalfVector, and SparseVector.
  • Includes examples for common use cases like embeddings with OpenAI, hybrid search, and recommendations.

Maintenance & Community

The project is actively maintained by the pgvector team. Contributions are welcomed, with clear guidelines for reporting bugs, fixing issues, and suggesting new features. Development setup instructions and testing procedures are provided.

Licensing & Compatibility

The library is released under the MIT License, permitting commercial use and integration with closed-source applications.

Limitations & Caveats

The library relies on the pgvector PostgreSQL extension being installed and enabled in the target database. Specific vector dimensions must be declared when creating tables.

Health Check
Last commit

1 day ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
33 stars in the last 90 days

Explore Similar Projects

Starred by Jared Palmer Jared Palmer(Ex-VP of AI at Vercel; Founder of Turborepo; Author of Formik, TSDX).

pgvector-node by pgvector

0.8%
399
Node.js library for pgvector support
created 4 years ago
updated 2 weeks ago
Feedback? Help us improve.