SQLite Gets Into Vector Search
Written by Nikos Vaggalis   
Thursday, 05 September 2024

This is thanks to sqlite-vec, a new vector search extension for SQLite written entirely in C and with no dependencies.

Vendors are eager to add vector search to their dbms products.
One prominent example is Postgres with pg_vector which we covered in "Turn PostgreSQL Into A Vector Store" and more recently Mariadb as examined in "MariaDB Introduces Vector Search". This begs the question of what's the rush for adding vetor support?

This is because vector search gets AI and LLMs one step closer to the database by providing relevant, contextual information to the LLM workflows. 

In the simplest of terms, a vector or embedding takes a chunk of text and creates a numerical representation of that text, so that text with similar content will have similar vectors in this numeric space.

What that means is that we can then compare those vectors and find pieces of text that are similar. Of course there's need for an optimized backend to store those vectors , hence pg_vector, the extension for PostgreSQL that renders it as a viable alternative to specialized vector stores like ChromaDB.

MariaDB on the other hand adds vector search not as an extension but directly into its core part of the native syntax.

Now and not far behind comes SQLite. Although there already was a vector search extension, that of sqlite-vss by the same author of sqlite-vec, he wrote sqlite-vec as a replacement of the former because it was not optimized enough and facing issues with:

  • Only worked on Linux + MacOS machines (no Windows, WASM, mobile devices, etc. )
  • Stored vectors all in-memory
  • Various transaction-related bugs and issues
  • Extremely hard and time-consuming to compile
  • Missing common vector operations (scalar/binary quantization)

In contrast the new counterpart is a no-dependency SQLite extension, it is written entirely in a single C file and is extremely portable working on most operating systems and environments, as in working on MacOS, Linux, Windows, Android, Raspberry Pis and other small devices, and in the browser through WebAssembly! That aside it's also MIT/Apache-2 dual licensed.

Installation wise You have several options to include it into your projects, including PyPi packages for Python, NPM packages for Node. js, Gems for Ruby, and more.
For instance:

For instance, to use sqlite-vec from Python, install the sqlite-vec PyPi package using your favorite Python package manager:

pip install sqlite-vec

and once installed, use the sqlite_vec.load() function to load sqlite-vec SQL functions into a SQLite connection.

Alternatively you can load it inside a SQLite instance for using it under raw sql:

Magic. Caveat only that the current version only supports brute force/exhaustive full-scan vector search and no "approximate nearest neighbors" (ANN) options by means of HNSW Index Storage.

Fear not however since that support is on the tool's roadmap, which looks paved rich with opportunities for achievement since quite recently SQLite Cloud announced that they sponsor the development of the extension sqlite-vec to enable for privacy-first mobile GenAI Applications.

The future looks bright!

sqlite

More Information

sqlite-vec

Sponsoring sqlite-vec for privacy-first mobile GenAI Applications

Related Articles

Turn PostgreSQL Into A Vector Store

MariaDB Introduces Vector Search

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


AI Propels Python To Top Language on GitHub
30/10/2024

This year's Octoverse Report reveals how AI is expanding on GitHub and that Python has now overtaken JavaScript as the most popular language on GitHub. The use of Jupyter Notebooks has also surged.



Ai-Da's Portrait of Alan Turing At Auction
01/11/2024

Sotheby's Digital Art Day Action, now underway, features a large-scale portrait of  Alan Turing created by Ai-Da, the humanoid robot artist whose work, including this canvas, was exhibited at the [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Thursday, 05 September 2024 )