from vectoylite.core import VectoyLite
= VectoyLite("another-demo") db
vectoylite
Utility/Quickstart for sqlite-vec.
The goal of this project is to offer a simple way to get started with SQLite-vec. With this project you can:
- automatically install the right version of sqlite to run sqlite-vec
- not worry about SQL, just use a simple Python API
It also comes with some settings that you can turn on/off:
- add a cache to detect/prevent duplicates
- turn the embeddings into their binary variants
- add the non-vector data as json into a cache as well
Install
If that sounds interesting, you can install this project via pip
.f
pip install vectoylite
How to use
Before running anything it is good to observe that we are running modern versions of everything.
db.print_version()
sqlite_version=3.46.1, vec_version=v0.1.1
VectoLite uses
pysqlite3
under the hood to install the most recent version of sqlite, which should be compatible withsqlite-vec
right out of the box. There may be edge cases, but we have not hit our head sofar.
Now that we have confirmed the version, lets move on to do some basic vector retreival.
# Examples just for illustrative purposes.
= [
items 'i': 1, 'vector':[0.1, 0.1, 0.1, 0.1]},
{'i': 2, 'vector':[0.2, 0.2, 0.2, 0.2]},
{'i': 3, 'vector':[0.3, 0.3, 0.3, 0.3]},
{'i': 4, 'vector':[0.4, 0.4, 0.4, 0.4]},
{'i': 5, 'vector':[0.5, 0.5, 0.5, 0.5]},
{
]
# Query these examples
= [0.3, 0.3, 0.3, 0.3]
query
db.insert(items)
# View the output
= db.query(query, k=3)
results, distances for res, d in zip(results, distances):
print(res, d)
{'i': 2} 0.0
{'i': 3} 0.19999998807907104
{'i': 1} 0.20000001788139343
At the moment of making this document there is no support for indexes just yet, but folks are working on that.