KeraDB CLI is a lightweight, embedded document database designed for simplicity and ease of use. It serves as a powerful tool for developers to manage JSON documents with automatic indexing and persistent storage. Built in Rust, KeraDB offers high performance and memory safety while maintaining an intuitive interface.
Key Features:
Single-file database format: All data is stored in a single .ndb file for simplicity and ease of management.
Fast and memory-safe: Written in Rust, KeraDB ensures zero-cost abstractions and memory safety, making it ideal for mission-critical applications.
Document-oriented storage: Store JSON documents with automatic UUIDs for easy organization and retrieval.
Vector search capabilities: Supports HNSW (Hierarchical Navigable Small World) indexing for fast approximate nearest neighbor searches, enabling efficient vector database operations.
Delta compression: Inspired by LEANN-style compression, KeraDB reduces storage requirements while maintaining accuracy, achieving up to 97% savings in some cases.
Multi-language SDKs: Accessible from multiple programming languages, including Rust, Node.js, Python, Go, and C#, making it versatile for various development environments.
Audience & Benefit:
Ideal for developers building applications that require embedded document storage or vector search capabilities. KeraDB simplifies integration into projects by eliminating the need for external database setups, reducing overhead, and offering efficient performance for both small-scale and large-scale applications. Its robust features make it a reliable choice for embedding in machine learning workflows or any scenario requiring lightweight, high-performance data management. Installable via winget, KeraDB CLI provides developers with a seamless experience from the command line or through its interactive REPL interface.
README
KeraDB
> A lightweight, embedded NoSQL document database with vector search - written in Rust
KeraDB is a single-file, embedded document database designed for simplicity and ease of use. Think SQLite, but for JSON documents with vector search capabilities!
Metadata Filtering - Filter vector search by document attributes
Unified Storage - Vectors and documents in the same .ndb file
Delta Compression - Up to 97% storage savings with LEANN-style compression
LEANN-Style Delta Compression
KeraDB implements delta compression inspired by LEANN (Low-storage Embedding Approximate Nearest Neighbor), a research project from Berkeley Sky Computing Lab that achieves 97% storage savings while maintaining search accuracy.
Only compute/store embeddings for nodes in the search path
High-degree preserving pruning
Keep important "hub" nodes while removing redundant connections
Sparse delta encoding
Store only components that differ significantly (threshold-based)
Quantized deltas
Optional 8-bit quantization for even more aggressive compression
Storage Savings (LEANN Benchmarks)
Dataset
Traditional
With LEANN
Savings
780K email chunks
78 MB
8 MB
91%
60M text chunks
201 GB
6 GB
97%
38K browser entries
6 MB
0.4 MB
95%
400K chat messages
64 MB
2 MB
97%
Using Compression in KeraDB
use keradb::{VectorConfig, CompressionConfig, CompressionMode};
// Delta compression - recommended for most use cases
let config = VectorConfig::new(768)
.with_delta_compression();
// Quantized delta - most aggressive compression
let config = VectorConfig::new(768)
.with_quantized_compression();
// Custom configuration
let config = VectorConfig::new(768)
.with_compression(CompressionConfig {
mode: CompressionMode::Delta,
sparsity_threshold: 0.001, // Ignore deltas below this
max_density: 0.15, // Fall back to full if >15% differs
anchor_frequency: 8, // Every 8th vector is an anchor
quantization_bits: 8, // For quantized mode
});
Quick Start
Installation
Linux and macOS:
curl -sSf https://raw.githubusercontent.com/KeraDB/keradb/main/scripts/install.sh | sh
git clone https://github.com/KeraDB/keradb.git
cd keradb
cargo build --release
Using the CLI
# Create and open database
./target/release/keradb shell myapp.ndb
# Inside the shell:
keradb> insert users {"name":"Alice","age":30}
keradb> find users
keradb> count users
keradb> exit
Using as a Library
use keradb::Database;
use serde_json::json;
fn main() -> Result<(), Box> {
let db = Database::create("mydata.ndb")?;
let id = db.insert("users", json!({
"name": "Alice",
"age": 30
}))?;
let user = db.find_by_id("users", &id)?;
println!("Found: {:?}", user.data);
Ok(())
}
Vector Search Example
use keradb::{Database, VectorConfig, Distance};
fn main() -> Result<(), Box> {
let db = Database::create("vectors.ndb")?;
// Create vector collection with compression
let config = VectorConfig::new(384)
.with_distance(Distance::Cosine)
.with_delta_compression();
db.create_vector_collection("embeddings", config)?;
// Insert vectors
let embedding = vec![0.1, 0.2, 0.3, /* ... */];
db.insert_vector("embeddings", embedding, None)?;
// Search
let results = db.vector_search("embeddings", &query, 10)?;
Ok(())
}
Benchmarks
Run on your system with cargo bench.
Document Operations
Operation
Throughput
Insert (single)
~10,000 ops/sec
Find by ID
~50,000 ops/sec
Update
~8,000 ops/sec
Vector Insert Performance
Dimensions
Time per Insert
32-dim
77-81 us
128-dim
94-97 us
384-dim
135-144 us
768-dim
167-185 us
Vector Search Performance (k=10)
Collection Size
Dimensions
Search Time
100 vectors
128-dim
34-36 us
1,000 vectors
128-dim
36-37 us
10,000 vectors
128-dim
38 us
1,000 vectors
384-dim
117-121 us
HNSW achieves near-constant search time - 10,000 vectors is only ~10% slower than 100 vectors.
Search by K
k (results)
Time
k=1
35-37 us
k=10
35-37 us
k=50
39-40 us
k=100
64-65 us
Distance Metric Comparison
Metric
Time
Notes
Dot Product
54-57 us
Fastest - no normalization
Euclidean
59-60 us
Standard L2 distance
Cosine
115-117 us
Requires normalization
Bulk Insert
Count
Time
Rate
100 vectors
7.1 ms
~14k/sec
500 vectors
51 ms
~10k/sec
1,000 vectors
107 ms
~9.3k/sec
5,000 vectors
567 ms
~8.8k/sec
Compression Performance
Scenario
Uncompressed
Compressed
Savings
768-dim, 5% sparse diff
3,072 bytes
~250 bytes
91.9%
128-dim, 10% sparse diff
512 bytes
~94 bytes
81.6%
Mixed workload
5,120 bytes
2,218 bytes
56.7%
Performance Summary
Sub-40us search on 10K vectors (HNSW delivers O(log n) complexity)
~100us per vector insert for typical 128-dim embeddings
Dot product is 2x faster than cosine (no normalization)