- Notifications
You must be signed in to change notification settings - Fork0
pgvector support for Haskell
License
NotificationsYou must be signed in to change notification settings
pgvector/pgvector-haskell
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
pgvector support for Haskell
Supportspostgresql-simple
Add this line to your application’s.cabal
file underbuild-depends
:
pgvector >= 0.1 && < 0.2
And follow the instructions for your database library:
Import the library
importPgvector
Enable the extension
execute_ conn"CREATE EXTENSION IF NOT EXISTS vector"
Create a table
execute_ conn"CREATE TABLE items (embedding vector(3))"
Insert a vector
execute conn"INSERT INTO items (embedding) VALUES (?)" [Vector [1,1,1]]
Get the nearest neighbors
let q="SELECT embedding FROM items ORDER BY embedding <-> ? LIMIT 5"forEach conn q [Vector [1,1,1]]$\(Only embedding)->putStrLn$show (embedding::Vector)
Add an approximate index
execute_ conn"CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)"-- orexecute_ conn"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
View thechangelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs andsubmit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/pgvector/pgvector-haskell.gitcd pgvector-haskellcreatedb pgvector_haskell_testcabaltest
About
pgvector support for Haskell
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.