Add approximate nearest neighbor infrastructure to vec0: shared distance dispatch (vec0_distance_full), flat index type with parser, NEON-optimized cosine/Hamming for float32/int8, amalgamation script, and benchmark suite (benchmarks-ann/) with ground-truth generation and profiling tools. Remove unused vec_npy_each/vec_static_blobs code, fix missing stdint.h include.
2.6 KiB
Compiling sqlite-vec
sqlite-vec is is easy to compile yourself! It's a single C file with no dependencies, so the process should be straightforward.
From Source
To compile sqlite-vec as a loadable SQLite extension, you can git clone the source repository and run the following commands:
git clone https://github.com/asg017/sqlite-vec
cd sqlite-vec
./scripts/vendor.sh
make loadable
The ./scripts/vendor.sh command will download a recent version of SQLite's amalgammation builds, to ensure you have an up-to-date sqlite3ext.h available on your system.
Then make loadable will generate the sqlite-vec.h file and a dynamically loadable library at dist/vec.$SUFFIX. The suffix will be .dylib for MacOS, .so for Linux, and .dll for Windows.
From the amalgamation build
The "amalgamation" build of sqlite-vec is a .zip or .tar.gz archive with the pre-configured sqlite-vec.c and sqlite-vec.h source files.
The amalgamation builds can be found in sqlite-vec Releases. You can also download the latest amalgamation build with this command:
wget https://github.com/asg017/sqlite-vec/releases/download/v{{data.VERSION}}/sqlite-vec-{{data.VERSION}}-amalgamation.zip
unzip sqlite-vec-{{data.VERSION}}-amalgamation.zip
There will now be sqlite-vec.c and sqlite-vec.h available in your current directory. To compile it manually, follow the official SQLite extension compilation instructions, which will be something like:
# Linux
gcc -g -fPIC -shared sqlite-vec.c -o vec0.so
# MacOS
gcc -g -fPIC -dynamiclib sqlite-vec.c -o vec0.dylib
# Windows, MSVC compiler
cl sqlite-vec.c -link -dll -out:sqlite-vec.dll
# Windows, MinGW
gcc -g -shared sqlite-vec.c -o vec0.dll
Different platforms, compiler, or architectures may require different compilation flags.
Compile-time options
There are a few compilation options available for sqlite-vec, but they're currently unstable and may change in the future. They aren't tracked with sqlite-vec's semantic versioning policy , so options may break in patch version updates.
The current compile-time flags are:
SQLITE_VEC_ENABLE_AVX, enables AVX CPU instructions for some vector search operationsSQLITE_VEC_ENABLE_NEON, enables NEON CPU instructions for some vector search operationsSQLITE_VEC_STATIC, meant for statically linkingsqlite-vec