vink 0.1.0a1__tar.gz

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.

Potentially problematic release.


This version of vink might be problematic. Click here for more details.

vink-0.1.0a1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Speed K
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
vink-0.1.0a1/PKG-INFO ADDED
@@ -0,0 +1,408 @@
1
+ Metadata-Version: 2.4
2
+ Name: vink
3
+ Version: 0.1.0a1
4
+ Summary: Vector Incremental Nano Kit β€” a lightweight vector database with incremental inserts, automatic exact-to-ANN switching, and explicit storage management. Add vectors anytime without rebuilding the index
5
+ Author-email: speedyk_005 <speedy40115719@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/speedyk-005/vink
8
+ Project-URL: Repository, https://github.com/speedyk-005/vink
9
+ Keywords: vector-database,ann,approximate-nearest-neighbor,similarity-search,embedding-vectors,semantic-search,rag,retrieval-augmented-generation,llm,generative-ai,product-quantization,vector-search,ai,information-retrieval,knowledge-base
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: pybind11<4.0,>=3.0
25
+ Requires-Dist: rii<1.0,>=0.2.12
26
+ Requires-Dist: readerwriterlock<2.0,>=1.0.9
27
+ Requires-Dist: pysqlite3<0.7,>=0.6
28
+ Requires-Dist: pydantic<3.0,>=2.12.2
29
+ Requires-Dist: uuid6>=2025.0.0; python_version < "3.14"
30
+ Requires-Dist: loguru<1.0,>=0.7.3
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=8.3.5; extra == "dev"
33
+ Requires-Dist: pytest-cov>=6.2.1; extra == "dev"
34
+ Requires-Dist: pytest-mock>=3.14.1; extra == "dev"
35
+ Requires-Dist: pytest-rerunfailures>=15.0; extra == "dev"
36
+ Requires-Dist: ruff>=0.14.14; extra == "dev"
37
+ Requires-Dist: python-docstring-markdown>=0.4.0; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # 🐦 Vink
41
+
42
+ <p align="center">
43
+ <img src="https://github.com/speedyk-005/vink/blob/main/vink_logo.png?raw=true" alt="Vink Logo" width="300"/>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <b>V</b>ector <b>In</b>cremental <b>N</b>ano <b>K</b>it
48
+ </p>
49
+ <p align="center">
50
+ β€œVector DB that self-organize. Auto-switch, Auto-tune, Auto-scale.”
51
+ </p>
52
+
53
+ [![Python Version](https://img.shields.io/badge/Python-3.9%20--%203.14-blue)](https://www.python.org/downloads/)
54
+ [![PyPI](https://img.shields.io/pypi/v/vink)](https://pypi.org/project/vink)
55
+ [![CodeFactor](https://www.codefactor.io/repository/github/speedyk-005/vink/badge)](https://www.codefactor.io/repository/github/speedyk-005/vink)
56
+ [![Coverage Status](https://coveralls.io/repos/github/speedyk-005/vink/badge.svg?branch=main)](https://coveralls.io/github/speedyk-005/vink?branch=main)
57
+ [![Stability](https://img.shields.io/badge/stability-pre--alpha-yellow)](https://github.com/speedyk-005/vink)
58
+ [![Tests](https://img.shields.io/badge/tests-passing-brightgreen)](https://github.com/speedyk-005/vink/actions)
59
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
60
+
61
+ > [!WARNING]
62
+ > This project is currently in pre-alpha.
63
+
64
+ ---
65
+
66
+ ## Table of Contents
67
+
68
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
69
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
70
+ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
71
+
72
+ - [πŸ€” So What's vink Anyway? (And Why Should You Care?)](#-so-whats-vink-anyway-and-why-should-you-care)
73
+ - [πŸ“¦ Installation](#-installation)
74
+ - [The Quick & Easy Way](#the-quick--easy-way)
75
+ - [The From-Source Way](#the-from-source-way)
76
+ - [βœ… Proof It Works](#-proof-it-works)
77
+ - [πŸš€ Usage](#-usage)
78
+ - [Initialization (VinkDB API)](#initialization-vinkdb-api)
79
+ - [AnnConfig (API)](#annconfig-api)
80
+ - [Add (API)](#add-api)
81
+ - [With embedding callback](#with-embedding-callback)
82
+ - [Without callback](#without-callback)
83
+ - [Search (API)](#search-api)
84
+ - [Without filters](#without-filters)
85
+ - [With filters](#with-filters)
86
+ - [Delete](#delete)
87
+ - [Soft deletion (API)](#soft-deletion-api)
88
+ - [Compaction (API)](#compaction-api)
89
+ - [Stats (API)](#stats-api)
90
+ - [🚨 Exceptions (API)](#-exceptions-api)
91
+ - [πŸ—Ί Features & Roadmap](#-features--roadmap)
92
+ - [πŸ”§ Core Dependencies](#-core-dependencies)
93
+ - [🀝 Contributing](#-contributing)
94
+ - [πŸ“œ License](#-license)
95
+
96
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
97
+
98
+ ---
99
+
100
+ ## πŸ€” So What's vink Anyway? (And Why Should You Care?)
101
+
102
+ Most vector databases force a trade-off: you either over-engineer for small datasets or hit a performance cliff as you scale. You’re left babysitting indices, manually tuning parameters, and praying your hardware can keep up.
103
+
104
+ **Vink** eliminates the guesswork. It automatically switches from **Exact Search** (for 100% precision) to **ANN** (for massive scale with IVF-PQ) based on dataset size and runtime latency. Whether you are running on a mobile device or a high-end server, Vink adapts its optimization strategy to your hardware and data distribution.
105
+
106
+ | Feature | Why it's awesome |
107
+ | :--- | :--- |
108
+ | βž• **Incremental Inserts** | Add vectors anytime. Your index grows with your data, not against it. |
109
+ | πŸ“Ÿ **Hardware-Aware Auto-Switch** | It figures out when to ditch exact search and switch to ANN based on latency prediction. |
110
+ | βš™οΈ **Self-Tuning Engine** | Background reconfiguration keeps clusters fresh as your data evolves. |
111
+ | 🎯 **Production-Ready Search** | Filtered searches, soft deletes, compact, dual-metric (Euclidean + cosine). |
112
+ | πŸ’Ύ **Explicit Storage** | Disk or memory β€” you control where your data lives. |
113
+
114
+ Unlike enterprise solutions (Milvus, Pinecone) that require complex Docker or cloud setup, Vink runs entirely local β€” zero dependencies beyond pip install.
115
+
116
+ And that's just the start - there's plenty more to explore!
117
+
118
+ ---
119
+
120
+ ## πŸ“¦ Installation
121
+
122
+ First ensure that you have the necessary system dependencies installed.
123
+
124
+ - **Linux only**:
125
+ Required for building [rii](https://github.com/matsui528/rii)
126
+
127
+ ```bash
128
+ # Debian/Ubuntu
129
+ sudo apt-get install python3-dev
130
+
131
+ # RedHat/Fedora/CentOS
132
+ sudo dnf install python3-devel -y
133
+
134
+ # CentOS 7 and older
135
+ sudo yum install python3-devel
136
+ ```
137
+
138
+ - **Android/Termux**:
139
+
140
+ ```bash
141
+ pkg install -y tur-repo
142
+ pkg install python-scipy
143
+ ```
144
+
145
+ ### The Quick & Easy Way
146
+
147
+ The simplest way to get started is with pip:
148
+
149
+ ```bash
150
+ pip install vink
151
+ ```
152
+
153
+ ### The From-Source Way
154
+
155
+ Prefer building from source? You can clone and install manually for full control:
156
+
157
+ ```bash
158
+ git clone https://github.com/speedyk-005/vink.git
159
+ cd vink
160
+ pip install -e .
161
+ ```
162
+
163
+ (But honestly, the pip way is usually way easier!)
164
+
165
+ ---
166
+
167
+ ## βœ… Proof It Works
168
+
169
+ Run the demo to see auto-switch in action:
170
+
171
+ ```bash
172
+ # Install and run anywhere
173
+ curl -O https://raw.githubusercontent.com/speedyk-005/vink/main/demo_poc.py
174
+ python demo_poc.py
175
+ ```
176
+
177
+ The demo uses:
178
+ - `switch_latency_ms=120` (vs 300 default) β€” triggers switch sooner
179
+ - `dim=128`
180
+ - Batches of 10,000 vectors
181
+
182
+ The switch happens when latency exceeds `switch_latency_ms`. New vectors are buffered during the switch with zero downtime.
183
+
184
+ Results vary by hardware and system load β€” faster machines switch later, and running other programs will affect timing.
185
+
186
+ Example output:
187
+
188
+ ```
189
+ ┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
190
+ ┃ Vectors ┃ Strategy ┃ Avg Query (ms) ┃ Insert Time (s) ┃ Status ┃
191
+ ┑━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
192
+ β”‚ 10,000 β”‚ exact_search β”‚ 32.486 β”‚ 0.806 β”‚ Exact Search β”‚
193
+ β”‚ 20,000 β”‚ exact_search β”‚ 79.690 β”‚ 0.729 β”‚ Exact Search β”‚
194
+ β”‚ 30,000 β”‚ exact_search β”‚ 107.419 β”‚ 0.720 β”‚ Exact Search β”‚
195
+ β”‚ 40,000 β”‚ exact_search β”‚ 188.063 β”‚ 0.771 β”‚ βš™ Building ANN β”‚
196
+ β”‚ 50,000 β”‚ approximate_search β”‚ 0.000 β”‚ 10.051 β”‚ βœ“ ANN Active β”‚
197
+ β”‚ 60,000 β”‚ approximate_search β”‚ 155.239 β”‚ 1.323 β”‚ βœ“ ANN Active β”‚
198
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
199
+
200
+ βœ“ ANN switch successfully triggered!
201
+ ```
202
+
203
+ ---
204
+
205
+ ## πŸš€ Usage
206
+
207
+ ### Initialization ([VinkDB API](https://github.com/speedyk-005/vink/blob/main/API_REFERENCES.md#vink-core-VinkDB))
208
+
209
+ ```python
210
+ from vink import VinkDB
211
+
212
+ # Create a database with 128-dimensional vectors
213
+ db = VinkDB("./data", dim=128)
214
+
215
+ # Or use in-memory mode (no persistence)
216
+ db = VinkDB(":memory:", dim=128)
217
+
218
+ # With custom settings
219
+ db = VinkDB(
220
+ dir_path="./data",
221
+ dim=384,
222
+ metric="euclidean", # or "cosine" (default: euclidean)
223
+ force_exact=False, # or True to disable ANN (default: False)
224
+ ann_config=None, # ANNConfig for PQ/OPQ (default: auto-generated)
225
+ switch_latency_ms=300, # ms threshold for ANN switch (default: 300)
226
+ embedding_callback=None, # fn to generate embeddings from content
227
+ overwrite=False, # overwrite existing index (default: False)
228
+ verbose=False # enable verbose output (default: False)
229
+ )
230
+ ```
231
+
232
+ #### AnnConfig ([API](https://github.com/speedyk-005/vink/blob/main/API_REFERENCES.md#vink-models-AnnConfig))
233
+
234
+ Want custom ANN settings?
235
+
236
+ ```python
237
+ from vink import AnnConfig
238
+
239
+ config = AnnConfig(
240
+ num_subspaces=16, # number of sub-vectors (default: 32)
241
+ quantizer="pq", # "pq" or "opq" (default: pq)
242
+ codebook_size=128, # centroids per subspace (default: 256)
243
+ )
244
+ db = VinkDB("./data", dim=384, ann_config=config)
245
+
246
+ # print all available options:
247
+ AnnConfig.help()
248
+ ```
249
+
250
+ ### Add ([API](https://github.com/speedyk-005/vink/blob/main/API_REFERENCES.md#vink-core-VinkDB-add))
251
+
252
+ Records need:
253
+
254
+ - `content` (required): text to store
255
+ - `embedding` (required if no callback): list of floats or numpy array, shape `(d,)` or `(1, d)`
256
+ - `id` (optional): valid UUIDv7
257
+ - `metadata` (optional): dict of key-value pairs
258
+
259
+ Provide embeddings directly or use a callback to generate them on the fly.
260
+
261
+ #### With embedding callback
262
+
263
+ ```python
264
+ db = VinkDB("./data", dim=384, embedding_callback=my_embedding_fn)
265
+
266
+ # Just provide content β€” embeddings generated automatically
267
+ db.add([
268
+ {"content": "Hello world", "metadata": {"source": "doc1"}},
269
+ {"content": "Another text"},
270
+ ])
271
+ ```
272
+
273
+ #### Without callback
274
+
275
+ Provide embeddings directly:
276
+
277
+ ```python
278
+ db.add([
279
+ {"content": "Hello world", "embedding": [0.1] * 384, "metadata": {"source": "doc1"}},
280
+ {"content": "Another text", "embedding": [0.2] * 384}}
281
+ )]
282
+ ```
283
+
284
+ ### Search ([API](https://github.com/speedyk-005/vink/blob/main/API_REFERENCES.md#vink-core-VinkDB-search))
285
+
286
+ Results include:
287
+
288
+ - `id`: vector ID
289
+ - `content`: text content
290
+ - `distance`: similarity score (lower is closer for euclidean)
291
+ - `metadata`: key-value pairs
292
+ - `embedding`: (only if `include_vectors=True`)
293
+
294
+ #### Without filters
295
+ ```python
296
+ # Basic search
297
+ results = db.search(query_vec=[0.1] * 384, top_k=5)
298
+
299
+ # Include embeddings in results
300
+ results = db.search(query_vec=[0.1] * 384, include_vectors=True)
301
+ ```
302
+
303
+ #### With filters
304
+
305
+ Filter syntax supports `==`, `!=`, `>`, `<`, `>=`, `<=` with strings, numbers, and booleans. More operators coming in future updates.
306
+
307
+ ```
308
+ results = db.search(
309
+ query_vec=[0.1] * 384,
310
+ top_k=10,
311
+ filters=["source == 'doc1'", "score >= 50", "new == True"]
312
+ )
313
+ ```
314
+
315
+ ### Delete
316
+
317
+ #### Soft deletion ([API](https://github.com/speedyk-005/vink/blob/main/API_REFERENCES.md#vink-core-VinkDB-soft_delete))
318
+
319
+ Soft-delete vectors by ID without rebuilding the index β€” fast and efficient.
320
+
321
+ ```python
322
+ # IDs come from search results or when adding
323
+ db.soft_delete(["0192a5b4-7f3c-7d6e-9a1b-2c3d4e5f6a7b", "0192a5b4-7f3c-7d6e-9a1b-2c3d4e5f6a7c"])
324
+ ```
325
+
326
+ #### Compaction ([API](https://github.com/speedyk-005/vink/blob/main/API_REFERENCES.md#vink-core-VinkDB-compact))
327
+
328
+ Actually remove soft-deleted records and reclaim storage:
329
+
330
+ ```python
331
+ db.compact()
332
+ ```
333
+
334
+ > [!WARNING]
335
+ > Can take 20-200+ seconds with `approximate strategy` depending on data size. Run during maintenance windows or off-peak hours. If not enough vectors remain to retrain the codec, rebuild is skipped.
336
+
337
+ ### Stats ([API](https://github.com/speedyk-005/vink/blob/main/API_REFERENCES.md#vink-core-VinkDB-stats))
338
+
339
+ Get database statistics:
340
+
341
+ ```python
342
+ stats = db.stats()
343
+ # {
344
+ # "version": "...",
345
+ # "dimension": 128,
346
+ # "metric": "euclidean",
347
+ # "strategy": "exact_search",
348
+ # "last_saved_at": "...",
349
+ # "last_deleted_at": "...",
350
+ # "active_count": 1000,
351
+ # "deleted_count": 5
352
+ # }
353
+ ```
354
+
355
+ ---
356
+
357
+ ## 🚨 Exceptions ([API](https://github.com/speedyk-005/vink/blob/main/API_REFERENCES.md#vink-exceptions))
358
+
359
+ Something go wrong?
360
+
361
+ | Exception | When it hits |
362
+ | :--- | :--- |
363
+ | `InvalidInputError` | Bad data or invalid params |
364
+ | `VectorDimensionError` | Embedding dim mismatch |
365
+ | `InvalidIdError` | Malformed UUIDv7 |
366
+ | `FilterError` | Bad filter syntax |
367
+
368
+ ---
369
+
370
+ ## πŸ—Ί Features & Roadmap
371
+
372
+ - [x] Incremental Inserts
373
+ - [x] Hardware-Aware Auto-Switch
374
+ - [x] Soft deletes + compact
375
+ - [x] Save/Load
376
+ - [ ] Filter DSL
377
+ - [x] basic filters: Quick Comparison
378
+ - [ ] Complex Filters: Content Matching, Null Checks, date/time literals, ...
379
+ - [ ] Recovery: recover soft-deleted vectors
380
+ - [ ] Collections: Multi-collection support for managing multiple indices
381
+ - [ ] CLI - command-line interface
382
+ - [ ] REST API: HTTP API for remote vector operations
383
+ - [ ] Integrations: LangChain, LlamaIndex, and other integrations
384
+
385
+ ---
386
+
387
+ ## πŸ”§ Core Dependencies
388
+
389
+ - [rii](https://github.com/matsui528/rii) β€” C++ ANN library with pybind11 bindings (IVF-PQ index storage)
390
+ - [nanopq](https://github.com/matsui528/nanopq) β€” Pure Python PQ encoding/decoding
391
+ - [scipy](https://scipy.org) β€” Scientific computing (distance calculations)
392
+ - [numpy](https://numpy.org) β€” Numerical computing
393
+ - [SQLite](https://sqlite.org) β€” Metadata storage (content, embeddings, metadata), filtering queries
394
+
395
+ ---
396
+
397
+ ## 🀝 Contributing
398
+
399
+ Bug fixes, features, docs β€” all welcome. Check out [CONTRIBUTING.md](https://github.com/speedyk-005/vink/blob/main/CONTRIBUTING.md) for the full details.
400
+
401
+ ---
402
+
403
+ ## πŸ“œ License
404
+
405
+ Check out the [LICENSE](https://github.com/speedyk-005/vink/blob/main/LICENSE) file for all the details.
406
+
407
+ > MIT License. Use freely, modify boldly, and credit appropriately! (We're not that legendary... yet πŸ˜‰)
408
+