A wrapper to use sqlite-vec, a SQLite extension for working with vectors, in Elixir. The configured version of the precompiled loadable library will be downloaded from the GitHub releases. Moreover, this package provides structs and custom Ecto types for working with Float32, Int8, and Bit vectors.
- it's currently not possible to create int8 and bit vectors using
Ecto
. You must directly use SQL to do so - not implemented operations:
vec_each
,vec_quantize_i8
The package can be installed by adding sqlite_vec
to your list of dependencies in mix.exs
:
def deps do
[
{:sqlite_vec, "~> 0.1.0"}
]
end
SqliteVec.path/0
returns the path of the downloaded library.
Therefore, you can load the extension using this path.
For instance with Exqlite
:
{:ok, conn} = Basic.open(":memory:")
:ok = Basic.enable_load_extension(conn)
Basic.load_extension(conn, SqliteVec.path())
Or, with SQLite
configured as Ecto.Repo
:
defmodule MyApp.Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Ecto.Adapters.SQLite3
end
config :my_app, MyApp.Repo, load_extensions: [SqliteVec.path()]
You can check out the Getting Started and Usage with Ecto notebooks.
Special thanks to these projects that helped to make this package:
- OctoFetch which does all the work for downloading the GitHub releases, and served as a blueprint for this package (yes, including this Attribution section :) )
- sqlite-vec, of course, which provides all of the functionality
- pgvector provides something similar for postgres and quite some code could be reused