No project description provided
Project description
lab-1806-vec-db
Lab 1806 Vector Database.
Usage with Python
See https://github.com/pku-lab-1806-llm/lab-1806-vec-db/releases/latest for the latest release.
Install the wheel file with pip.
from lab_1806_vec_db import RagVecDB
db = RagVecDB(dim=4)
db.add([1.0, 0.0, 0.0, 0.0], {"content": "a"})
db.add([1.0, 0.0, 0.0, 0.1], {"content": "aa"})
db.add([0.0, 1.0, 0.0, 0.0], {"content": "b"})
db.add([0.0, 1.0, 0.0, 0.1], {"content": "bb"})
db.add([0.0, 0.0, 1.0, 0.0], {"content": "c"})
db.add([0.0, 0.0, 1.0, 0.1], {"content": "cc"})
db.save("test_db.local.bin")
loaded_db = RagVecDB.load("test_db.local.bin")
for idx, metadata in enumerate(loaded_db.search([1.0, 0.0, 0.0, 0.0], 2)):
print(idx, metadata["content"])
Development with Rust
# Install Rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"
# Then install the rust-analyzer extension in VSCode.
# You may need to set "rust-analyzer.runnables.extraEnv" in VSCode Machine settings.
# The value should be like {"PATH":""} and make sure that `/home/YOUR_NAME/.cargo/bin` is in it.
# Otherwise you may fail when press the `Run test` button.
# Run tests
# Add `-r` to test with release mode
cargo test
# Or you can click the 'Run Test' button in VSCode to show output.
# Our GitHub Actions will also run the tests.
Test the python binding with test-pyo3.py.
# Install Python 3.10
brew install python@3.10
# or on Windows
scoop bucket add versions
scoop install python310
# Install uv.
# See https://github.com/astral-sh/uv for alternatives.
pip install uv
# or on Windows
scoop install uv
# Run the Python test
uv sync --reinstall-package lab_1806_vec_db
uv run ./test-pyo3.py
# Build the Python Wheel Release
# This will be automatically run in GitHub Actions.
uv build
Examples Binaries
See also the Binaries at src/bin/, and the Examples at examples/.
src/bin/convert_fvecs.rs: Convert the fvecs format to the binary format.src/bin/gen_ground_truth.rs: Generate the ground truth for the query.examples/bench.rs: The benchmark for index algorithms.
Check the comments at the end of the source files for the usage.
Dataset
Download Gist1M dataset from:
-
Official: http://corpus-texmex.irisa.fr/
-
Ours: Recommended faster, and already converted to the binary format. We also provide pre-built config file & ground truth & HNSW index.
https://huggingface.co/datasets/pku-lab-1806-llm/gist-for-lab-1806-vec-db
Then, you can run the examples to test the database.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lab_1806_vec_db-0.2.1-cp310-none-win_amd64.whl.
File metadata
- Download URL: lab_1806_vec_db-0.2.1-cp310-none-win_amd64.whl
- Upload date:
- Size: 256.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
860622f25ff2f5c24de618e80881e9e88b916803156e56651d77254b448f4b0b
|
|
| MD5 |
416e0308f55b27545156bd3999be4003
|
|
| BLAKE2b-256 |
cce5e779cd5b6c2aa53f5539b6dbed560c7176be4d3045147169e256cc39b563
|
File details
Details for the file lab_1806_vec_db-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: lab_1806_vec_db-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 396.0 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ab811d30b1b25728dfd7c48aeb03b0f65be14814958598bf1bb20955080cd16
|
|
| MD5 |
9550c78e7b88c6b7112c442cca9b5a4c
|
|
| BLAKE2b-256 |
a84b9bfa0661f9c7b02fd64792b4d80d57cdb501b660b35a58951833d7edfbca
|