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

Appearance settings

pgvector/pgvector-racket

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pgvector-racket

pgvector examples for Racket

Supports db

Build Status

Getting Started

Follow the instructions for your database library:

db

Enable the extension

(query-exec conn "CREATE EXTENSION IF NOT EXISTS vector")

Create a table

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

Insert vectors

(query-exec conn "INSERT INTO items (embedding) VALUES ($1::text::vector)" "[1,2,3]")

Get the nearest neighbors

(query-rows conn "SELECT id FROM items ORDER BY embedding <-> $1::text::vector LIMIT 5" "[3,1,2]")

Add an approximate index

(query-exec conn "CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)")

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-racket.git
cd pgvector-racket
createdb pgvector_racket_test
raco pkg install db-lib
racket example.rkt

About

pgvector examples for Racket

Resources

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.