memvdb
Library Listed Dormant
A Rust in-memory vector database
- Downloads
- 305
- Dependents
- 2
- Stars
- 2
- Forks
- 1
- Contributors
- 1
- Commits
- 7
- Latest release
- 0.1.1 ยท
About
MemVDB - In-Memory Vector Database
MemVDB is a fast, lightweight in-memory vector database written in Rust. It provides efficient similarity search capabilities with support for multiple distance metrics, making it ideal for machine learning applications, recommendation systems, and semantic search.
๐ Features
- Multiple Distance Metrics: Euclidean, Cosine, and Dot Product similarity
- High Performance: Optimized similarity search with binary heap algorithms
- Flexible Metadata: Store arbitrary metadata with each embedding
- Batch Operations: Efficient batch insertion and updates
- Thread Safety: Safe concurrent access with proper locking
- Zero Dependencies: Minimal external dependencies for core functionality
- Memory Efficient: Optimized data structures for large-scale operations
๐ฆ Installation
Add MemVDB to your Cargo.toml:
cargo add memvdb
Read the full README
๐ฏ Quick Start
use memvdb::{CacheDB, Distance, Embedding};
use std::collections::HashMap;
// Create a new in-memory vector database
let mut db = CacheDB::new();
// Create a collection with 128-dimensional vectors using cosine similarity
db.create_collection("documents".to_string(), 128, Distance::Cosine).unwrap();
// Create an embedding with metadata
let mut id = HashMap::new();
id.insert("doc_id".to_string(), "doc_001".to_string());
let mut metadata = HashMap::new();
metadata.insert("title".to_string(), "Sample Document".to_string());
metadata.insert("category".to_string(), "AI".to_string());
let vector = vec![0.1; 128]; // 128-dimensional vector
let embedding = Embedding {
id,
vector,
metadata: Some(metadata),
};
// Insert the embedding
db.insert_into_collection("documents", embedding).unwrap();
// Perform similarity search
let query_vector = vec![0.2; 128];
let collection = db.get_collection("documents").unwrap();
let results = collection.get_similarity(&query_vector, 5);
println!("Found {} similar documents", results.len());
๐ Core Concepts
Collections
Collections are containers for embeddings with a specific dimensionality and distance metric. All embeddings within a collection must have the same vector dimension.
// Create collections with different distance metrics
db.create_collection("images".to_string(), 512, Distance::Euclidean).unwrap();
db.create_collection("text".to_string(), 384, Distance::Cosine).unwrap();
db.create_collection("recommendations".to_string(), 256, Distance::DotProduct).unwrap();
Embeddings
Embeddings consist of a unique identifier, vector data, and optional metadata:
let mut id = HashMap::new();
id.insert("user_id".to_string(), "user_123".to_string());
id.insert("item_id".to_string(), "item_456".to_string());
let mut metadata = HashMap::new();
metadata.insert("category".to_string(), "electronics".to_string());
metadata.insert("price".to_string(), "299.99".to_string());
let embedding = Embedding {
id,
vector: vec![0.1, 0.2, 0.3, 0.4],
metadata: Some(metadata),
};
Distance Metrics
Choose the appropriate distance metric based on your data and use case:
Euclidean Distance
- Best for: Spatial data, computer vision features
- Characteristics: Sensitive to magnitude, measures geometric distance
- Range: [0, โ)
db.create_collection("spatial_data".to_string(), 3, Distance::Euclidean).unwrap();
Cosine Similarity
- Best for: Text embeddings, high-dimensional sparse data
- Characteristics: Ignores magnitude, measures angle between vectors
- Range: [0, 2] (converted from [-1, 1])
db.create_collection("documents".to_string(), 768, Distance::Cosine).unwrap();
Dot Product
- Best for: Pre-normalized vectors, neural network outputs
- Characteristics: Considers both angle and magnitude
- Range: (-โ, โ)
db.create_collection("embeddings".to_string(), 512, Distance::DotProduct).unwrap();
๐ง API Reference
Database Operations
// Create a new database
let mut db = CacheDB::new();
// Create a collection
db.create_collection("my_collection".to_string(), 128, Distance::Cosine)?;
// Get a collection
let collection = db.get_collection("my_collection");
// Delete a collection
db.delete_collection("my_collection")?;
// Get all embeddings from a collection
let embeddings = db.get_embeddings("my_collection");
Embedding Operations
// Insert a single embedding
db.insert_into_collection("my_collection", embedding)?;
// Batch insert/update embeddings
let embeddings = vec![embedding1, embedding2, embedding3];
db.update_collection("my_collection", embeddings)?;
// Similarity search
let collection = db.get_collection("my_collection").unwrap();
let results = collection.get_similarity(&query_vector, 10);
Similarity Search
let results = collection.get_similarity(&query_vector, k);
for result in results {
println!("Score: {}", result.score);
println!("ID: {:?}", result.embedding.id);
println!("Metadata: {:?}", result.embedding.metadata);
}
๐ Examples
Document Similarity Search
use memvdb::{CacheDB, Distance, Embedding};
use std::collections::HashMap;
let mut db = CacheDB::new();
db.create_collection("articles".to_string(), 384, Distance::Cosine)?;
// Insert documents
let articles = vec![
("AI in Healthcare", vec![0.8, 0.7, 0.1, 0.2]),
("Machine Learning Basics", vec![0.7, 0.8, 0.2, 0.1]),
("Cooking Recipes", vec![0.1, 0.2, 0.9, 0.8]),
];
for (title, mut vector) in articles {
vector.resize(384, 0.0); // Pad to collection dimension
let mut id = HashMap::new();
id.insert("title".to_string(), title.to_string());
let mut metadata = HashMap::new();
metadata.insert("category".to_string(),
if title.contains("AI") || title.contains("Machine") {
"Technology".to_string()
} else {
"Lifestyle".to_string()
});
let embedding = Embedding {
id,
vector,
metadata: Some(metadata),
};
db.insert_into_collection("articles", embedding)?;
}
// Search for AI-related content
let mut query = vec![0.75, 0.75, 0.1, 0.1];
query.resize(384, 0.0);
let collection = db.get_collection("articles").unwrap();
let results = collection.get_similarity(&query, 3);
for (i, result) in results.iter().enumerate() {
println!("{}. {} (Score: {:.4})",
i + 1,
result.embedding.id.get("title").unwrap(),
result.score);
}
Batch Operations
// Generate many embeddings
let embeddings: Vec<Embedding> = (0..1000).map(|i| {
let mut id = HashMap::new();
id.insert("id".to_string(), i.to_string());
Embedding {
id,
vector: vec![i as f32 / 1000.0; 128],
metadata: None,
}
}).collect();
// Batch insert for better performance
db.update_collection("large_collection", embeddings)?;
E-commerce Recommendations
let mut db = CacheDB::new();
db.create_collection("products".to_string(), 256, Distance::DotProduct)?;
// Product embeddings with metadata
let products = vec![
("laptop_001", "Gaming Laptop", "Electronics", 1299.99),
("book_001", "Rust Programming", "Books", 39.99),
("headphones_001", "Wireless Headphones", "Electronics", 199.99),
];
for (product_id, name, category, price) in products {
let mut id = HashMap::new();
id.insert("product_id".to_string(), product_id.to_string());
let mut metadata = HashMap::new();
metadata.insert("name".to_string(), name.to_string());
metadata.insert("category".to_string(), category.to_string());
metadata.insert("price".to_string(), price.to_string());
// Simulate product embedding based on features
let vector = generate_product_embedding(name, category);
let embedding = Embedding {
id,
vector,
metadata: Some(metadata),
};
db.insert_into_collection("products", embedding)?;
}
// Find similar products
let user_preference_vector = vec![0.5; 256];
let collection = db.get_collection("products").unwrap();
let recommendations = collection.get_similarity(&user_preference_vector, 5);
๐ง Building and Testing
Build
cargo build --release
Run Tests
# Run all tests
cargo test
# Run specific test categories
cargo test --lib # Unit tests
cargo test --test integration_tests # Integration tests
cargo test --test similarity_tests # Similarity function tests
cargo test --test error_tests # Error handling tests
cargo test --test performance_tests # Performance tests
Run Examples
# Basic usage example
cargo run --example basic_usage
# Document similarity search
cargo run --example document_similarity
# Distance metrics comparison
cargo run --example distance_metrics
# Batch operations
cargo run --example batch_operations
๐ฃ๏ธ Use Cases
Machine Learning
- Feature similarity search: Find similar data points in feature space
- Nearest neighbor algorithms: Implement k-NN classifiers
- Clustering validation: Evaluate cluster quality with distance metrics
Natural Language Processing
- Semantic search: Find semantically similar documents or sentences
- Document retrieval: Information retrieval systems
- Question answering: Find relevant context for questions
Computer Vision
- Image similarity: Find visually similar images
- Face recognition: Match face embeddings
- Object detection: Compare object feature vectors
Recommendation Systems
- Content-based filtering: Recommend similar items
- User similarity: Find users with similar preferences
- Hybrid recommendations: Combine multiple embedding types
Information Retrieval
- Search engines: Semantic document search
- Knowledge bases: Find related concepts
- Data deduplication: Identify similar records
๐ค Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Setup
- Clone the repository
- Install Rust (1.70+ recommended)
- Run tests:
cargo test - Run examples:
cargo run --example basic_usage
Code Style
We use standard Rust formatting:
cargo fmt
cargo clippy
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Inspired by memvectordb
- Built with Rust's performance and safety in mind
- Optimized for machine learning and AI applications
๐ Support
- Documentation: docs.rs/memvdb
- Issues: GitHub Issues
- Discussions: GitHub Discussions
MemVDB - Fast, lightweight, and efficient in-memory vector search for Rust applications.
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- None found
- No native code found
- Python bindings
- No Python binding crate found
- License
- MIT
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
A Rust in-memory vector database |
305 downloads over 30 days | 2 | 2 | 0.1.1 | GPU support unknown | No native code found | MIT |
|
lancedb Featured
LanceDB: A serverless, low-latency vector database for AI applications |
615,090 downloads over 30 days | 102 | 11,863 | 0.41.0 | GPU support unknown | No native code found | Apache-2.0 |
|
Qdrant - High-performance, massive-scale Vector Database and Vector Search Engine for the next generation of AI. Also available in the cloud https://cloud.qdrant.io/ |
34,017 binary downloads per release | Not applicable | 35,478 | Not measured | Not measured | Apache-2.0 | |
|
ruvector Listed
High-performance Rust vector database core with HNSW indexing |
39,411 downloads over 30 days | 51 | 4,675 | 2.5.0 | CUDA, WebGPU, Metal | Binds native code: libsqlite3-sys, napi-sys, ort-sys, pgrx-pg-sys, pqcrypto-internals and 5 more | MIT |
|
splintr Listed
Tokenizer for Rust and Python: pure Rust by default, with 18 bundled vocabularies and four backends covering BPE, SentencePiece and WordPiece. Its output matches Hugging Face tokenizers id for id on 14 model families, including GPT-2, Qwen, Whisper, T5 and BERT. Python bindings |
8,204 downloads over 30 days | 7 | 63 | 0.22.2 | GPU support unknown | Binds native code: pcre2-sys (feature pcre2) | MIT |
|
velesdb Listed
High-performance vector database engine written in Rust |
2,396 downloads over 30 days | 0 | 102 | 8.1.0 | WebGPU | Binds native code: tauri, tauri-plugin-velesdb, atk-sys, gdk-pixbuf-sys, gdk-sys and 9 more | Not measured |
|
chromadb-rs Archived
A Rust client library for the ChromaDB vector database. |
3,548 downloads over 30 days | 7 | 46 | 2.3.0 | GPU support unknown | No native code found | MIT |
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- It has 2 active dependents and 2 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 2 stars, 1 fork and 1 contributor. It needs 4,539 stars, 434 forks and 79 contributors together.
- The project is dormant and not finished. Dormancy rule
What else the check found
- The last activity is on 26 May 2025, 532 days ago. That reaches the 365 days the rules expect, so the project is dormant. Dormancy rule
- The oldest outside issue waits 446 days for a reply, past the limit of 270. No maintainer replied in 365 days. Rot signals rule
Not measured: Latest release fails cargo check.
Exact rules: Listed, Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 0.1.1 base 300, capped at 2 releases = 100, raised to the 365-day floor: E = 365 daysdormancy: last activity 2025-05-26, 532 days ago, E = 365: dormantrot: oldest unanswered issue 446 days (limit 270), no maintainer reply in 365 daysfeatured: not featured: active_users 2 < 11 and new_adopters 2 < 9 and repository route stars 2 (needs 4539), forks 1 (needs 434), contributors 1 (needs 79); dormant and not stablelisted: listed: no archive, new or featured rule applies
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption2 active dependents, 2 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 2 | crates.io database dump | Yes | |
| New dependents (365 days) | 2 | crates.io database dump | Yes | |
| Peak active dependents | 2 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 1 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 17 months ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2025-05-26 | GitHub repository | Yes | |
| Latest release | 2025-05-26 | crates.io database dump | Yes | |
| First release | 2025-05-26 | crates.io database dump | Yes | |
| Latest version | 0.1.1 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 446 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 0 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution2 releases, 305 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 2 | crates.io database dump | Yes | |
| Downloads over 30 days | 305 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository2 stars, 1 forks, 1 contributors, 7 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 2 | GitHub repository | Yes โ one part of the repository route | |
| GitHub forks | 1 | GitHub repository | Yes โ one part of the repository route | |
| Contributors with a GitHub account | 1 | GitHub contributors | Yes โ one part of the repository route | |
| Commits on the default branch | 7 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | MIT | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | No native code found | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | No Python binding crate found | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 2 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.