memvdb

Library Listed Dormant

A Rust in-memory vector database

Checked ยท Sources

Downloads
305
Dependents
2
Stars
2
Forks
1
Contributors
1
Commits
7
Latest release
0.1.1 ยท

About

From the project README ยท

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
  1. Clone the repository
  2. Install Rust (1.70+ recommended)
  3. Run tests: cargo test
  4. 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


MemVDB - Fast, lightweight, and efficient in-memory vector search for Rust applications.

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.

memvdb beside the projects that share a topic with it
ProjectDownloadsDependentsStarsLatest releaseRuns on (GPU)Native codeLicense
memvdb This page Listed Dormant

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 App Featured

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 days
  • dormancy: last activity 2025-05-26, 532 days ago, E = 365: dormant
  • rot: oldest unanswered issue 446 days (limit 270), no maintainer reply in 365 days
  • featured: 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 stable
  • listed: 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
Adoption2 active dependents, 2 new dependents in 365 days1 not measured
Adoption measurements
SignalValueSourceFetchedCounts
Active dependents2crates.io database dumpYes
New dependents (365 days)2crates.io database dumpYes
Peak active dependents2crates.io database dumpYes
Active dependents as a share of the peak1crates.io database dumpYes
Binary downloads per releaseNot measuredYes
MaintenanceLatest human commit: 17 months ago3 not measured
Maintenance measurements
SignalValueSourceFetchedCounts
Latest human commit2025-05-26GitHub repositoryYes
Latest release2025-05-26crates.io database dumpYes
First release2025-05-26crates.io database dumpYes
Latest version0.1.1crates.io database dumpYes
Days the oldest outside issue waits for a reply446GitHub repositoryYes
Maintainer replies over 365 days0GitHub repositoryYes
Repository archivedfalseGitHub repositoryYes
Repository gonefalseGitHub repositoryYes
Release commit or manifest in the repotruecrates.io packageYes
Published docstruecrates.io database dumpYes
Latest release fails cargo checkNot measuredYes
Build check dateNot measuredYes
Build check toolchainNot measuredYes
SecurityUnpatched vulnerabilities: none
Security measurements
SignalValueSourceFetchedCounts
Unpatched vulnerabilities past the grace windownoneRustSec advisory databaseYes
RustSec unmaintained advisorynoneRustSec advisory databaseYes
Deprecation noticenonecrates.io database dumpYes
Deprecated requirementnonecrates.io database dumpYes
Distribution2 releases, 305 downloads over 30 days5 not measured
Distribution measurements
SignalValueSourceFetchedCounts
Releases2crates.io database dumpYes
Downloads over 30 days305crates.io database dumpYes
Binary downloads over the last 3 releasesNot measuredYes
Homebrew installs on request over 365 daysNot measuredYes
Repology repository familiesNot measuredYes
Docker pull growth over 90 daysNot measuredYes
Docker pulls at the growth baselineNot measuredYes
Every version a prereleasefalsecrates.io database dumpYes
Every version 0.0.xfalsecrates.io database dumpYes
Every version yankedfalsecrates.io database dumpYes
Crate deleted from crates.iofalsecrates.io database dumpYes
Repository2 stars, 1 forks, 1 contributors, 7 commits. Stars alone never qualify a project.
Repository measurements
SignalValueSourceFetchedCounts
GitHub stars2GitHub repositoryYes โ€” one part of the repository route
GitHub forks1GitHub repositoryYes โ€” one part of the repository route
Contributors with a GitHub account1GitHub contributorsYes โ€” one part of the repository route
Commits on the default branch7GitHub repositoryNo
Repository's main crate left out of the entrynonecrates.io database dumpYes
Facts that never count
Facts that never count measurements
SignalValueSourceFetchedCounts
LicenseMITcrates.io database dumpNo
Runs on, from listed crates and their direct dependenciesGPU support unknowncrates.io database dumpNo
What shows each backendno dependency or feature matches a backend rowcrates.io database dumpNo
Native code, from listed crates and their dependenciesNo native code foundcrates.io database dumpNo
Python bindings, from direct dependencies of listed cratesNo Python binding crate foundcrates.io database dumpNo
Crates that depend on a listed crate directly2crates.io database dumpNo

Corrections and review history

Report a correction

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.