Skip to content

pgvector/pgvector-ada

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pgvector-ada

pgvector examples for Ada

Supports GNATcoll

Build Status

Getting Started

Follow the instructions for your database library:

GNATcoll

Enable the extension

DB.Execute ("CREATE EXTENSION IF NOT EXISTS vector");

Create a table

DB.Execute ("CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))");

Insert vectors

DB.Execute ("INSERT INTO items (embedding) VALUES ($1), ($2)", Params => (1 => +"[1,2,3]", 2 => +"[4,5,6]"));

Get the nearest neighbors

R.Fetch (DB, "SELECT * FROM items ORDER BY embedding <-> $1 LIMIT 5", Params => (1 => +"[3,1,2]"));
while Has_Row (R) loop
   Put_Line (Value (R, 0));
   Next (R);
end loop;

Add an approximate index

DB.Execute ("CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)");
-- or
DB.Execute ("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-ada.git
cd pgvector-ada
createdb pgvector_ada_test
alr run

About

pgvector examples for Ada

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages