Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pgvector examples for D

License

NotificationsYou must be signed in to change notification settings

pgvector/pgvector-d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pgvector examples for D

Supportsdpq2

Build Status

Getting Started

Follow the instructions for your database library:

Or check out some examples:

dpq2

Enable the extension

conn.exec("CREATE EXTENSION IF NOT EXISTS vector");

Create a table

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

Insert vectors

QueryParams p;p.sqlCommand ="INSERT INTO items (embedding) VALUES ($1::vector), ($2::vector)";p.argsVariadic([1,2,3], [4,5,6]);conn.execParams(p);

Get the nearest neighbors

QueryParams p;p.sqlCommand ="SELECT * FROM items ORDER BY embedding <-> $1::vector LIMIT 5";p.argsVariadic([3,1,2]);p.resultFormat = ValueFormat.TEXT;auto result = conn.execParams(p);foreach (row; rangify(result)){    writeln(row);}

Add an approximate index

conn.exec("CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)");// orconn.exec("CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 100)");

Usevector_ip_ops for inner product andvector_cosine_ops for cosine distance

See afull 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-d.gitcd pgvector-dcreatedb pgvector_d_testdub run

Specify the path to libpq if needed:

DFLAGS="-L-L/opt/homebrew/opt/libpq/lib" dub run

To run an example:

cd examples/openaicreatedb pgvector_exampledub run

About

pgvector examples for D

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp