# Locus
Locus is a local, simple, in-memory vector database.
Why Locus?
* Easy to use
* 2 dependencies
* Store database locally
## Installation
Soon
## Example Code
Some example code to illustrate Locus' functionality.
``` python
import numpy as np
from locus 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(results)
# store the index on disk
index._store_on_disk()
# load the index from disk
new_index = Index.from_file(config.storage_location)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/the-alex-b/Locus",
"name": "locus-db",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Alex",
"author_email": "46456279+the-alex-b@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/83/be/8c10c3e423ada426f3ac5c976821243824de70da3a6e0d89687c989f53df/locus_db-0.1.0.tar.gz",
"platform": null,
"description": "# Locus\nLocus is a local, simple, in-memory vector database.\n\nWhy Locus?\n* Easy to use\n* 2 dependencies\n* Store database locally\n\n\n## Installation\nSoon\n\n## Example Code\nSome example code to illustrate Locus' functionality.\n\n``` python\nimport numpy as np\nfrom locus import Config, Vector, Index\n\n# create a new configuration\nconfig = Config(max_elements=1000, ef_construction=200, M=16, dim=128, space=\"cosine\", storage_location=\"index.db\")\n\n# create a new index instance\nindex = Index(dimensions=config.dim, config=config)\n\n# create some random vectors\nvectors = []\nfor i in range(10):\n embedding = np.random.randn(config.dim)\n data = {\"id\": i, \"message\": f\"test message {i}\"}\n vector = Vector(embedding=embedding, data=data)\n vectors.append(vector)\n\n# add the vectors to the index\nfor vector in vectors:\n index.add_vector(vector)\n\n# retrieve the closest vectors to a query embedding\nquery_embedding = np.random.randn(config.dim)\nresults = index.retrieve(query_embedding, number_of_results=3)\nprint(results)\n\n# store the index on disk\nindex._store_on_disk()\n\n# load the index from disk\nnew_index = Index.from_file(config.storage_location)\n```\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Local, in-memory vector database",
"version": "0.1.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "adf23d4ba44683d626b1bd5ed34a97613873df49849dd07c4aac8c81d362e162",
"md5": "0cafcc4c2516e279325273048f905243",
"sha256": "6217901c602b9a5f548ee30326ed367fb7c60a207a14fa2c6f5d75f3fe5bf04f"
},
"downloads": -1,
"filename": "locus_db-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0cafcc4c2516e279325273048f905243",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 8203,
"upload_time": "2023-04-19T18:40:39",
"upload_time_iso_8601": "2023-04-19T18:40:39.020729Z",
"url": "https://files.pythonhosted.org/packages/ad/f2/3d4ba44683d626b1bd5ed34a97613873df49849dd07c4aac8c81d362e162/locus_db-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "83be8c10c3e423ada426f3ac5c976821243824de70da3a6e0d89687c989f53df",
"md5": "2414493a952d8edd056a2b3788c8e7c8",
"sha256": "455c91fe9778a004254ff8b1aa054e9c6d49530bdf4433862f73b0d803bfe000"
},
"downloads": -1,
"filename": "locus_db-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "2414493a952d8edd056a2b3788c8e7c8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 7081,
"upload_time": "2023-04-19T18:40:41",
"upload_time_iso_8601": "2023-04-19T18:40:41.874087Z",
"url": "https://files.pythonhosted.org/packages/83/be/8c10c3e423ada426f3ac5c976821243824de70da3a6e0d89687c989f53df/locus_db-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-19 18:40:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "the-alex-b",
"github_project": "Locus",
"lcname": "locus-db"
}