Nothing Special   »   [go: up one dir, main page]

Skip to content

🚧 WIP 🚧 Vector database plugin for Postgres, written in Rust

License

Notifications You must be signed in to change notification settings

skyzh/pgvecto.rs

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

pgvecto.rs

discord invitation link trackgit-views all-contributors

pgvecto.rs is a Postgres extension that provides vector similarity search functions. It is written in Rust and based on pgrx.

Features

  • cosine_distance: cosine distance
  • dot_product_distance: dot product distance
  • square_euclidean_distance: square Euclidean distance

Build from source

cargo install cargo-pgrx
cargo pgrx init
cargo pgrx run

Getting Started

-- install the extension
DROP EXTENSION IF EXISTS vectors;
CREATE EXTENSION vectors;
-- check the extension related functions
\df+

-- call the distance function through operators

-- square Euclidean distance
SELECT array[1, 2, 3] <-> array[3, 2, 1];
-- dot product distance
SELECT array[1, 2, 3] <#> array[3, 2, 1];
-- cosine distance
SELECT array[1, 2, 3] <=> array[3, 2, 1];

-- create table
CREATE TABLE items (id bigserial PRIMARY KEY, emb numeric[]);
-- insert values
INSERT INTO items (emb) VALUES (ARRAY[1,2,3]), (ARRAY[4,5,6]);
-- query the similar embeddings
SELECT * FROM items ORDER BY emb <-> ARRAY[3,2,1] LIMIT 5;
-- query the neighbors within a certain distance
SELECT * FROM items WHERE emb <-> ARRAY[3,2,1] < 5;

Roadmap

See the open issues

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Ce Gao
Ce Gao

πŸ’Ό πŸ–‹ πŸ“–
Keming
Keming

πŸ› πŸ’» πŸ“– πŸ€” πŸš‡
Jinjing Zhou
Jinjing Zhou

🎨 πŸ€” πŸ“†
Add your contributions

This project follows the all-contributors specification. Contributions of any kind welcome!

Acknowledgements

Thanks to the following projects:

  • pgrx - Postgres extension framework in Rust
  • pgvector - Postgres extension for vector similarity search written in C

About

🚧 WIP 🚧 Vector database plugin for Postgres, written in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%