GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - pgvector/pgvector-d: pgvector examples for D

BranchesTags
Open more actions menu

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
examples
examples
 
 
source
source
 
 
.gitignore
.gitignore
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
dub.json
dub.json
 
 

Repository files navigation

pgvector-d

pgvector examples for D

Supports dpq2

Build Status

Getting Started

Follow the instructions for your database library:

  • dpq2

Or check out some examples:

  • Embeddings with OpenAI
  • Binary embeddings with Cohere
  • Hybrid search with Ollama (Reciprocal Rank Fusion)
  • Sparse search with Text Embeddings Inference

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)");
// or
conn.exec("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:

  • Report bugs
  • Fix bugs and submit pull requests
  • Write, clarify, or fix documentation
  • Suggest or add new features

To get started with development:

git clone https://github.com/pgvector/pgvector-d.git
cd pgvector-d
createdb pgvector_d_test
dub run

Specify the path to libpq if needed:

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

To run an example:

cd examples/openai
createdb pgvector_example
dub run

About

pgvector examples for D

Resources

Readme
MIT license

Security policy

Security policy
Activity
Custom properties

Stars

2 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.