Repolode
pgvector

pgvector/pgvector-go

Go support for the pgvector PostgreSQL extension, with vector types and helpers for pgx, pg, Bun, Ent, GORM and sqlx.

Stars
356
Forks
16
Open issues
0
Last commit
2 days ago

What is it?

pgvector-go is a Go library that lets applications store and query vector embeddings in PostgreSQL through the pgvector extension. It provides Go types for dense vectors, half vectors and sparse vectors, along with adapters so these types work directly with pgx, pg, Bun, Ent, GORM and sqlx.

The library covers the common workflow: enabling the extension, defining a vector column, inserting embeddings, and running nearest-neighbor queries with distance operators such as L2, inner product and cosine. It also shows how to create HNSW or IVFFlat indexes for approximate search. Ent integration includes helpers for several distance functions.

Examples in the repository cover OpenAI and Cohere embeddings, hybrid search with Reciprocal Rank Fusion, sparse search, recommendations, Citus horizontal scaling and bulk loading with COPY.

Key features

  • 01Go types for dense, half and sparse vectors
  • 02Adapters for pgx, pg, Bun, Ent, GORM and sqlx
  • 03Nearest-neighbor queries with L2, inner product and cosine distance operators
  • 04HNSW and IVFFlat index creation examples
  • 05Examples for OpenAI, Cohere, hybrid search and bulk loading with COPY

Use cases

  • Adding semantic search or retrieval to a Go service backed by PostgreSQL
  • Storing text or image embeddings alongside relational data
  • Building recommendation features that rank items by vector similarity
  • Loading large embedding datasets into PostgreSQL efficiently

Quick start

  1. 1

    Install the core Go package

    go get github.com/pgvector/pgvector-go
  2. 2

    Install the pgx integration package

    go get github.com/pgvector/pgvector-go/pgx
  3. 3

    Enable the pgvector extension in PostgreSQL

    CREATE EXTENSION IF NOT EXISTS vector

Things to know

  • Requires PostgreSQL with the pgvector extension installed on the server.

In collections

Topics

FAQ

What is pgvector-go?
Go support for the pgvector PostgreSQL extension, with vector types and helpers for pgx, pg, Bun, Ent, GORM and sqlx. pgvector-go is a Go library that lets applications store and query vector embeddings in PostgreSQL through the pgvector extension. It provides Go types for dense vectors, half vectors and sparse vectors, along with adapters so these types work directly with pgx, pg, Bun, Ent, GORM and sqlx.
Is pgvector-go free to use? What license does it have?
pgvector-go is open source under the MIT license. Check the license terms before using it in commercial products.
Is pgvector-go still maintained?
Actively maintained. The last commit to pgvector-go was on Nov 5, 2026.
What can I use pgvector-go for?
Adding semantic search or retrieval to a Go service backed by PostgreSQL Storing text or image embeddings alongside relational data Building recommendation features that rank items by vector similarity Loading large embedding datasets into PostgreSQL efficiently
How do I install pgvector-go?
Install the core Go package: go get github.com/pgvector/pgvector-go Install the pgx integration package: go get github.com/pgvector/pgvector-go/pgx Enable the pgvector extension in PostgreSQL: CREATE EXTENSION IF NOT EXISTS vector
Where can I get pgvector-go?
The source code and installation instructions are on GitHub: https://github.com/pgvector/pgvector-go

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects