A vector search SQLite extension that runs anywhere!
Find a file
Alex Garcia 6875f7649c typo
2024-06-12 10:45:59 -07:00
.github light/dark modes 2024-06-12 00:23:45 -07:00
benchmarks micro benchmarks work 2024-06-11 23:57:46 -07:00
bindings fixup rust bindings 2024-05-10 21:13:18 -07:00
examples try out static blobs feature behind SQLITE_VEC_ENABLE_EXPERIMENTAL 2024-05-17 12:03:45 -07:00
scripts try out static blobs feature behind SQLITE_VEC_ENABLE_EXPERIMENTAL 2024-05-17 12:03:45 -07:00
site site updates + sponsors 2024-06-12 00:02:27 -07:00
tests int8 vec from text (#17) 2024-06-08 11:50:10 -07:00
.gitignore readme updates 2024-06-12 00:08:53 -07:00
LICENSE-APACHE add licenses 2024-05-10 22:42:10 -07:00
LICENSE-MIT add licenses 2024-05-10 22:42:10 -07:00
Makefile sqlite-vec.h dep on cli 2024-05-23 11:27:15 -07:00
README.md typo 2024-06-12 10:45:59 -07:00
reference.yaml wasm tests and fixes 2024-04-27 12:05:50 -07:00
sqlite-dist.toml upgrade dist 2024-05-10 21:05:52 -07:00
sqlite-vec.c Always Use Neon for L2 f32 (#20) 2024-06-10 11:56:42 -07:00
sqlite-vec.h.tmpl fix msvc build (#14) 2024-06-08 23:53:12 -07:00
tmp-static.py try out static blobs feature behind SQLITE_VEC_ENABLE_EXPERIMENTAL 2024-05-17 12:03:45 -07:00
VERSION v0.0.1-alpha.10 2024-05-21 14:55:18 -07:00

sqlite-vec

An extremely small, "fast enough" vector search SQLite extension that runs anywhere! A successor to sqlite-vss

Important

sqlite-vec is a work-in-progress and not ready for general usage! I plan to launch a "beta" version in the next month or so. Watch this repo for updates, and read this blog post for more info.

  • Store and query float, int8, and binary vectors in vec0 virtual tables
  • Pre-filter vectors with rowid IN (...) subqueries
  • Written in pure C, no dependencies, runs anywhere SQLite runs (Linux/MacOS/Windows, in the browser with WASM, Raspberry Pis, etc.)

sqlite-vec is a Mozilla Builders project, with additional sponsorship from Fly.io , Turso, and SQLite Cloud. See the Sponsors section for more details.

Sample usage

.load ./vec0

create virtual table vec_examples using vec0(
  sample_embedding float[8]
);

-- vectors can be provided as JSON or in a compact binary format
insert into vec_examples(rowid, sample_embedding)
  values
    (1, '[-0.200, 0.250, 0.341, -0.211, 0.645, 0.935, -0.316, -0.924]'),
    (2, '[0.443, -0.501, 0.355, -0.771, 0.707, -0.708, -0.185, 0.362]'),
    (3, '[0.716, -0.927, 0.134, 0.052, -0.669, 0.793, -0.634, -0.162]'),
    (4, '[-0.710, 0.330, 0.656, 0.041, -0.990, 0.726, 0.385, -0.958]');


-- KNN style query goes brrrr
select
  rowid,
  distance
from vec_examples
where sample_embedding match '[0.890, 0.544, 0.825, 0.961, 0.358, 0.0196, 0.521, 0.175]'
order by distance
limit 2;
/*
┌───────┬──────────────────┐
│ rowid │     distance     │
├───────┼──────────────────┤
│ 2     │ 2.38687372207642 │
│ 1     │ 2.38978505134583 │
└───────┴──────────────────┘
*/

Roadmap

Not currently implemented, but planned in the future (after initial v0.1.0 version):

  • Approximate nearest neighbors search (DiskANN, IVF, maybe HNSW?)
  • Metadata filtering + custom internal partitioning
  • More vector types (float16, int16, sparse, etc.) and distance functions

Additionally, there will be pre-compiled and pre-packaged packages of sqlite-vec for the following platforms:

  • pip for Python
  • npm for Node.js / Deno / Bun
  • gem for Ruby
  • cargo for Rust
  • A single .c and .h amalgammation for C/C++
  • Go module for Golang (requires CGO)
  • Datasette and sqlite-utils plugins
  • Pre-compiled loadable extensions on Github releases

Sponsors

Development of sqlite-vec is supported by multiple generous sponsors! Mozilla is the main sponsor through the new Builders project.

sqlite-vec is also sponsored by the following companies:

logo of Fly.io logo of Turso logo of SQLite Cloud

As well as multiple individual supporters on Github sponsors!

If your company interested in sponsoring sqlite-vec development, send me an email to get more info: https://alexgarcia.xyz

See Also

  • sqlite-ecosystem, Maybe more 3rd party SQLite extensions I've developed
  • sqlite-rembed, Generate text embeddings from remote APIs like OpenAI/Nomic/Ollama, meant for testing and SQL scripts
  • sqlite-lembed, Generate text embeddings locally from embedding models in the .gguf format