https://github.com/xiangpenghao/vector-lite
The SQLite of Vector Database in Rust.
https://github.com/xiangpenghao/vector-lite
ann rust vector-database vector-search
Last synced: 6 months ago
JSON representation
The SQLite of Vector Database in Rust.
- Host: GitHub
- URL: https://github.com/xiangpenghao/vector-lite
- Owner: XiangpengHao
- License: apache-2.0
- Created: 2025-03-05T19:33:56.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-17T04:39:20.000Z (7 months ago)
- Last Synced: 2025-04-09T23:52:21.134Z (6 months ago)
- Topics: ann, rust, vector-database, vector-search
- Language: Rust
- Homepage:
- Size: 169 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VectorLite
[](https://github.com/XiangpengHao/vector-lite/actions/workflows/ci.yml)
[](https://crates.io/crates/vector-lite)
[](https://docs.rs/vector-lite/latest/vector_lite/)The SQLite of Vector Database in Rust.
## Features
- [x] Compact size
- [x] Zero-copy de/serialization from/to disk
- [x] Excellent search performance
- [x] WASM support
- [x] Minimal dependencies### Planned
- [ ] Concurrent insert/delete/search
- [ ] Support usage as external index for Parquet dataset.## Usage
```rust
use vector_lite::{VectorLite, Vector, ANNIndexOwned};// Create a new index with 4 trees and leaf size of 10
const DIM: usize = 3;
let mut index = VectorLite::::new(4, 10);
index.insert([1.0, 0.0, 0.0].into(), "101".to_string());
index.insert([0.0, 1.0, 0.0].into(), "102".to_string());
index.insert([0.0, 0.0, 1.0].into(), "103".to_string());
index.insert([0.7, 0.7, 0.0].into(), "104".to_string());let query = [0.9, 0.1, 0.0].into();
let results = index.search(&query, 2);for (id, distance) in results {
println!("ID: {}, Distance: {}", id, distance);
}index.delete_by_id("102");
// De/serialize from/to disk
let serialized = index.to_bytes();
let loaded_index = VectorLite::::from_bytes(&serialized);
```## Benchmark
```bash
cargo bench --bench ann_benchmark "ANN Index Building/10000"
```## WASM
Need to build with [`wasm_js` backend](https://docs.rs/getrandom/latest/getrandom/#webassembly-support) for `getrandom` crate.
```bash
env RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo build --target wasm32-unknown-unknown
```Run tests:
```bash
# Install wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh# Run test
env RUSTFLAGS='--cfg getrandom_backend="wasm_js"' wasm-pack test --headless --firefox
```## Notable users
VectorLite is the primary vector database used in [Seen](https://github.com/XiangpengHao/seen) -- knowledge management for the impatient.## License
Apache-2.0