Tiny Vector Database
A lightweight vector database designed for small projects.
Features
- Just-in-time (JIT) compiling to optimize vector operations by setting the vector size at compile time.
- Accelerates vector operations using Eigen.
- Processes vectors using only Python lists, no need for any additional third-party data formats.
- Stores vectors as base-64 encoded strings in a SQLite database.
Performance
More than 10x Faster than numpy-based vector operations.
Development Status
It is currently compatible with g++ or clang++.
You may need to modify compile_config parameter in VectorDatabase initialization to inject your compile commands.
To make it work with other compiler, you may need to change tiny_vectordb.jit module.
Installation
pip install tiny_vectordb
Good to go!
Uninstallation (before version 0.1.11)
Uninstallation
Previous to version 0.1.11, the package will emit some compiled files in the source directory, which may not be automatically removed using pip uninstall, so you need to run the following command manually if you want to uninstall the package comletely.
(After 0.1.11, you can also use the following command to clean up the cache files.)
python -c "import tiny_vectordb; tiny_vectordb.cleanup()"
After that, you can safely uninstall the package with:
pip uninstall tiny_vectordb
Usage:
from tiny_vectordb import VectorDatabase
collection_configs = [
{
"name": "hello",
"dimension": 256,
},
{
"name": "world",
"dimension": 1000,
}
]
database = VectorDatabase("test.db", collection_configs)
collection = database["hello"]
# add vectors
collection.setBlock(
["id1", "id2"], # ids
[[1] * 256, [2] * 256] # vectors
)
# search for nearest vectors
search_ids, search_scores = collection.search([1.9] * 256)
For more usage, see example.py.
Designing Note:
-
No numpy array is used in the database, because I want it to be as lightweight as possible, and lists of numbers are eaiser to be converted into json for communication with http requests.
-
The data are always stored in contiguous memory to ensure the best searching performance.
So the addition and deletion are preferred to be done in batches as they envolve memory reallocation.
Here are some useful functions for batch operations:
class VectorCollection(Generic[NumVar]):
def addBlock(self, ids: list[str], vectors: list[list[NumVar]]) -> None:
def setBlock(self, ids: list[str], vectors: list[list[NumVar]]) -> None:
def deleteBlock(self, ids: list[str]) -> None:
def getBlock(self, ids: list[str]) -> list[list[NumVar]]:
Metadata
Release files for tiny-vectordb 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tiny_vectordb-0.1.11.tar.gz | 22.1 kB | Without provenance | Details |
Release files / tiny_vectordb-0.1.11.tar.gz
| Download URL | tiny_vectordb-0.1.11.tar.gz |
|---|---|
| Size | 22.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
578e01a67224c08702e706f6b3734df197f1fa701010e54f56663a16fd707eb1
|
|
BLAKE2b-256 checksum How to use checksums |
518db24db4510a0efafbbd07279d1dc0074fc00d9a619b53edcd9a91e0b66ff1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.10.5
|
Security for tiny-vectordb 0.1.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.