mem0-rust
A high-performance Rust implementation of mem0, the universal memory layer for AI Agents.
maintained by YASSERRMD.
Features
- 🦀 Pure Rust - Fast, safe, and efficient
- 🔌 Multiple Backends - Support for Memory, Qdrant, PostgreSQL (pgvector), and Redis vector stores
- 🧠 Embedding Support - OpenAI, Ollama, HuggingFace Inference API, and Mock providers
- 🤖 LLM Integration - Automatic fact extraction with OpenAI, Ollama, or Anthropic
- 🔍 Semantic Search - Find relevant memories using vector similarity
- 🔄 Reranking - Improve search relevance with rerankers (e.g. Cohere)
- 📜 History Tracking - Track memory changes (ADD/UPDATE/DELETE) with local SQLite history
- 👥 Multi-User - Isolated memory spaces per user/agent/run
- 🏷️ Metadata Filtering - Rich filtering with operators (eq, gt, in, contains, etc.)
Installation
Add to your Cargo.toml:
[]
= "0.2"
Feature Flags
| Feature | Description |
|---|---|
memory-store (default) |
In-memory vector store |
openai |
OpenAI embeddings and LLM |
ollama |
Ollama local embeddings and LLM |
anthropic |
Anthropic Claude LLM |
qdrant |
Qdrant vector database |
postgres |
PostgreSQL with pgvector |
redis |
Redis with vector search |
full |
All features |
Quick Start
use ;
async
With OpenAI (Real Embeddings + LLM Inference)
use ;
async
Advanced Capabilities
History Tracking
Track changes to your memories locally using SQLite:
use MemoryConfig;
use PathBuf;
let config = MemoryConfig ;
// Memories added/updated/deleted will now be logged
Reranking
Improve search results using a reranker (like Cohere):
use ;
let config = MemoryConfig ;
// Use rerank: true in SearchOptions
API Reference
Memory Methods
| Method | Description |
|---|---|
add(messages, options) |
Add memories from text or messages |
search(query, options) |
Search for relevant memories (w/ optional reranking) |
get(id) |
Get a memory by ID |
get_all(options) |
List all memories with filters |
update(id, content) |
Update a memory's content |
delete(id) |
Delete a memory |
history(id) |
Get version history of a memory |
reset(options) |
Delete all memories |
Scoping
Memories are scoped by user_id, agent_id, and/or run_id.
Examples
Run the examples:
# Basic usage
# History Tracking
# Reranking (Cohere)
# HuggingFace Embeddings
# Vector Stores
Architecture
mem0-rust/
├── src/
│ ├── embeddings/ # Embedders (Mock, OpenAI, Ollama, HuggingFace)
│ ├── vector_stores/ # Stores (Memory, Qdrant, Postgres, Redis)
│ ├── llms/ # LLMs (OpenAI, Ollama, Anthropic)
│ ├── history/ # History tracking (SQLite)
│ ├── rerankers/ # Rerankers (Cohere)
│ ├── memory/ # Core memory management
│ └── utils/ # Utilities
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License