zeusdb-vector-database 0.0.9__cp310-cp310-macosx_11_0_arm64.whl → 0.1.0__cp310-cp310-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zeusdb_vector_database/__init__.py +1 -1
- zeusdb_vector_database/vector_database.py +63 -27
- zeusdb_vector_database/zeusdb_vector_database.cpython-310-darwin.so +0 -0
- {zeusdb_vector_database-0.0.9.dist-info → zeusdb_vector_database-0.1.0.dist-info}/METADATA +14 -12
- zeusdb_vector_database-0.1.0.dist-info/RECORD +9 -0
- zeusdb_vector_database-0.0.9.dist-info/RECORD +0 -9
- {zeusdb_vector_database-0.0.9.dist-info → zeusdb_vector_database-0.1.0.dist-info}/WHEEL +0 -0
- {zeusdb_vector_database-0.0.9.dist-info → zeusdb_vector_database-0.1.0.dist-info}/licenses/LICENSE +0 -0
- {zeusdb_vector_database-0.0.9.dist-info → zeusdb_vector_database-0.1.0.dist-info}/licenses/NOTICE +0 -0
@@ -1,50 +1,86 @@
|
|
1
1
|
"""
|
2
2
|
vector_database.py
|
3
3
|
|
4
|
-
|
5
|
-
Currently supports HNSW (Hierarchical Navigable Small World).
|
4
|
+
Factory for creating vector indexes with support for multiple types.
|
5
|
+
Currently supports HNSW (Hierarchical Navigable Small World) with extensible design.
|
6
6
|
"""
|
7
|
+
from typing import Callable, Dict, Any
|
7
8
|
from .zeusdb_vector_database import HNSWIndex
|
9
|
+
# from .zeusdb_vector_database import HNSWIndex, IVFIndex, LSHIndex, AnnoyIndex, FlatIndex # Future support planned
|
8
10
|
|
9
11
|
class VectorDatabase:
|
10
12
|
"""
|
11
|
-
|
12
|
-
|
13
|
+
Factory for creating various types of vector indexes.
|
14
|
+
Each index type is registered via _index_constructors.
|
13
15
|
"""
|
16
|
+
|
17
|
+
_index_constructors: Dict[str, Callable[..., Any]] = {
|
18
|
+
"hnsw": HNSWIndex,
|
19
|
+
# "ivf": IVFIndex, # Future support planned
|
20
|
+
# "lsh": LSHIndex, # Future support planned
|
21
|
+
# "annoy": AnnoyIndex, # Future support planned
|
22
|
+
# "flat": FlatIndex, # Future support planned
|
23
|
+
}
|
14
24
|
|
15
25
|
def __init__(self):
|
16
|
-
"""Initialize
|
26
|
+
"""Initialize the vector database factory."""
|
17
27
|
pass
|
18
28
|
|
19
|
-
def
|
20
|
-
self,
|
21
|
-
dim: int = 1536,
|
22
|
-
space: str = "cosine",
|
23
|
-
M: int = 16,
|
24
|
-
ef_construction: int = 200,
|
25
|
-
expected_size: int = 10000
|
26
|
-
) -> HNSWIndex:
|
29
|
+
def create(self, index_type: str = "hnsw", **kwargs) -> Any:
|
27
30
|
"""
|
28
|
-
|
31
|
+
Create a vector index of the specified type.
|
29
32
|
|
30
33
|
Args:
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
index_type: The type of index to create (case-insensitive: "hnsw", "ivf", etc.)
|
35
|
+
**kwargs: Parameters specific to the chosen index type (validated by Rust backend)
|
36
|
+
|
37
|
+
For "hnsw", supported parameters are:
|
38
|
+
- dim (int): Vector dimension (default: 1536)
|
39
|
+
- space (str): Distance metric — supports 'cosine', 'l2', or 'l1' (default: 'cosine')
|
40
|
+
- m (int): Bidirectional links per node (default: 16, max: 256)
|
41
|
+
- ef_construction (int): Construction candidate list size (default: 200)
|
42
|
+
- expected_size (int): Expected number of vectors (default: 10000)
|
36
43
|
|
37
44
|
Returns:
|
38
|
-
|
45
|
+
An instance of the created vector index.
|
39
46
|
|
40
|
-
|
47
|
+
Examples:
|
48
|
+
# HNSW index with defaults
|
41
49
|
vdb = VectorDatabase()
|
42
|
-
index = vdb.
|
43
|
-
|
44
|
-
|
50
|
+
index = vdb.create("hnsw", dim=1536)
|
51
|
+
|
52
|
+
# HNSW index with custom parameters
|
53
|
+
index = vdb.create("hnsw", dim=768, m=16, ef_construction=200, space="cosine", expected_size=10000)
|
54
|
+
|
55
|
+
# Future IVF index
|
56
|
+
# index = vdb.create("ivf", dim=1536, nlist=100, nprobe=10)
|
57
|
+
|
58
|
+
Raises:
|
59
|
+
ValueError: If index_type is not supported.
|
60
|
+
RuntimeError: If index creation fails due to backend validation.
|
45
61
|
"""
|
62
|
+
index_type = (index_type or "").strip().lower()
|
63
|
+
|
64
|
+
if index_type not in self._index_constructors:
|
65
|
+
available = ', '.join(sorted(self._index_constructors.keys()))
|
66
|
+
raise ValueError(f"Unknown index type '{index_type}'. Available: {available}")
|
67
|
+
|
68
|
+
# Apply index-specific defaults
|
69
|
+
if index_type == "hnsw":
|
70
|
+
kwargs.setdefault("dim", 1536)
|
71
|
+
kwargs.setdefault("space", "cosine")
|
72
|
+
kwargs.setdefault("m", 16)
|
73
|
+
kwargs.setdefault("ef_construction", 200)
|
74
|
+
kwargs.setdefault("expected_size", 10000)
|
75
|
+
|
76
|
+
constructor = self._index_constructors[index_type]
|
77
|
+
|
46
78
|
try:
|
47
|
-
return
|
79
|
+
return constructor(**kwargs)
|
48
80
|
except Exception as e:
|
49
|
-
raise RuntimeError(f"Failed to create
|
50
|
-
|
81
|
+
raise RuntimeError(f"Failed to create {index_type.upper()} index: {e}") from e
|
82
|
+
|
83
|
+
@classmethod
|
84
|
+
def available_index_types(cls) -> list[str]:
|
85
|
+
"""Return list of all supported index types."""
|
86
|
+
return sorted(cls._index_constructors.keys())
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: zeusdb-vector-database
|
3
|
-
Version: 0.0
|
3
|
+
Version: 0.1.0
|
4
4
|
Classifier: Programming Language :: Rust
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
6
6
|
Requires-Dist: numpy>=2.2.6,<3.0.0
|
@@ -124,7 +124,7 @@ from zeusdb_vector_database import VectorDatabase
|
|
124
124
|
vdb = VectorDatabase()
|
125
125
|
|
126
126
|
# Initialize and set up the database resources
|
127
|
-
index = vdb.
|
127
|
+
index = vdb.create(index_type="hnsw", dim=8)
|
128
128
|
|
129
129
|
# Vector embeddings with accompanying ID's and Metadata
|
130
130
|
records = [
|
@@ -175,11 +175,11 @@ ZeusDB Vector Database makes it easy to work with high-dimensional vector data u
|
|
175
175
|
|
176
176
|
**Three simple steps**
|
177
177
|
|
178
|
-
1. **Create an index**
|
179
|
-
2. **Add data
|
180
|
-
3. **Conduct a similarity search**
|
178
|
+
1. **Create an index** using `.create()`
|
179
|
+
2. **Add data** using `.add(...)`
|
180
|
+
3. **Conduct a similarity search** using `.search(...)`
|
181
181
|
|
182
|
-
Each step is covered below.
|
182
|
+
Each step is covered below.
|
183
183
|
|
184
184
|
<br/>
|
185
185
|
|
@@ -195,22 +195,24 @@ from zeusdb_vector_database import VectorDatabase
|
|
195
195
|
vdb = VectorDatabase()
|
196
196
|
|
197
197
|
# Initialize and set up the database resources
|
198
|
-
index = vdb.
|
198
|
+
index = vdb.create(
|
199
|
+
index_type = "hnsw",
|
199
200
|
dim = 8,
|
200
201
|
space = "cosine",
|
201
|
-
|
202
|
+
m = 16,
|
202
203
|
ef_construction = 200,
|
203
|
-
expected_size=5
|
204
|
+
expected_size = 5
|
204
205
|
)
|
205
206
|
```
|
206
207
|
|
207
|
-
#### 📘 `
|
208
|
+
#### 📘 `create()` Parameters
|
208
209
|
|
209
210
|
| Parameter | Type | Default | Description |
|
210
211
|
|------------------|--------|-----------|-----------------------------------------------------------------------------|
|
212
|
+
| `index_type` | `str` | `"hnsw"` | The type of vector index to create. Currently supports `"hnsw"`. Future options include `"ivf"`, `"flat"`, etc. Case-insensitive. |
|
211
213
|
| `dim` | `int` | `1536` | Dimensionality of the vectors to be indexed. Each vector must have this length. The default dim=1536 is chosen to match the output dimensionality of OpenAI’s text-embedding-ada-002 model. |
|
212
214
|
| `space` | `str` | `"cosine"`| Distance metric used for similarity search. Options include `"cosine"`. Additional metrics such as `"l2"`, and `"dot"` will be added in future versions. |
|
213
|
-
| `
|
215
|
+
| `m` | `int` | `16` | Number of bi-directional connections created for each new node. Higher `m` improves recall but increases index size and build time. |
|
214
216
|
| `ef_construction`| `int` | `200` | Size of the dynamic list used during index construction. Larger values increase indexing time and memory, but improve quality. |
|
215
217
|
| `expected_size` | `int` | `10000` | Estimated number of elements to be inserted. Used for preallocating internal data structures. Not a hard limit. |
|
216
218
|
|
@@ -393,7 +395,7 @@ print(index.info())
|
|
393
395
|
```
|
394
396
|
*Output*
|
395
397
|
```
|
396
|
-
HNSWIndex(dim=8, space=cosine,
|
398
|
+
HNSWIndex(dim=8, space=cosine, m=16, ef_construction=200, expected_size=5, vectors=5)
|
397
399
|
```
|
398
400
|
|
399
401
|
<br/>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
zeusdb_vector_database-0.1.0.dist-info/METADATA,sha256=TpOxVHETFf2PMjZVWwjxyV43ZJPIsuIqTmBmwCXfJGI,22218
|
2
|
+
zeusdb_vector_database-0.1.0.dist-info/WHEEL,sha256=KCCpmWLLQj9_-RHIFoo-pqx3tFzfg6Kma0cpWK8830E,104
|
3
|
+
zeusdb_vector_database-0.1.0.dist-info/licenses/LICENSE,sha256=82Hi3E_KqpDOBk00HrY6fGiErqL3QJquGQ6dUu9wJzE,11336
|
4
|
+
zeusdb_vector_database-0.1.0.dist-info/licenses/NOTICE,sha256=GDGZ9V3p4Uvaj-1RT9Pbeczps-rSeZz8q8wSxb_Q13o,971
|
5
|
+
zeusdb_vector_database/__init__.py,sha256=WANw_gobvA72v6z1tydjyWwRUvx01mnCjMX55LXbeic,202
|
6
|
+
zeusdb_vector_database/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
zeusdb_vector_database/vector_database.py,sha256=7Gs9FiasO5suqc3E8mxxtW1ORIXBh-8AXvp0pQo1VYc,3463
|
8
|
+
zeusdb_vector_database/zeusdb_vector_database.cpython-310-darwin.so,sha256=MS0ZM-5hDTqvAluScxhuQ9QFFuAGvuds8kR1jn1iysk,3810208
|
9
|
+
zeusdb_vector_database-0.1.0.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
zeusdb_vector_database-0.0.9.dist-info/METADATA,sha256=M8_KsB8EW0BjPjwilv8mSoXa0NCNbkTHvV7VPovx5U4,21994
|
2
|
-
zeusdb_vector_database-0.0.9.dist-info/WHEEL,sha256=KCCpmWLLQj9_-RHIFoo-pqx3tFzfg6Kma0cpWK8830E,104
|
3
|
-
zeusdb_vector_database-0.0.9.dist-info/licenses/LICENSE,sha256=82Hi3E_KqpDOBk00HrY6fGiErqL3QJquGQ6dUu9wJzE,11336
|
4
|
-
zeusdb_vector_database-0.0.9.dist-info/licenses/NOTICE,sha256=GDGZ9V3p4Uvaj-1RT9Pbeczps-rSeZz8q8wSxb_Q13o,971
|
5
|
-
zeusdb_vector_database/__init__.py,sha256=8nQKR99xrTRvMgH_Z2nNI4XtwkTAi5DmkjBxUxxeJho,202
|
6
|
-
zeusdb_vector_database/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
zeusdb_vector_database/vector_database.py,sha256=HmOjY7qOWfh0We-85qmfVmwoVSlM9zD-Hj1SvplMtF0,1621
|
8
|
-
zeusdb_vector_database/zeusdb_vector_database.cpython-310-darwin.so,sha256=S2YAyKFgGoiMXVbIWQLdLUowUlH9PO3TM4rhbLTYa7Q,3810208
|
9
|
-
zeusdb_vector_database-0.0.9.dist-info/RECORD,,
|
File without changes
|
{zeusdb_vector_database-0.0.9.dist-info → zeusdb_vector_database-0.1.0.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{zeusdb_vector_database-0.0.9.dist-info → zeusdb_vector_database-0.1.0.dist-info}/licenses/NOTICE
RENAMED
File without changes
|