Locus
Locus is a local, simple, append-only, in-memory vector database based on hnswlib.
Installation
pip install locusdb
Example Code
Some example code to illustrate Locus' functionality.
import numpy as np
from locusdb import Config, Vector, Index
# create a new configuration
config = Config(max_elements=1000, ef_construction=200, M=16, dim=128, space="cosine", storage_location="index.db")
# create a new index instance
index = Index(dimensions=config.dim, config=config)
# create some random vectors
vectors = []
for i in range(10):
embedding = np.random.randn(config.dim)
data = {"id": i, "message": f"test message {i}"}
vector = Vector(embedding=embedding, data=data)
vectors.append(vector)
# add the vectors to the index
for vector in vectors:
index.add_vector(vector)
# retrieve the closest vectors to a query embedding
query_embedding = np.random.randn(config.dim)
results = index.retrieve(query_embedding, number_of_results=3)
print(f"Matches: {results}")
print(f"Items in index: {index.count}")
# store the index on disk
index._store_on_disk()
# load the index from disk
new_index = Index.from_file(config.storage_location)
Release files for locusdb 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| locusdb-0.3.0.tar.gz | 7.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| locusdb-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.7 kB
Release files / locusdb-0.3.0.tar.gz
| Download URL | locusdb-0.3.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6dd1aa70c17d7c446b22738a385573afe9078753839fd8ccfcb9760e81f2ea3
|
|
BLAKE2b-256 checksum How to use checksums |
e3a2be03cf4263a95fad8d90dc343732fc517c00913dee940c623e62cc2fb446
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.11 Linux/5.15.0-1036-azure
|
Release files / locusdb-0.3.0-py3-none-any.whl
| Download URL | locusdb-0.3.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc6392ae8f4c165765a46c3eedb600f28438e96c754d93a6ed93693eb575afbc
|
|
BLAKE2b-256 checksum How to use checksums |
3468cf5e459da454d173d93818e501e0800122331a7a14f221dfd000ed1b3619
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.11 Linux/5.15.0-1036-azure
|