SimpleDBNN
SimpleDBNN is a Rust library that combines a lightweight text database with a vector index for performing similarity searches using embeddings. It is designed to be flexible and embeddable with any custom embedding engine that implements the Embeddable trait.
Features
- Efficient persistence with
heedandarroy - Insert and query by embedding vectors
- Extensible interface via the
Embeddabletrait - Batch support for high-throughput use cases
- Built-in test suite
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Note: replace with the published version on crates.io when available.
🚀 Usage
1. Define your embedding engine
;
2. Create a database
use Euclidean;
use ;
use PathBuf;
let mut db = new.unwrap;
3. Insert content
db.put.unwrap;
4. Search similar content
let results = db.get.unwrap;
for in results
🧩 Public API
| Function | Description |
|---|---|
put(&str) |
Insert and index content |
get(&str, usize) |
Search top-n similar entries |
put_batch(Vec<&str>) |
Insert a batch of entries |
clear() |
Delete all persisted data |
get_current_id() |
Get the next internal ID to be assigned |
🧠 Embeddable Trait
Implement this trait to integrate your own embedding engine:
🛠️ Tests
Run tests with:
Covers:
- Basic storage and retrieval
- Batch insertions
- Similarity search using both
DummyEmbeddingandFastEmbedding
⚖️ License
This project is dual-licensed under MIT or Apache-2.0 — choose whichever you prefer.
🙌 Credits
- Powered by
arroyfor approximate nearest neighbor indexing - Uses
heedfor efficient LMDB-based storage - Compatible with
fastembedfor real embedding backends
Have a custom embedding engine? Just implement Embeddable and you're ready.
Pull requests and suggestions are welcome ❤️