Skip to main content

Vector Database Lite (VDBLITE)

Vector Database Lite (like SQLITE but for vector search)

To discuss VDBLITE and ask general questions, use https://github.com/daveshap/VDBLITE/discussions

Quickstart

  1. Install using pip install vdblite
  2. Run a test with the following code:
import vdblite
from time import time
from uuid import uuid4
import sys
from pprint import pprint as pp


if __name__ == '__main__':
    vdb = vdblite.Vdb()
    dimension = 12    # dimensions of each vector                         
    n = 200    # number of vectors                   
    np.random.seed(1)             
    db_vectors = np.random.random((n, dimension)).astype('float32')
    print(db_vectors[0])
    for vector in db_vectors:
        info = {'vector': vector, 'time': time(), 'uuid': str(uuid4())}
        vdb.add(info)
    vdb.details()
    results = vdb.search(db_vectors[10])
    pp(results)

Class Vdb Methods

Vdb.add(payload)

# add a dictionary
info = dict()
vdb.add(info)
# or a list of dictionaries
info = list()
vdb.add(info)

Add a an arbitrary number of records to self.data (master list of data) of your Vdb object. No checks are performed beyond data type.

payload

Payload must be either a list or dict variable type. For instance:

info = {
	'time': 123.456789,
	'vector': [0.1, 0.1, 0.1, 0.1, 0.1],
	'uuid': '174657a5-ba76-47a8-a121-5fda05dde560',
	'content': 'lorem ipsum...',
}

or

info = [
	{'...'},
	{'...'},
	{'...'},
]

Vdb.delete(field, value, firstonly=False)

# delete all records with timestamp at UNIX time of 123.456789
vdb.delete('timestamp', 123.456789, False)

Delete record(s) with fields that match a given value

field

Specify which element within each record to match for deletion

value

Specify value to be matched for deletion

firstonly

Optional. False by default. Will delete all records with fields that match value. Set to True if you only want to delete a single record

Vdb.search(vector, field='vector', count=5)

results = vdb.search([1.0, 0.0], 'vector', 5)

Search for n number of records that are most similar to vector (cosine similarity). Specify field if searching any other field than vector.

vector

1-dimensional numpy array to match your query. Performs cosine similarity against all vectors in self.data

field='vector'

Optional. Specify which field contains the vector for comparison. Records can contain more than one vector. For instance you may have vectors of different dimensionality, or from different models for different purposes.

count=5

Optional. Specify number of matches to return.

Vdb.bound(field, lower_bound, upper_bound)

results = vdb.bound('time', 123.456789, 987.654321)

Return all records with field value between lower_bound and upper_bound e.g. all records with a timestamp between two specific values.

field

Specify which field to compare in all records.

lower_bound

Minimum threshold to return.

upper_bound

Maximum threshold to return.

Vdb.purge()

Delete self.data from memory and reinstantiate.

Vdb.save(filepath)

vdb.save('my_data.vdb')

Save VDB data to file

filepath

Relative or absolute filepath of save file

Vdb.load(filepath)

vdb = Vdb()
vdb.load('my_data.vdb')

Load saved VDB data into memory

filepath

Relative or absolute filepath of save file

Release files for vdblite 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vdblite 0.1.4
File Size Uploaded
vdblite-0.1.4.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vdblite 0.1.4
File Interpreter ABI Platform
vdblite-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / vdblite-0.1.4.tar.gz

Download URL vdblite-0.1.4.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2f941ca19c56c13ec1769c73489923c6aabe9bf2dbf14b453072d0dbb1d3d0d2
BLAKE2b-256 checksum
How to use checksums
a45b3b5cd3f39e911236bf44dd9ea8c54393c7ea344d5da26fb09d3c3c1ea4f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / vdblite-0.1.4-py3-none-any.whl

Download URL vdblite-0.1.4-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ab9783552fc2a0a7efc1e8f860f0cda64d39eb8916e0a7da65e0d745094dd39
BLAKE2b-256 checksum
How to use checksums
b6d64a1703ca2abf35f56199c96cf6d15d132b387ffbce5b114e03f564c0a63a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page