memvid-core
A crash-safe, deterministic, single-file AI memory system.
About
memvid-core is the Rust library powering Memvid - a memory system for AI applications that stores everything in a single .mv2 file. No databases, no sidecar files, no external dependencies. Each memory file is completely self-contained with embedded WAL, full-text search indices, vector embeddings, and time-indexed storage.
Why memvid-core?
- Single File - Everything in one portable
.mv2file - Crash-Safe - Embedded WAL ensures durability and automatic recovery
- Hybrid Search - Full-text (Tantivy BM25) + semantic vector search (HNSW)
- Deterministic - Same operations produce identical bytes
- Fast - Sub-millisecond search across 50K documents
Performance
| Metric | Value |
|---|---|
| Search Latency | 0.81 ms (50K docs) |
| Cold Start | 190 ms |
| Memory Usage | ~200 MB |
| Ingestion | 157 docs/sec |
Installation
[]
= "2.0.1"
Feature Flags
| Feature | Default | Description |
|---|---|---|
lex |
Yes | Tantivy full-text search (BM25) |
vec |
No | HNSW vector search with ONNX embeddings |
temporal_track |
No | Natural language time queries |
parallel_segments |
No | Multi-threaded ingestion |
pdfium |
No | PDF rendering with Pdfium |
Enable features based on your needs:
[]
= { = "2.0.1", = ["lex", "vec", "parallel_segments"] }
Quick Start
use ;
Feature Flag Compatibility
When opening an existing .mv2 file, you must enable the same features that were used during creation. Mismatched features cause deserialization errors.
// If the file was created with the CLI (which enables all features),
// you need all features to open it:
[]
= { = "2.0.1", = [
"lex",
"vec",
"temporal_track",
"parallel_segments"
]}
Check what features a file needs:
|
# Shows: lexical, vector, time index presence
Architecture
┌─────────────────────────────────────┐
│ .mv2 File (Single File) │
├─────────────────────────────────────┤
│ Header (4KB) │
│ - Magic bytes, version, metadata │
├─────────────────────────────────────┤
│ Embedded WAL (1-64MB) │
│ - Crash recovery, append-only log │
├─────────────────────────────────────┤
│ Data Segments │
│ - Compressed frames, embeddings │
├─────────────────────────────────────┤
│ Tantivy Index (Full-Text) │
├─────────────────────────────────────┤
│ HNSW Vector Index (Semantic) │
├─────────────────────────────────────┤
│ Time Index │
├─────────────────────────────────────┤
│ Table of Contents (Footer) │
└─────────────────────────────────────┘
Logging
memvid-core uses the log and tracing crates. Configure logging in your application:
// Using env_logger
from_env.init;
// Using tracing
fmt
.with_env_filter
.init;
Recommended levels:
error- Production (critical failures only)warn- Production with warningsinfo- Developmentdebug/trace- Debugging
Examples
Hybrid Search
use ;
let mem = open?;
// Auto mode (lexical + semantic reranking)
let results = mem.search?;
// Lexical only (BM25)
let results = mem.search?;
// Semantic only (vector similarity)
let results = mem.search?;
Timeline Queries
use Memvid;
let mem = open?;
// Get recent entries
let entries = mem.timeline?;
// Filter by time range
let entries = mem.timeline?;
Parallel Ingestion
use ;
let mut mem = create?;
let opts = BuildOpts ;
mem.put_file?;
Documentation
Security
- Runs fully offline by default
- OS-level file locking prevents concurrent writes
- Ed25519 signed tickets for access control
- Single-file design reduces attack surface
License
Dual-licensed under MIT or Apache 2.0. Choose either for your use.
Acknowledgments
Built with:
- Tantivy - Full-text search
- HNSW - Vector similarity
- ONNX Runtime - ML inference