Skip to content

pgvector/pgvector-erlang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pgvector-erlang

pgvector examples for Erlang

Supports epgsql

Build Status

Getting Started

Follow the instructions for your database library:

epgsql

Enable the extension

epgsql:equery(C, "CREATE EXTENSION IF NOT EXISTS vector"),

Create a table

epgsql:equery(C, "CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))"),

Insert vectors

epgsql:equery(C, "INSERT INTO items (embedding) VALUES ($1), ($2)", ["[1,2,3]", "[4,5,6]"]),

Get the nearest neighbors

epgsql:equery(C, "SELECT id FROM items ORDER BY embedding <-> $1 LIMIT 5", ["[3,1,2]"]),

Add an approximate index

epgsql:equery(C, "CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)"),
% or
epgsql:equery(C, "CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 100)"),

Use vector_ip_ops for inner product and vector_cosine_ops for cosine distance

See a full example

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/pgvector/pgvector-erlang.git
cd pgvector-erlang
createdb pgvector_erlang_test
rebar3 escriptize
_build/default/bin/example

About

pgvector examples for Erlang

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages