Skip to main content

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:

Then, you can run the examples to test the database.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lab_1806_vec_db-0.2.2-cp310-none-win_amd64.whl (256.0 kB view details)

Uploaded CPython 3.10Windows x86-64

lab_1806_vec_db-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (395.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

Details for the file lab_1806_vec_db-0.2.2-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for lab_1806_vec_db-0.2.2-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 de337b070ee7e531e8aa77ee058729092a430ae62c7a35ffafa6e5ad3203f568
MD5 eff98c281c12e3683e2d9160b292c21d
BLAKE2b-256 d5f0ec9dcae812a36f362f524d525aced7613ac9945024b311e76f0b120edc54

See more details on using hashes here.

File details

Details for the file lab_1806_vec_db-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lab_1806_vec_db-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f7f77a3e8d3eab41ab83fc535ddabe78981de536e6d3caa885af1b31b630c4be
MD5 6bafb2026cfd2b1c44bf329a2cb62640
BLAKE2b-256 dde53fede4723b5de9ba0d24c470da076a5d35d49d040c64c6c74868a07307bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page