Skip to content

pgvector/pgvector-prolog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pgvector-prolog

pgvector examples for Prolog

Supports postgresql-prolog

Build Status

Getting Started

Follow the instructions for your database library:

postgresql-prolog

Enable the extension

postgresql:query(Connection, "CREATE EXTENSION IF NOT EXISTS vector", ok)

Create a table

postgresql:query(Connection, "CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))", ok)

Insert vectors

postgresql:sql(Connection, [insert_into(items, [embedding]), values("[1,2,3]")], data([]))

Get the nearest neighbors

postgresql:query(Connection, "SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5", Rows)

Add an approximate index

postgresql:query(Connection, "CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)", ok)

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-prolog.git
cd pgvector-prolog
createdb pgvector_prolog_test
scryer-prolog example.pl -g "main,halt."

About

pgvector examples for Prolog

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages