Memory Modules Overview
Memory Modules Overview
MemOS provides a rich set of memory modules to meet various needs from rapid prototyping to production environments. This guide helps you quickly find the most suitable memory solution.
π― Quick Selection Guide
Not sure which to choose? Follow this decision tree:
- π Quick testing/demo β NaiveTextMemory
- π General text memory β GeneralTextMemory
- π€ User preference management β PreferenceTextMemory
- π³ Structured knowledge graph β TreeTextMemory
- β‘ Inference acceleration β KVCacheMemory
π Memory Module Categories
I. Textual Memory Series
Focused on storing and retrieving text-based memories, suitable for most application scenarios.
NaiveTextMemory: Simple Textual Memory
Use Cases: Rapid prototyping, demos, teaching, small-scale applications
Core Features:
- β Zero dependencies, pure in-memory storage
- β Keyword-based retrieval
- β Minimal API, get started in 5 minutes
- β File persistence support
Limitations:
- β No vector semantic search
- β Not suitable for large-scale data
- β Limited retrieval precision
π View Documentation
GeneralTextMemory: General-Purpose Textual Memory
Use Cases: Conversational agents, personal assistants, knowledge management systems
Core Features:
- β Vector-based semantic search
- β Rich metadata support (type, time, source, etc.)
- β Flexible filtering and querying
- β Suitable for medium to large-scale applications
Technical Requirements:
- Requires vector database (Qdrant, etc.)
- Requires embedding model
π View Documentation
PreferenceTextMemory: Preference Memory
Use Cases: Personalized recommendations, user profiling, intelligent assistants
Core Features:
- β Automatic detection of explicit and implicit preferences
- β Preference deduplication and conflict detection
- β Filter by preference type and strength
- β Vector semantic retrieval
Specialized Functions:
- Dual preference extraction (explicit/implicit)
- Preference strength scoring
- Temporal decay support
π View Documentation
TreeTextMemory: Hierarchical Structured Memory
Use Cases: Knowledge graphs, complex relationship reasoning, multi-hop queries
Core Features:
- β Graph database-based structured storage
- β Support for hierarchical relationships and causal chains
- β Multi-hop reasoning capabilities
- β Deduplication, conflict detection, memory scheduling
Advanced Features:
- Supports MultiModal Reader (images, URLs, files)
- Supports Internet Retrieval (BochaAI, Google, Bing)
- Working memory replacement mechanism
Technical Requirements:
- Requires graph database (Neo4j, etc.)
- Requires vector database and embedding model
π View Documentation
II. Specialized Memory Modules
Memory systems optimized for specific scenarios.
KVCacheMemory: Activation Memory
Use Cases: LLM inference acceleration, high-frequency background knowledge reuse
Core Features:
- β‘ Pre-computed KV Cache, skip repeated encoding
- β‘ Significantly reduce prefill phase computation
- β‘ Suitable for high-throughput scenarios
Typical Use Cases:
- FAQ caching
- Conversation history reuse
- Domain knowledge preloading
How It Works: Stable text memory β Pre-convert to KV Cache β Direct injection during inference
π View Documentation
ParametricMemory: Parametric Memory
Status: π§ Under Development
Design Goals:
- Encode knowledge into model weights (LoRA, expert modules)
- Dynamically load/unload capability modules
- Support multi-task, multi-role architecture
Future Features:
- Parameter module generation and compression
- Version control and rollback
- Hot-swappable capability modules
π View Documentation
III. Graph Database Backends
Provide graph storage capabilities for TreeTextMemory.
Neo4j Graph DB
Recommendation: βββββ
Features:
- Complete graph database functionality
- Support for vector-enhanced retrieval
- Multi-tenant architecture (v0.2.1+)
- Compatible with Community Edition
π View Documentation
Nebula Graph DB
Features:
- Distributed graph database
- High availability
- Suitable for large-scale deployment
π View Documentation
PolarDB Graph DB
Features:
- Alibaba Cloud PolarDB graph computing
- Cloud-native architecture
- Enterprise-grade reliability
π View Documentation
π Feature Comparison Table
| Feature | Naive | General | Preference | Tree | KVCache |
|---|---|---|---|---|---|
| Search Method | Keyword | Vector Semantic | Vector Semantic | Vector+Graph | N/A |
| Metadata Support | β | βββ | βββ | ββββ | - |
| Relationship Reasoning | β | β | β | β | - |
| Deduplication | β | β | βββ | ββββ | - |
| Scalability | Small | Medium-Large | Medium-Large | Large | - |
| Deployment Complexity | Minimal | Medium | Medium | Higher | Medium |
| Inference Acceleration | - | - | - | - | βββββ |
π οΈ Usage Scenario Recommendations
Scenario 1: Rapid Prototyping
Recommended: NaiveTextMemory
from memos.memories import NaiveTextMemory
memory = NaiveTextMemory()
memory.add("User likes coffee")
results = memory.search("coffee")
Scenario 2: Chatbot Memory
Recommended: GeneralTextMemory
- Supports semantic search
- Filter by time, type, source
- Suitable for conversation history management
Scenario 3: Personalized Recommendation System
Recommended: PreferenceTextMemory
- Automatic user preference extraction
- Preference conflict detection
- Strength scoring and filtering
Scenario 4: Knowledge Graph Applications
Recommended: TreeTextMemory
- Multi-hop relationship queries
- Hierarchical structure management
- Complex reasoning scenarios
Scenario 5: High-Performance LLM Services
Recommended: KVCacheMemory
- FAQ systems
- Customer service bots
- High-volume request processing
π Advanced Features
MultiModal Reader (Multimodal Reading)
Supported in TreeTextMemory for processing:
- π· Images in conversations
- π Web URLs
- π Local files (PDF, DOCX, TXT, Markdown)
- π Mixed mode (text+images+URLs)
π View Examples
Internet Retrieval
Fetch real-time information from the web and add to memory:
- π BochaAI search
- π Google search
- π Bing search
π View Examples
π Quick Start
- Choose Memory Module - Select the appropriate module based on the guide above
- Read Documentation - Click the corresponding link to view detailed documentation
- Hands-On Practice - Each module has complete code examples
- Production Deployment - Refer to the best practices section
π Related Resources
Beginner Suggestion: Start with NaiveTextMemory, understand the basic concepts, then explore GeneralTextMemory and TreeTextMemory.
MemFeedback
MemFeedback enables your Agent to understand 'You remembered it wrong' and automatically correct the memory database. It is a key component for self-evolving memory.
Naive Textual Memory
The most lightweight memory module in MemOS, designed for rapid prototyping and simple scenarios. No vector database requiredβquickly retrieve memories using keyword matching.