Mem0 1.0.0 (#3545)

This commit is contained in:
Parshva Daftari
2025-10-16 15:50:20 +05:30
committed by GitHub
parent 8f5151c344
commit 394203d1b5
77 changed files with 3445 additions and 990 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
<Note type="info">
📢 Announcing our research paper: Mem0 achieves <strong>26%</strong> higher accuracy than OpenAI Memory, <strong>91%</strong> lower latency, and <strong>90%</strong> token savings! [Read the paper](https://mem0.ai/research) to learn how we're revolutionizing AI agent memory.
<strong>🎉 Mem0 1.0.0 is here!</strong> Enhanced filtering, reranking, and smarter memory management.
</Note>
@@ -25,8 +25,7 @@ memories = m.get_all(
"created_at": {"gte": "2024-07-01", "lte": "2024-07-31"}
}
]
},
version="v2"
}
)
```
@@ -58,8 +57,7 @@ memories = m.get_all(
"run_id": "*"
}
]
},
version="v2"
}
)
```
</CodeGroup>
@@ -1,5 +1,5 @@
---
title: 'Search Memories (v2)'
title: 'Search Memories'
openapi: post /v2/memories/search/
---
@@ -17,7 +17,6 @@ The v2 search API is powerful and flexible, allowing for more precise memory ret
```python Code
related_memories = m.search(
query="What are Alice's hobbies?",
version="v2",
filters={
"OR": [
{
@@ -56,7 +55,6 @@ related_memories = m.search(
# Using wildcard to match all run_ids for a specific user
all_memories = m.search(
query="What are Alice's hobbies?",
version="v2",
filters={
"AND": [
{
@@ -76,7 +74,6 @@ all_memories = m.search(
# Example 1: Using 'contains' for partial matching
finance_memories = m.search(
query="What are my financial goals?",
version="v2",
filters={
"AND": [
{ "user_id": "alice" },
@@ -92,7 +89,6 @@ finance_memories = m.search(
# Example 2: Using 'in' for exact matching
personal_memories = m.search(
query="What personal information do you have?",
version="v2",
filters={
"AND": [
{ "user_id": "alice" },
@@ -106,11 +102,3 @@ personal_memories = m.search(
)
```
</CodeGroup>
## Graph Memory
To retrieve memories with graph-based relationships, pass the `enable_graph=True` parameter. This includes relationship data in the response for more contextual results.
<Note>
Learn more in the [Graph Memory documentation](/platform/features/graph-memory).
</Note>
+76 -114
View File
@@ -1,145 +1,107 @@
---
title: Configuration
title: Config
description: 'Configuration options for rerankers in Mem0'
icon: "gear"
iconType: "solid"
---
## How to define configurations?
## Common Configuration Parameters
The `reranker` configuration is defined as an object with two main keys:
- `provider`: The name of the reranker provider (e.g., "cohere", "sentence_transformer", "huggingface", "llm_reranker")
- `config`: A nested dictionary containing provider-specific settings
All rerankers share these common configuration parameters:
## Basic Configuration
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `provider` | Reranker provider name | `str` | Required |
| `top_k` | Maximum number of results to return after reranking | `int` | `None` |
| `api_key` | API key for the reranker service | `str` | `None` |
Here's how to configure a reranker with Mem0:
## Provider-Specific Configuration
```python
from mem0 import Memory
### Zero Entropy
config = {
"reranker": {
"provider": "cohere",
"config": {
"api_key": "your-api-key",
"top_n": 10,
"model": "rerank-english-v3.0"
}
}
}
memory = Memory.from_config(config)
```
## Configuration Parameters
| Parameter | Description | Required | Default |
|-----------|-------------|----------|---------|
| `provider` | Reranker provider name | Yes | - |
| `config` | Provider-specific configuration | Yes | - |
### Common Config Parameters
| Parameter | Description | Providers |
|-----------|-------------|-----------|
| `api_key` | API key for the service | Cohere, Hugging Face |
| `model` | Model name to use | All |
| `top_n` | Number of results to return | All |
| `device` | Device to run on (cpu/cuda/mps) | Sentence Transformer, Hugging Face |
## Provider-Specific Examples
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `model` | Model to use: `zerank-1` or `zerank-1-small` | `str` | `"zerank-1"` |
| `api_key` | Zero Entropy API key | `str` | `None` |
### Cohere
```python
config = {
"reranker": {
"provider": "cohere",
"config": {
"api_key": "your-cohere-api-key",
"model": "rerank-english-v3.0",
"top_n": 5
}
}
}
```
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `model` | Cohere rerank model | `str` | `"rerank-english-v3.0"` |
| `api_key` | Cohere API key | `str` | `None` |
| `return_documents` | Whether to return document texts in response | `bool` | `False` |
| `max_chunks_per_doc` | Maximum chunks per document | `int` | `None` |
### Sentence Transformer
```python
config = {
"reranker": {
"provider": "sentence_transformer",
"config": {
"model": "cross-encoder/ms-marco-MiniLM-L-6-v2",
"device": "cpu",
"top_n": 10
}
}
}
```
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `model` | HuggingFace cross-encoder model name | `str` | `"cross-encoder/ms-marco-MiniLM-L-6-v2"` |
| `device` | Device to run model on (`cpu`, `cuda`, etc.) | `str` | `None` |
| `batch_size` | Batch size for processing | `int` | `32` |
| `show_progress_bar` | Show progress during processing | `bool` | `False` |
### Hugging Face
```python
config = {
"reranker": {
"provider": "huggingface",
"config": {
"api_key": "your-hf-token",
"model": "BAAI/bge-reranker-large",
"top_n": 8
}
}
}
```
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `model` | HuggingFace reranker model name | `str` | `"BAAI/bge-reranker-large"` |
| `api_key` | HuggingFace API token | `str` | `None` |
| `device` | Device to run model on (`cpu`, `cuda`, etc.) | `str` | `None` |
### LLM-based
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `model` | LLM model to use for scoring | `str` | `"gpt-4o-mini"` |
| `provider` | LLM provider (`openai`, `anthropic`, etc.) | `str` | `"openai"` |
| `api_key` | API key for LLM provider | `str` | `None` |
| `temperature` | Temperature for LLM generation | `float` | `0.0` |
| `max_tokens` | Maximum tokens for LLM response | `int` | `100` |
| `scoring_prompt` | Custom prompt template for scoring | `str` | Default scoring prompt |
### LLM Reranker
```python
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `llm.provider` | LLM provider for reranking | `str` | Required |
| `llm.config` | LLM configuration object | `dict` | Required |
| `top_n` | Number of results to return | `int` | `None` |
## Environment Variables
You can set API keys using environment variables:
- `ZERO_ENTROPY_API_KEY` - Zero Entropy API key
- `COHERE_API_KEY` - Cohere API key
- `HUGGINGFACE_API_KEY` - HuggingFace API token
- `OPENAI_API_KEY` - OpenAI API key (for LLM-based reranker)
- `ANTHROPIC_API_KEY` - Anthropic API key (for LLM-based reranker)
## Basic Configuration Example
```python Python
config = {
"reranker": {
"provider": "llm_reranker",
"vector_store": {
"provider": "chroma",
"config": {
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4",
"api_key": "your-openai-key"
}
},
"top_n": 5
"collection_name": "my_memories",
"path": "./chroma_db"
}
}
}
```
## Advanced Configuration
You can combine rerankers with other components:
```python
config = {
},
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4",
"api_key": "your-openai-key"
"model": "gpt-4o-mini"
}
},
"vector_store": {
"provider": "qdrant",
"rerank": {
"provider": "zero_entropy",
"config": {
"collection_name": "memories",
"host": "localhost",
"port": 6333
}
},
"reranker": {
"provider": "cohere",
"config": {
"api_key": "your-cohere-key",
"model": "rerank-english-v3.0",
"top_n": 10
"model": "zerank-1",
"top_k": 5
}
}
}
```
For provider-specific configuration details, visit the individual reranker pages.
+108 -77
View File
@@ -1,116 +1,147 @@
---
title: Cohere
description: 'Reranking with Cohere'
icon: "building"
iconType: "solid"
---
Cohere provides state-of-the-art reranking models that can significantly improve the relevance of search results. Cohere's rerankers are optimized for various languages and use cases.
Cohere provides enterprise-grade reranking models with excellent multilingual support and production-ready performance.
## Usage
## Models
To use Cohere's reranker with Mem0:
Cohere offers several reranking models:
```python
import os
- **`rerank-english-v3.0`**: Latest English reranker with best performance
- **`rerank-multilingual-v3.0`**: Multilingual support for global applications
- **`rerank-english-v2.0`**: Previous generation English reranker
## Installation
```bash
pip install cohere
```
## Configuration
```python Python
from mem0 import Memory
os.environ["COHERE_API_KEY"] = "your-cohere-api-key"
config = {
"vector_store": {
"provider": "chroma",
"config": {
"collection_name": "my_memories",
"path": "./chroma_db"
}
},
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4o-mini"
}
},
"reranker": {
"provider": "cohere",
"config": {
"api_key": "your-cohere-api-key", # Can also use environment variable
"model": "rerank-english-v3.0",
"top_n": 10
"api_key": "your-cohere-api-key", # or set COHERE_API_KEY
"top_k": 5,
"return_documents": False,
"max_chunks_per_doc": None
}
}
}
memory = Memory.from_config(config)
```
## Environment Variables
Set your API key as an environment variable:
```bash
export COHERE_API_KEY="your-api-key"
```
## Usage Example
```python Python
import os
from mem0 import Memory
# Set API key
os.environ["COHERE_API_KEY"] = "your-api-key"
# Initialize memory with Cohere reranker
config = {
"vector_store": {"provider": "chroma"},
"llm": {"provider": "openai", "config": {"model": "gpt-4o-mini"}},
"rerank": {
"provider": "cohere",
"config": {
"model": "rerank-english-v3.0",
"top_k": 3
}
}
}
memory = Memory.from_config(config)
# Use memory as usual
memory.add("I love playing basketball", user_id="alice")
memory.add("I enjoy watching movies", user_id="alice")
# Add memories
messages = [
{"role": "user", "content": "I work as a data scientist at Microsoft"},
{"role": "user", "content": "I specialize in machine learning and NLP"},
{"role": "user", "content": "I enjoy playing tennis on weekends"}
]
# Search will now use Cohere reranking
results = memory.search("What sports does Alice like?", user_id="alice")
memory.add(messages, user_id="bob")
# Search with reranking
results = memory.search("What is the user's profession?", user_id="bob")
for result in results['results']:
print(f"Memory: {result['memory']}")
print(f"Vector Score: {result['score']:.3f}")
print(f"Rerank Score: {result['rerank_score']:.3f}")
print()
```
## Configuration
## Multilingual Support
| Parameter | Description | Default |
|-----------|-------------|---------|
| `api_key` | Cohere API key | Required |
| `model` | Cohere rerank model | `rerank-english-v3.0` |
| `top_n` | Number of results to return | `10` |
For multilingual applications, use the multilingual model:
## Available Models
- `rerank-english-v3.0`: Latest English reranking model
- `rerank-multilingual-v3.0`: Multilingual reranking model
- `rerank-english-v2.0`: Previous English model
- `rerank-multilingual-v2.0`: Previous multilingual model
## Example with Different Models
### English Reranker
```python
```python Python
config = {
"reranker": {
"rerank": {
"provider": "cohere",
"config": {
"api_key": "your-cohere-api-key",
"model": "rerank-english-v3.0",
"top_n": 5
}
}
}
```
### Multilingual Reranker
```python
config = {
"reranker": {
"provider": "cohere",
"config": {
"api_key": "your-cohere-api-key",
"model": "rerank-multilingual-v3.0",
"top_n": 8
"top_k": 5
}
}
}
```
## Environment Variables
## Configuration Parameters
You can set your Cohere API key as an environment variable:
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `model` | Cohere rerank model to use | `str` | `"rerank-english-v3.0"` |
| `api_key` | Cohere API key | `str` | `None` |
| `top_k` | Maximum documents to return | `int` | `None` |
| `return_documents` | Whether to return document texts | `bool` | `False` |
| `max_chunks_per_doc` | Maximum chunks per document | `int` | `None` |
```bash
export COHERE_API_KEY="your-cohere-api-key"
```
## Features
Then use the config without specifying the API key:
- **High Quality**: Enterprise-grade relevance scoring
- **Multilingual**: Support for 100+ languages
- **Scalable**: Production-ready with high throughput
- **Reliable**: SLA-backed service with 99.9% uptime
```python
config = {
"reranker": {
"provider": "cohere",
"config": {
"model": "rerank-english-v3.0",
"top_n": 10
}
}
}
```
## Best Practices
## Getting Your API Key
1. Sign up at [Cohere](https://cohere.ai/)
2. Navigate to the API keys section in your dashboard
3. Generate a new API key
4. Use this key in your configuration
## Performance Considerations
- Cohere rerankers work best with 10-100 candidate documents
- Higher `top_n` values provide more comprehensive reranking but may increase latency
- The v3.0 models generally provide better performance than v2.0 models
1. **Model Selection**: Use `rerank-english-v3.0` for English, `rerank-multilingual-v3.0` for other languages
2. **Batch Processing**: Process multiple queries efficiently
3. **Error Handling**: Implement retry logic for production systems
4. **Monitoring**: Track reranking performance and costs
+224
View File
@@ -0,0 +1,224 @@
---
title: LLM as Reranker
description: 'Flexible reranking using LLMs'
icon: "robot"
iconType: "solid"
---
LLM-based reranker provides maximum flexibility by using any Large Language Model to score document relevance. This approach allows for custom prompts and domain-specific scoring logic.
## Supported LLM Providers
Any LLM provider supported by Mem0 can be used for reranking:
- **OpenAI**: GPT-4, GPT-3.5-turbo, etc.
- **Anthropic**: Claude models
- **Together**: Open-source models
- **Groq**: Fast inference
- **Ollama**: Local models
- And more...
## Configuration
```python Python
from mem0 import Memory
config = {
"vector_store": {
"provider": "chroma",
"config": {
"collection_name": "my_memories",
"path": "./chroma_db"
}
},
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4o-mini"
}
},
"rerank": {
"provider": "llm",
"config": {
"model": "gpt-4o-mini",
"provider": "openai",
"api_key": "your-openai-api-key", # or set OPENAI_API_KEY
"top_k": 5,
"temperature": 0.0
}
}
}
memory = Memory.from_config(config)
```
## Custom Scoring Prompt
You can provide a custom prompt for relevance scoring:
```python Python
custom_prompt = """You are a relevance scoring assistant. Rate how well this document answers the query.
Query: "{query}"
Document: "{document}"
Score from 0.0 to 1.0 where:
- 1.0: Perfect match, directly answers the query
- 0.8-0.9: Highly relevant, good match
- 0.6-0.7: Moderately relevant, partial match
- 0.4-0.5: Slightly relevant, limited useful information
- 0.0-0.3: Not relevant or no useful information
Provide only a single numerical score between 0.0 and 1.0."""
config["rerank"]["config"]["scoring_prompt"] = custom_prompt
```
## Usage Example
```python Python
import os
from mem0 import Memory
# Set API key
os.environ["OPENAI_API_KEY"] = "your-api-key"
# Initialize memory with LLM reranker
config = {
"vector_store": {"provider": "chroma"},
"llm": {"provider": "openai", "config": {"model": "gpt-4o-mini"}},
"rerank": {
"provider": "llm",
"config": {
"model": "gpt-4o-mini",
"provider": "openai",
"temperature": 0.0
}
}
}
memory = Memory.from_config(config)
# Add memories
messages = [
{"role": "user", "content": "I'm learning Python programming"},
{"role": "user", "content": "I find object-oriented programming challenging"},
{"role": "user", "content": "I love hiking in national parks"}
]
memory.add(messages, user_id="david")
# Search with LLM reranking
results = memory.search("What programming topics is the user studying?", user_id="david")
for result in results['results']:
print(f"Memory: {result['memory']}")
print(f"Vector Score: {result['score']:.3f}")
print(f"Rerank Score: {result['rerank_score']:.3f}")
print()
```
```text Output
Memory: I'm learning Python programming
Vector Score: 0.856
Rerank Score: 0.920
Memory: I find object-oriented programming challenging
Vector Score: 0.782
Rerank Score: 0.850
```
## Domain-Specific Scoring
Create specialized scoring for your domain:
```python Python
medical_prompt = """You are a medical relevance expert. Score how relevant this medical record is to the clinical query.
Clinical Query: "{query}"
Medical Record: "{document}"
Consider:
- Clinical relevance and accuracy
- Patient safety implications
- Diagnostic value
- Treatment relevance
Score from 0.0 to 1.0. Provide only the numerical score."""
config = {
"rerank": {
"provider": "llm",
"config": {
"model": "gpt-4o-mini",
"provider": "openai",
"scoring_prompt": medical_prompt,
"temperature": 0.0
}
}
}
```
## Multiple LLM Providers
Use different LLM providers for reranking:
```python Python
# Using Anthropic Claude
anthropic_config = {
"rerank": {
"provider": "llm",
"config": {
"model": "claude-3-haiku-20240307",
"provider": "anthropic",
"temperature": 0.0
}
}
}
# Using local Ollama model
ollama_config = {
"rerank": {
"provider": "llm",
"config": {
"model": "llama2:7b",
"provider": "ollama",
"temperature": 0.0
}
}
}
```
## Configuration Parameters
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `model` | LLM model to use for scoring | `str` | `"gpt-4o-mini"` |
| `provider` | LLM provider name | `str` | `"openai"` |
| `api_key` | API key for the LLM provider | `str` | `None` |
| `top_k` | Maximum documents to return | `int` | `None` |
| `temperature` | Temperature for LLM generation | `float` | `0.0` |
| `max_tokens` | Maximum tokens for LLM response | `int` | `100` |
| `scoring_prompt` | Custom prompt template | `str` | Default prompt |
## Advantages
- **Maximum Flexibility**: Custom prompts for any use case
- **Domain Expertise**: Leverage LLM knowledge for specialized domains
- **Interpretability**: Understand scoring through prompt engineering
- **Multi-criteria**: Score based on multiple relevance factors
## Considerations
- **Latency**: Higher latency than specialized rerankers
- **Cost**: LLM API costs per reranking operation
- **Consistency**: May have slight variations in scoring
- **Prompt Engineering**: Requires careful prompt design
## Best Practices
1. **Temperature**: Use 0.0 for consistent scoring
2. **Prompt Design**: Be specific about scoring criteria
3. **Token Efficiency**: Keep prompts concise to reduce costs
4. **Caching**: Cache results for repeated queries when possible
5. **Fallback**: Handle API errors gracefully
@@ -1,162 +1,161 @@
---
title: Sentence Transformer
description: 'Local reranking with HuggingFace cross-encoder models'
icon: "server"
iconType: "solid"
---
Sentence Transformer rerankers use cross-encoder models that are specifically designed for ranking tasks. These models can run locally and provide good reranking performance without external API calls.
Sentence Transformer reranker provides local reranking using HuggingFace cross-encoder models, perfect for privacy-focused deployments where you want to keep data on-premises.
## Usage
## Models
To use Sentence Transformer reranker with Mem0:
Any HuggingFace cross-encoder model can be used. Popular choices include:
```python
- **`cross-encoder/ms-marco-MiniLM-L-6-v2`**: Default, good balance of speed and accuracy
- **`cross-encoder/ms-marco-TinyBERT-L-2-v2`**: Fastest, smaller model size
- **`cross-encoder/ms-marco-electra-base`**: Higher accuracy, larger model
- **`cross-encoder/stsb-distilroberta-base`**: Good for semantic similarity tasks
## Installation
```bash
pip install sentence-transformers
```
## Configuration
```python Python
from mem0 import Memory
config = {
"reranker": {
"vector_store": {
"provider": "chroma",
"config": {
"collection_name": "my_memories",
"path": "./chroma_db"
}
},
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4o-mini"
}
},
"rerank": {
"provider": "sentence_transformer",
"config": {
"model": "cross-encoder/ms-marco-MiniLM-L-6-v2",
"device": "cpu",
"top_n": 10
"device": "cpu", # or "cuda" for GPU
"batch_size": 32,
"show_progress_bar": False,
"top_k": 5
}
}
}
memory = Memory.from_config(config)
```
## GPU Acceleration
For better performance, use GPU acceleration:
```python Python
config = {
"rerank": {
"provider": "sentence_transformer",
"config": {
"model": "cross-encoder/ms-marco-MiniLM-L-6-v2",
"device": "cuda", # Use GPU
"batch_size": 64 # high batch size for high memory GPUs
}
}
}
```
## Usage Example
```python Python
from mem0 import Memory
# Initialize memory with local reranker
config = {
"vector_store": {"provider": "chroma"},
"llm": {"provider": "openai", "config": {"model": "gpt-4o-mini"}},
"rerank": {
"provider": "sentence_transformer",
"config": {
"model": "cross-encoder/ms-marco-MiniLM-L-6-v2",
"device": "cpu"
}
}
}
memory = Memory.from_config(config)
# Use memory as usual
memory.add("I love playing basketball", user_id="alice")
memory.add("I enjoy watching movies", user_id="alice")
# Add memories
messages = [
{"role": "user", "content": "I love reading science fiction novels"},
{"role": "user", "content": "My favorite author is Isaac Asimov"},
{"role": "user", "content": "I also enjoy watching sci-fi movies"}
]
# Search will now use Sentence Transformer reranking
results = memory.search("What sports does Alice like?", user_id="alice")
```
memory.add(messages, user_id="charlie")
## Configuration
# Search with local reranking
results = memory.search("What books does the user like?", user_id="charlie")
| Parameter | Description | Default |
|-----------|-------------|---------|
| `model` | Sentence Transformer cross-encoder model | `cross-encoder/ms-marco-MiniLM-L-6-v2` |
| `device` | Device to run on (`cpu`, `cuda`, `mps`) | `cpu` |
| `top_n` | Number of results to return | `10` |
## Popular Models
### Lightweight Models
- `cross-encoder/ms-marco-MiniLM-L-6-v2`: Fast and efficient
- `cross-encoder/ms-marco-MiniLM-L-4-v2`: Even faster, slightly lower accuracy
- `cross-encoder/ms-marco-MiniLM-L-2-v2`: Fastest, good for real-time applications
### High-Performance Models
- `cross-encoder/ms-marco-electra-base`: Better accuracy, larger model
- `ms-marco-MiniLM-L-12-v2`: Balanced performance and speed
- `cross-encoder/qnli-electra-base`: Good for question-answering tasks
## Device Configuration
### CPU Usage
```python
config = {
"reranker": {
"provider": "sentence_transformer",
"config": {
"model": "cross-encoder/ms-marco-MiniLM-L-6-v2",
"device": "cpu",
"top_n": 10
}
}
}
```
### GPU Usage (CUDA)
```python
config = {
"reranker": {
"provider": "sentence_transformer",
"config": {
"model": "cross-encoder/ms-marco-electra-base",
"device": "cuda",
"top_n": 15
}
}
}
```
### Apple Silicon (MPS)
```python
config = {
"reranker": {
"provider": "sentence_transformer",
"config": {
"model": "cross-encoder/ms-marco-MiniLM-L-6-v2",
"device": "mps",
"top_n": 10
}
}
}
```
## Installation
The sentence-transformers library is required:
```bash
pip install sentence-transformers
```
For GPU support with CUDA:
```bash
pip install sentence-transformers torch
```
## Performance Optimization
### Model Selection
- Use MiniLM models for faster inference
- Use larger models (electra-base) for better accuracy
- Consider the trade-off between speed and quality
### Device Optimization
- Use GPU (`cuda` or `mps`) for larger models
- CPU is sufficient for MiniLM models
- Batch processing improves GPU utilization
### Memory Considerations
```python
# For memory-constrained environments
config = {
"reranker": {
"provider": "sentence_transformer",
"config": {
"model": "cross-encoder/ms-marco-MiniLM-L-2-v2", # Smallest model
"device": "cpu",
"top_n": 5 # Fewer results to process
}
}
}
for result in results['results']:
print(f"Memory: {result['memory']}")
print(f"Vector Score: {result['score']:.3f}")
print(f"Rerank Score: {result['rerank_score']:.3f}")
print()
```
## Custom Models
You can use any Sentence Transformer cross-encoder model:
You can use any HuggingFace cross-encoder model:
```python
```python Python
# Using a different model
config = {
"reranker": {
"provider": "sentence_transformer",
"rerank": {
"provider": "sentence_transformer",
"config": {
"model": "your-custom-model-name",
"device": "cpu",
"top_n": 10
"model": "cross-encoder/stsb-distilroberta-base",
"device": "cpu"
}
}
}
```
## Configuration Parameters
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `model` | HuggingFace cross-encoder model name | `str` | `"cross-encoder/ms-marco-MiniLM-L-6-v2"` |
| `device` | Device to run model on (`cpu`, `cuda`, etc.) | `str` | `None` |
| `batch_size` | Batch size for processing documents | `int` | `32` |
| `show_progress_bar` | Show progress bar during processing | `bool` | `False` |
| `top_k` | Maximum documents to return | `int` | `None` |
## Advantages
- **Local Processing**: No external API calls required
- **Privacy**: Data stays on your infrastructure
- **Cost Effective**: No per-request charges
- **Fast**: Especially with GPU acceleration
- **Customizable**: Can fine-tune on your specific data
- **Privacy**: Complete local processing, no external API calls
- **Cost**: No per-token charges after initial model download
- **Customization**: Use any HuggingFace cross-encoder model
- **Offline**: Works without internet connection after model download
## Performance Considerations
- **First Run**: Model download may take time initially
- **Memory Usage**: Models require GPU/CPU memory
- **Batch Size**: Optimize batch size based on available memory
- **Device**: GPU acceleration significantly improves speed
## Best Practices
1. **Model Selection**: Choose model based on accuracy vs speed requirements
2. **Device Management**: Use GPU when available for better performance
3. **Batch Processing**: Process multiple documents together for efficiency
4. **Memory Monitoring**: Monitor system memory usage with larger models
@@ -0,0 +1,119 @@
---
title: Zero Entropy
description: 'Neural reranking with Zero Entropy'
icon: "sparkles"
iconType: "solid"
---
[Zero Entropy](https://www.zeroentropy.dev) provides neural reranking models that significantly improve search relevance with fast performance.
## Models
Zero Entropy offers two reranking models:
- **`zerank-1`**: Flagship state-of-the-art reranker (non-commercial license)
- **`zerank-1-small`**: Open-source model (Apache 2.0 license)
## Installation
```bash
pip install zeroentropy
```
## Configuration
```python Python
from mem0 import Memory
config = {
"vector_store": {
"provider": "chroma",
"config": {
"collection_name": "my_memories",
"path": "./chroma_db"
}
},
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4o-mini"
}
},
"rerank": {
"provider": "zero_entropy",
"config": {
"model": "zerank-1", # or "zerank-1-small"
"api_key": "your-zero-entropy-api-key", # or set ZERO_ENTROPY_API_KEY
"top_k": 5
}
}
}
memory = Memory.from_config(config)
```
## Environment Variables
Set your API key as an environment variable:
```bash
export ZERO_ENTROPY_API_KEY="your-api-key"
```
## Usage Example
```python Python
import os
from mem0 import Memory
# Set API key
os.environ["ZERO_ENTROPY_API_KEY"] = "your-api-key"
# Initialize memory with Zero Entropy reranker
config = {
"vector_store": {"provider": "chroma"},
"llm": {"provider": "openai", "config": {"model": "gpt-4o-mini"}},
"rerank": {"provider": "zero_entropy", "config": {"model": "zerank-1"}}
}
memory = Memory.from_config(config)
# Add memories
messages = [
{"role": "user", "content": "I love Italian pasta, especially carbonara"},
{"role": "user", "content": "Japanese sushi is also amazing"},
{"role": "user", "content": "I enjoy cooking Mediterranean dishes"}
]
memory.add(messages, user_id="alice")
# Search with reranking
results = memory.search("What Italian food does the user like?", user_id="alice")
for result in results['results']:
print(f"Memory: {result['memory']}")
print(f"Vector Score: {result['score']:.3f}")
print(f"Rerank Score: {result['rerank_score']:.3f}")
print()
```
## Configuration Parameters
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| `model` | Model to use: `"zerank-1"` or `"zerank-1-small"` | `str` | `"zerank-1"` |
| `api_key` | Zero Entropy API key | `str` | `None` |
| `top_k` | Maximum documents to return after reranking | `int` | `None` |
## Performance
- **Fast**: Optimized neural architecture for low latency
- **Accurate**: State-of-the-art relevance scoring
- **Cost-effective**: ~$0.025/1M tokens processed
## Best Practices
1. **Model Selection**: Use `zerank-1` for best quality, `zerank-1-small` for faster processing
2. **Batch Size**: Process multiple queries together when possible
3. **Top-k Limiting**: Set reasonable `top_k` values (5-20) for best performance
4. **API Key Management**: Use environment variables for secure key storage
+56 -38
View File
@@ -1,52 +1,70 @@
---
title: Overview
icon: "info"
icon: "arrow-up-arrow-down"
iconType: "solid"
---
Rerankers enhance the quality of search results by re-ordering the initial retrieval results using more sophisticated scoring mechanisms. They act as a secondary ranking layer that can significantly improve the relevance of retrieved memories.
## How Rerankers Work
1. **Initial Retrieval**: Vector search returns candidate memories based on semantic similarity
2. **Reranking**: The reranker evaluates and re-scores these candidates using more complex criteria
3. **Final Results**: Returns the top-k memories with improved relevance ordering
## Benefits
- **Improved Precision**: Better ranking of relevant memories
- **Context Awareness**: More sophisticated understanding of query-memory relationships
- **Performance**: Can improve results without changing the underlying vector store
## Supported Rerankers
Mem0 supports several reranker models:
<CardGroup cols={2}>
<Card title="Cohere" href="/components/rerankers/models/cohere" />
<Card title="Sentence Transformer" href="/components/rerankers/models/sentence_transformer" />
<Card title="Hugging Face" href="/components/rerankers/models/huggingface" />
<Card title="LLM Reranker" href="/components/rerankers/models/llm_reranker" />
</CardGroup>
Mem0 includes built-in support for various reranking providers to improve the relevance of memory search results. Rerankers post-process initial vector search results by re-scoring and re-ordering them using more sophisticated relevance models.
## Usage
Rerankers are configured as part of the memory configuration:
To use a reranker:
1. **Configure**: Add a `rerank` configuration section in your memory config
2. **Search**: Reranking is automatically enabled for all searches (default: `rerank=True`)
If no reranker is configured, search results will rely on vector similarity scoring alone.
For comprehensive configuration parameters for each reranker, please refer to [Config](./config).
### Controlling Reranking Per Search
Once configured, reranking is enabled by default. You can control it per-search:
```python
from mem0 import Memory
# Reranking enabled (default)
results = memory.search("query", user_id="user1")
config = {
"reranker": {
"provider": "cohere",
"config": {
"api_key": "your-api-key",
"top_n": 10
}
}
}
# Explicitly enable reranking
results = memory.search("query", user_id="user1", rerank=True)
memory = Memory.from_config(config)
# Disable reranking for this specific search
results = memory.search("query", user_id="user1", rerank=False)
```
For detailed configuration options, see the [Config](./config) page.
## How Reranking Works
1. **Initial Search**: Vector similarity search retrieves candidate memories
2. **Reranking** (if enabled): Selected reranker re-scores candidates using advanced models
3. **Final Results**: Re-ordered results with both vector and rerank scores
<Note>
Reranking operates as a post-processing step and can significantly improve search relevance at the cost of additional latency and API calls.
</Note>
## Supported Rerankers
See the list of supported rerankers below.
<CardGroup cols={2}>
<Card title="Zero Entropy" href="/components/rerankers/models/zero_entropy" />
<Card title="Cohere" href="/components/rerankers/models/cohere" />
<Card title="Sentence Transformer" href="/components/rerankers/models/sentence_transformer" />
<Card title="Hugging Face" href="/components/rerankers/models/huggingface" />
<Card title="LLM-based" href="/components/rerankers/models/llm" />
<Card title="LLM Reranker" href="/components/rerankers/models/llm_reranker" />
</CardGroup>
## When to Use Reranking
- **Improved Relevance**: When vector search alone doesn't provide sufficiently relevant results
- **Domain-Specific Queries**: For specialized terminology or context that benefits from advanced models
- **Quality vs Speed Trade-off**: When you can accept higher latency for better search quality
- **Production Systems**: Where search quality directly impacts user experience
Choose the reranker that best fits your use case:
- **Zero Entropy**: Best balance of speed and quality for general use
- **Cohere**: Enterprise-grade with excellent multilingual support
- **Sentence Transformer**: Local deployment for privacy-sensitive applications
- **Hugging Face**: Wide variety of pre-trained models for specialized use cases
- **LLM-based**: Maximum customization with custom prompts and logic
+1 -1
View File
@@ -57,7 +57,7 @@ messages = [
client.add(
messages=messages,
user_id="alice",
version="v2"
)
```
@@ -58,7 +58,7 @@ filters = {
]
}
results = client.search(query, version="v2", filters=filters)
results = client.search(query, filters=filters)
```
```javascript JavaScript
@@ -74,7 +74,6 @@ const filters = {
};
const results = await client.search(query, {
version: "v2",
filters
});
```
@@ -89,26 +88,78 @@ const results = await client.search(query, {
from mem0 import Memory
m = Memory()
# Simple search
related_memories = m.search("Should I drink coffee or tea?", user_id="alice")
# Search with filters
memories = m.search(
"food preferences",
user_id="alice",
filters={"categories": {"contains": "diet"}}
)
```
```javascript JavaScript
import { Memory } from 'mem0ai/oss';
const memory = new Memory();
// Simple search
const relatedMemories = memory.search("Should I drink coffee or tea?", { userId: "alice" });
// Search with filters (if supported)
const memories = memory.search("food preferences", {
userId: "alice",
filters: { categories: { contains: "diet" } }
});
```
</CodeGroup>
---
## Using Filters
Filters help narrow down search results. Common use cases:
**Filter by Session Context:**
```python
# Get memories from a specific agent session
m.search("query", user_id="alice", agent_id="chatbot", run_id="session-123")
```
**Filter by Date Range:**
```python
# Platform only - date filtering
client.search("recent memories", filters={
"AND": [
{"user_id": "alice"},
{"created_at": {"gte": "2024-07-01"}}
]
})
```
**Filter by Categories:**
```python
# Platform only - category filtering
client.search("preferences", filters={
"AND": [
{"user_id": "alice"},
{"categories": {"contains": "food"}}
]
})
```
---
## Tips for Better Search
- Use descriptive natural queries (Mem0 can interpret intent)
- Apply filters for scoped, faster lookups
- Use `version: "v2"` for enhanced results
- Consider wildcard filters (e.g., `run_id: "*"`) for broader matches
- Tune with `top_k`, `threshold`, or `rerank` if needed
- **Use natural language**: Mem0 understands intent, so describe what you're looking for naturally
- **Scope with session IDs**: Always provide at least `user_id` to scope search to relevant memories
- **Combine filters**: Use AND/OR logic to create precise queries (Platform)
- **Consider wildcard filters**: Use wildcard filters (e.g., `run_id: "*"`) for broader matches
- **Tune parameters**: Adjust `top_k` for result count, `threshold` for relevance cutoff
- **Enable reranking**: Use `rerank=True` (default) when you have a reranker configured
### More Details
+1 -1
View File
@@ -12,7 +12,7 @@
"navigation": {
"versions": [
{
"version": "v1.0.0 Beta",
"version": "v1.0.0",
"anchors": [
{
"anchor": "Documentation",
+32 -20
View File
@@ -84,7 +84,7 @@ class EmailProcessor:
user_id=user_id,
metadata=metadata,
categories=["email", "correspondence"],
version="v2"
)
return response
@@ -99,45 +99,57 @@ class EmailProcessor:
else:
return email.get_payload(decode=True).decode()
def search_emails(self, query, user_id):
def search_emails(self, query, user_id, sender=None):
"""
Search through stored emails
Args:
query (str): Search query
user_id (str): User identifier
sender (str, optional): Filter by sender email address
"""
# Search Mem0 for relevant emails
results = self.client.search(
query=query,
user_id=user_id,
categories=["email"],
version="v2"
)
# For Platform API, all filters including user_id go in filters object
if not sender:
# Simple filter - just user_id and category
filters = {
"AND": [
{"user_id": user_id},
{"categories": {"contains": "email"}}
]
}
results = self.client.search(query=query, filters=filters)
else:
# Advanced filter - add sender condition
filters = {
"AND": [
{"user_id": user_id},
{"categories": {"contains": "email"}},
{"sender": sender}
]
}
results = self.client.search(query=query, filters=filters)
return results
def get_email_thread(self, subject, user_id):
"""
Retrieve all emails in a thread based on subject
Args:
subject (str): Email subject to match
user_id (str): User identifier
"""
# For Platform API, user_id goes in the filters object
filters = {
"AND": [
{"user_id": user_id},
{"categories": {"contains": "email"}},
{"metadata": {"subject": {"contains": subject}}}
{"subject": {"icontains": subject}}
]
}
thread = self.client.get_all(
version="v2",
filters=filters
)
thread = self.client.get_all(filters=filters)
return thread
# Initialize the processor
@@ -180,5 +192,5 @@ print(f"Found {len(meeting_emails['results'])} relevant emails")
## Conclusion
By combining Mem0's memory capabilities with email processing, you can create intelligent email management systems that help users organize, prioritize, and act on their inbox effectively. Advanced capabilities like automatic categorization, action item extraction, and priority management can significantly reduce the time spent on email management, allowing users to focus on more important tasks.
By combining Mem0's memory capabilities with email processing, you can create intelligent email management systems that help users organize, prioritize, and act on their inbox effectively. The advanced capabilities like automatic categorization, action item extraction, and priority management can significantly reduce the time spent on email management, allowing users to focus on more important tasks.
+2 -2
View File
@@ -130,7 +130,7 @@ async def search_memories(
user_id=USER_ID,
limit=5,
threshold=0.7, # Higher threshold for more relevant results
output_format="v1.1"
)
# Format and return the results
@@ -346,7 +346,7 @@ async def search_memories(
user_id=USER_ID,
limit=5,
threshold=0.7, # Higher threshold for more relevant results
output_format="v1.1"
)
# Format and return the results
@@ -68,17 +68,12 @@ def apply_writing_style(original_content):
results = client.search(
query="What are my writing style preferences?",
version="v2",
filters={
"AND": [
{
"user_id": USER_ID
},
{
"run_id": RUN_ID
}
{"user_id": USER_ID},
{"run_id": RUN_ID}
]
},
}
)
if not results:
@@ -85,8 +85,9 @@ When a user makes a new search query, we retrieve relevant memories to enhance t
```python
def get_user_context(user_id, query):
filters = {"AND": [{"user_id": user_id}]}
user_memories = mem0_client.search(query=query, version="v2", filters=filters)
# For Platform API, user_id goes in filters
filters = {"user_id": user_id}
user_memories = mem0_client.search(query=query, filters=filters)
if user_memories:
context = "\n".join([f"- {memory['memory']}" for memory in user_memories])
@@ -151,7 +152,7 @@ def store_search_interaction(user_id, original_query, agent_response):
{"role": "user", "content": f"Searched for: {original_query}"},
{"role": "assistant", "content": f"Results based on preferences: {agent_response}"}
]
mem0_client.add(messages=interaction, user_id=user_id, output_format="v1.1")
mem0_client.add(messages=interaction, user_id=user_id)
```
### Full Example Run
+2 -2
View File
@@ -120,7 +120,7 @@ def chat_user(
})
# Store messages in memory
client.add(messages, user_id=user_id, output_format='v1.1')
client.add(messages, user_id=user_id)
print("✅ Image and text stored in memory.")
if user_input:
@@ -151,7 +151,7 @@ User question:
# Store the interaction in memory
interaction_message = [{"role": "user", "content": f"User: {user_input}\nAssistant: {response.content}"}]
client.add(interaction_message, user_id=user_id, output_format='v1.1')
client.add(interaction_message, user_id=user_id)
return response.content
return "No user input or image provided."
+4 -13
View File
@@ -122,10 +122,8 @@ Define the two key memory functions that will be registered as tools:
"""Add a message to the memory store"""
message = parameters.get("message")
await mem0_client.add(
messages=message,
user_id=USER_ID,
output_format="v1.1",
version="v2"
messages=message,
user_id=USER_ID
)
return "Memory added successfully"
@@ -133,19 +131,12 @@ Define the two key memory functions that will be registered as tools:
"""Retrieve relevant memories based on the input message"""
message = parameters.get("message")
# Set up filters to retrieve memories for this specific user
filters = {
"AND": [
{
"user_id": USER_ID
}
]
}
# For Platform API, user_id goes in filters
filters = {"user_id": USER_ID}
# Search for relevant memories using the message as a query
results = await mem0_client.search(
query=message,
version="v2",
filters=filters
)
+12 -5
View File
@@ -50,7 +50,9 @@ mem0 = MemoryClient()
# Define memory function tools
def search_memory(query: str, user_id: str) -> dict:
"""Search through past conversations and memories"""
memories = mem0.search(query, user_id=user_id)
# For Platform API, user_id goes in filters
filters = {"user_id": user_id}
memories = mem0.search(query, filters=filters)
if memories.get('results', []):
memory_list = memories['results']
memory_context = "\n".join([f"- {mem['memory']}" for mem in memory_list])
@@ -255,12 +257,17 @@ if __name__ == "__main__":
Customize memory behavior and agent setup:
```python
# Configure memory search with metadata
# Configure memory search with filters
# For Platform API, all filters including user_id go in filters object
memories = mem0.search(
query="travel preferences",
user_id="alice",
limit=5,
filters={"category": "travel"} # Filter by category if supported
filters={
"AND": [
{"user_id": "alice"},
{"categories": {"contains": "travel"}}
]
},
limit=5
)
# Configure agent with custom model settings
+10 -19
View File
@@ -53,7 +53,6 @@ class Message(BaseModel):
class AddMemoryInput(BaseModel):
messages: List[Message] = Field(description="List of messages to add to memory")
user_id: str = Field(description="ID of the user associated with these messages")
output_format: str = Field(description="Version format for the output")
metadata: Optional[Dict[str, Any]] = Field(description="Additional metadata for the messages", default=None)
class Config:
@@ -64,7 +63,6 @@ class AddMemoryInput(BaseModel):
{"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy."}
],
"user_id": "alex",
"output_format": "v1.1",
"metadata": {"food": "vegan"}
}]
}
@@ -73,10 +71,10 @@ class AddMemoryInput(BaseModel):
#### Implementation
```python
def add_memory(messages: List[Message], user_id: str, output_format: str, metadata: Optional[Dict[str, Any]] = None) -> Any:
def add_memory(messages: List[Message], user_id: str, metadata: Optional[Dict[str, Any]] = None) -> Any:
"""Add messages to memory with associated user ID and metadata."""
message_dicts = [msg.dict() for msg in messages]
return client.add(message_dicts, user_id=user_id, output_format=output_format, metadata=metadata)
return client.add(message_dicts, user_id=user_id, metadata=metadata)
add_tool = StructuredTool(
name="add_memory",
@@ -96,7 +94,6 @@ add_input = {
{"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy."}
],
"user_id": "alex",
"output_format": "v1.1",
"metadata": {"food": "vegan"}
}
add_result = add_tool.invoke(add_input)
@@ -132,7 +129,6 @@ The SEARCH tool enables querying stored memories using natural language queries
class SearchMemoryInput(BaseModel):
query: str = Field(description="The search query string")
filters: Dict[str, Any] = Field(description="Filters to apply to the search")
version: str = Field(description="Version of the memory to search")
class Config:
json_schema_extra = {
@@ -143,8 +139,7 @@ class SearchMemoryInput(BaseModel):
{"user_id": "alex"},
{"created_at": {"gte": "2024-01-01", "lte": "2024-12-31"}}
]
},
"version": "v2"
}
}]
}
```
@@ -152,9 +147,9 @@ class SearchMemoryInput(BaseModel):
#### Implementation
```python
def search_memory(query: str, filters: Dict[str, Any], version: str) -> Any:
def search_memory(query: str, filters: Dict[str, Any]) -> Any:
"""Search memory with the given query and filters."""
return client.search(query=query, version=version, filters=filters)
return client.search(query=query, filters=filters)
search_tool = StructuredTool(
name="search_memory",
@@ -172,11 +167,10 @@ search_input = {
"query": "what is my name?",
"filters": {
"AND": [
{"created_at": {"gte": "2024-07-20", "lte": "2024-12-10"}},
{"user_id": "alex"}
{"user_id": "alex"},
{"created_at": {"gte": "2024-07-20", "lte": "2024-12-10"}}
]
},
"version": "v2"
}
}
result = search_tool.invoke(search_input)
```
@@ -210,7 +204,6 @@ The GET_ALL tool retrieves all memories matching specified criteria, with suppor
```python
class GetAllMemoryInput(BaseModel):
version: str = Field(description="Version of the memory to retrieve")
filters: Dict[str, Any] = Field(description="Filters to apply to the retrieval")
page: Optional[int] = Field(description="Page number for pagination", default=1)
page_size: Optional[int] = Field(description="Number of items per page", default=50)
@@ -218,7 +211,6 @@ class GetAllMemoryInput(BaseModel):
class Config:
json_schema_extra = {
"examples": [{
"version": "v2",
"filters": {
"AND": [
{"user_id": "alex"},
@@ -235,9 +227,9 @@ class GetAllMemoryInput(BaseModel):
#### Implementation
```python
def get_all_memory(version: str, filters: Dict[str, Any], page: int = 1, page_size: int = 50) -> Any:
def get_all_memory(filters: Dict[str, Any], page: int = 1, page_size: int = 50) -> Any:
"""Retrieve all memories matching the specified criteria."""
return client.get_all(version=version, filters=filters, page=page, page_size=page_size)
return client.get_all(filters=filters, page=page, page_size=page_size)
get_all_tool = StructuredTool(
name="get_all_memory",
@@ -252,7 +244,6 @@ get_all_tool = StructuredTool(
<CodeGroup>
```python Code
get_all_input = {
"version": "v2",
"filters": {
"AND": [
{"user_id": "alex"},
+1 -2
View File
@@ -41,7 +41,6 @@ context = {"user_id": "alice"}
memory_from_client = Mem0Memory.from_client(
context=context,
search_msg_limit=4, # optional, default is 5
output_format='v1.1', # Remove deprecation warnings
)
```
@@ -103,7 +102,7 @@ memory_from_config = Mem0Memory.from_config(
context=context,
config=config,
search_msg_limit=4, # optional, default is 5
output_format='v1.1', # Remove deprecation warnings
# Remove deprecation warnings
)
```
+1 -1
View File
@@ -5,7 +5,7 @@ iconType: "solid"
---
<Info>
**Mem0 v1.0.0 Beta is here!** Check out our [research paper](https://mem0.ai/research) to learn about the technical foundations and innovations behind Mem0's memory architecture.
Check out our [research paper](https://mem0.ai/research) to learn about the technical foundations and innovations behind Mem0's memory architecture.
</Info>
Mem0 is a memory layer designed for modern AI agents. It acts as a persistent memory layer that agents can use to:
+31 -31
View File
@@ -28,7 +28,7 @@ config = {
m = Memory.from_config(config)
```
#### v1.0.0 Beta
#### v1.0.0
```python
from mem0 import Memory
@@ -61,12 +61,11 @@ def add(
metadata: dict = None,
filters: dict = None,
output_format: str = None, # ❌ REMOVED
version: str = None, # ❌ REMOVED
async_mode: bool = None # ❌ REMOVED
version: str = None # ❌ REMOVED
) -> Union[List[dict], dict]
```
#### v1.0.0 Beta Signature
#### v1.0.0 Signature
```python
def add(
self,
@@ -82,7 +81,7 @@ def add(
#### Changes Summary
| Parameter | v0.x | v1.0.0 Beta | Change |
| Parameter | v0.x | v1.0.0 | Change |
|-----------|------|-----------|---------|
| `messages` | ✅ | ✅ | Unchanged |
| `user_id` | ✅ | ✅ | Unchanged |
@@ -92,7 +91,6 @@ def add(
| `filters` | ✅ | ✅ | Unchanged |
| `output_format` | ✅ | ❌ | **REMOVED** |
| `version` | ✅ | ❌ | **REMOVED** |
| `async_mode` | ✅ | ❌ | **REMOVED** |
| `infer` | ❌ | ✅ | **NEW** |
#### Response Format Changes
@@ -120,7 +118,7 @@ def add(
}
```
**v1.0.0 Beta Response (standardized):**
**v1.0.0 Response (standardized):**
```python
# Always returns this format
{
@@ -152,7 +150,7 @@ def search(
) -> Union[List[dict], dict]
```
#### v1.0.0 Beta Signature
#### v1.0.0 Signature
```python
def search(
self,
@@ -177,7 +175,7 @@ filters = {
}
```
**v1.0.0 Beta Filters (enhanced):**
**v1.0.0 Filters (enhanced):**
```python
# Advanced filtering with operators
filters = {
@@ -221,7 +219,7 @@ def get_all(
) -> Union[List[dict], dict]
```
#### v1.0.0 Beta Signature
#### v1.0.0 Signature
```python
def get_all(
self,
@@ -266,29 +264,31 @@ def delete_all(
) -> dict
```
## AsyncMemory Class Changes
## Platform Client (MemoryClient) Changes
### Enhanced Async Support
### async_mode Default Changed
#### v0.x (Limited)
#### v0.x
```python
from mem0 import AsyncMemory
from mem0 import MemoryClient
# Basic async support
async_m = AsyncMemory()
result = await async_m.add("content", user_id="alice", async_mode=True)
client = MemoryClient(api_key="your-key")
# async_mode had to be explicitly set or had different default
result = client.add("content", user_id="alice", async_mode=True)
```
#### v1.0.0 Beta (Optimized)
#### v1.0.0
```python
from mem0 import AsyncMemory
from mem0 import MemoryClient
# Optimized async by default
async_m = AsyncMemory()
result = await async_m.add("content", user_id="alice") # async_mode removed
client = MemoryClient(api_key="your-key")
# All methods are now properly async-optimized
results = await async_m.search("query", user_id="alice", rerank=True)
# async_mode defaults to True now (better performance)
result = client.add("content", user_id="alice") # Uses async_mode=True by default
# Can still override if needed
result = client.add("content", user_id="alice", async_mode=False)
```
## Configuration Changes
@@ -308,7 +308,7 @@ config = {
}
```
#### v1.0.0 Beta Config Options
#### v1.0.0 Config Options
```python
config = {
"vector_store": {...},
@@ -386,7 +386,7 @@ except Exception as e:
print(f"Error: {e}")
```
#### v1.0.0 Beta Errors
#### v1.0.0 Errors
```python
# More specific error handling
try:
@@ -416,7 +416,7 @@ except Exception as e:
result = m.add("content", user_id="alice", unknown_param="value")
```
**v1.0.0 Beta (Strict):**
**v1.0.0 (Strict):**
```python
# Unknown parameters raise TypeError
try:
@@ -442,7 +442,7 @@ except TypeError as e:
}
```
#### v1.0.0 Beta Schema (Enhanced)
#### v1.0.0 Schema (Enhanced)
```python
{
"id": "mem_123",
@@ -488,7 +488,7 @@ for memory in memories:
print(memory["memory"])
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
from mem0 import Memory
@@ -518,7 +518,7 @@ results = m.search(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Enhanced filtering with reranking
results = m.search(
@@ -536,7 +536,7 @@ results = m.search(
## Summary
| Component | v0.x | v1.0.0 Beta | Status |
| Component | v0.x | v1.0.0 | Status |
|-----------|------|-----------|---------|
| `add()` method | Variable response | Standardized response | ⚠️ Breaking |
| `search()` method | Basic filtering | Enhanced filtering + reranking | ⚠️ Breaking |
+33 -29
View File
@@ -1,6 +1,6 @@
---
title: Breaking Changes in v1.0.0 Beta
description: 'Complete list of breaking changes when upgrading from v0.x to v1.0.0 Beta'
title: Breaking Changes in v1.0.0
description: 'Complete list of breaking changes when upgrading from v0.x to v1.0.0 '
icon: "triangle-exclamation"
iconType: "solid"
---
@@ -29,7 +29,7 @@ result = m.add(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# v1.1 is the minimum supported version
config = {
@@ -65,7 +65,7 @@ search_results = m.search("query", user_id="alice", output_format="v1.1")
all_memories = m.get_all(user_id="alice", output_format="v1.1")
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
result = m.add("content", user_id="alice")
search_results = m.search("query", user_id="alice")
@@ -81,31 +81,35 @@ all_memories = m.get_all(user_id="alice")
result = m.add("content", user_id="alice", version="v1.0")
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
result = m.add("content", user_id="alice")
```
### 3. async_mode Parameter
### 3. async_mode Parameter (Platform Client)
**Breaking Change:** Async mode is now default and the parameter is removed.
**Change:** For `MemoryClient` (Platform API), `async_mode` now defaults to `True` but can still be configured.
#### Before (v0.x)
```python
# Optional async mode
result = m.add("content", user_id="alice", async_mode=True)
result = m.add("content", user_id="alice", async_mode=False) # Sync mode
from mem0 import MemoryClient
client = MemoryClient(api_key="your-key")
result = client.add("content", user_id="alice", async_mode=True)
result = client.add("content", user_id="alice", async_mode=False)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Always async by design, parameter removed
result = m.add("content", user_id="alice")
from mem0 import MemoryClient
# For async operations, use AsyncMemory
from mem0 import AsyncMemory
async_m = AsyncMemory()
result = await async_m.add("content", user_id="alice")
client = MemoryClient(api_key="your-key")
# async_mode now defaults to True, but you can still override it
result = client.add("content", user_id="alice") # Uses async_mode=True by default
# You can still explicitly set it to False if needed
result = client.add("content", user_id="alice", async_mode=False)
```
## Response Format Changes
@@ -124,7 +128,7 @@ result = m.add("content", user_id="alice", output_format="v1.1")
# Returns: {"results": [{"id": "...", "memory": "...", "event": "ADD"}]}
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Always returns standardized format
result = m.add("content", user_id="alice")
@@ -149,7 +153,7 @@ config = {
}
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# v1.1 is minimum, v1.1 is default
config = {
@@ -174,11 +178,11 @@ from mem0 import Memory
m = Memory() # Used default settings suitable for v0.x
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
from mem0 import Memory
# Default configuration optimized for v1.0.0 Beta
# Default configuration optimized for v1.0.0
m = Memory() # Uses v1.1+ optimized defaults
# Explicit configuration recommended
@@ -210,7 +214,7 @@ results = m.search(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Basic usage remains the same
results = m.search("query", user_id="alice")
@@ -243,7 +247,7 @@ except Exception as e:
print(f"Generic error: {e}")
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
try:
result = m.add("content", user_id="alice")
@@ -271,7 +275,7 @@ result = m.add(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Strict validation - unknown parameters cause errors
try:
@@ -291,7 +295,7 @@ except TypeError as e:
**Good News:** Import statements remain the same.
```python
# These imports work in both v0.x and v1.0.0 Beta
# These imports work in both v0.x and v1.0.0
from mem0 import Memory, AsyncMemory
from mem0 import MemoryConfig
```
@@ -305,7 +309,7 @@ from mem0 import MemoryConfig
#### Before (v0.x)
- Python 3.8+ supported
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
- Python 3.9+ required (check current requirements)
### Package Dependencies
@@ -332,7 +336,7 @@ pip check # Verify no dependency conflicts
**Good News:** Memory storage format unchanged.
- Existing memories work with v1.0.0 Beta
- Existing memories work with v1.0.0
- Search continues to work with old memories
- No re-indexing required
@@ -350,7 +354,7 @@ def test_add_memory():
assert len(result) > 0
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
def test_add_memory():
result = m.add("content", user_id="alice")
@@ -378,7 +382,7 @@ python test_mem0_functionality.py
### Data Safety
- **Safe:** Memories stored in v0.x format work with v1.0.0 Beta
- **Safe:** Memories stored in v0.x format work with v1.0.0
- **Safe:** Rollback doesn't lose data
- **Safe:** Vector store data remains intact
+29 -36
View File
@@ -1,24 +1,24 @@
---
title: Migrating from v0.x to v1.0.0 Beta
description: 'Complete guide to upgrade your Mem0 implementation to version 1.0.0 Beta'
title: Migrating from v0.x to v1.0.0
description: 'Complete guide to upgrade your Mem0 implementation to version 1.0.0 '
icon: "arrow-right"
iconType: "solid"
---
<Warning>
**Breaking Changes Ahead!** Mem0 1.0.0 Beta introduces several breaking changes. Please read this guide carefully before upgrading.
**Breaking Changes Ahead!** Mem0 1.0.0 introduces several breaking changes. Please read this guide carefully before upgrading.
</Warning>
## Overview
Mem0 1.0.0 Beta is a major release that modernizes the API, improves performance, and adds powerful new features. This guide will help you migrate your existing v0.x implementation to the new version.
Mem0 1.0.0 is a major release that modernizes the API, improves performance, and adds powerful new features. This guide will help you migrate your existing v0.x implementation to the new version.
## Key Changes Summary
| Feature | v0.x | v1.0.0 Beta | Migration Required |
| Feature | v0.x | v1.0.0 | Migration Required |
|---------|------|-------------|-------------------|
| API Version | v1.0 supported | v1.0 **removed**, v1.1+ only | ✅ Yes |
| Async Mode | Optional | Default and required | ✅ Yes |
| Async Mode (Platform Client) | Optional/manual | Defaults to `True`, configurable | ⚠️ Partial |
| Output Format Parameter | Supported | **Removed** | ✅ Yes |
| Response Format | Mixed | Standardized `{"results": [...]}` | ✅ Yes |
| Metadata Filtering | Basic | Enhanced with operators | ⚠️ Optional |
@@ -49,7 +49,7 @@ result = m.add(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
from mem0 import Memory
@@ -80,7 +80,7 @@ config = {
m = Memory.from_config(config)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
config = {
"vector_store": {
@@ -112,7 +112,7 @@ else:
print(result["results"])
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Response is always a standardized dict with "results" key
result = m.add("I love coffee", user_id="alice")
@@ -137,7 +137,7 @@ results = m.search(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Same basic search API
results = m.search("What do I like?", user_id="alice")
@@ -162,38 +162,31 @@ results = m.search(
)
```
### 6. Migrate Async Operations
### 6. Platform Client async_mode Default Changed
**Change:** For `MemoryClient`, the `async_mode` parameter now defaults to `True` for better performance.
#### Before (v0.x)
```python
from mem0 import AsyncMemory
from mem0 import MemoryClient
# Async was optional
async_memory = AsyncMemory()
client = MemoryClient(api_key="your-key")
async def add_memory():
result = await async_memory.add(
"I enjoy hiking",
user_id="alice",
async_mode=True # ❌ Parameter removed
)
return result
# Had to explicitly set async_mode
result = client.add("I enjoy hiking", user_id="alice", async_mode=True)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
from mem0 import AsyncMemory
from mem0 import MemoryClient
# Async is the default mode
async_memory = AsyncMemory()
client = MemoryClient(api_key="your-key")
async def add_memory():
result = await async_memory.add(
"I enjoy hiking",
user_id="alice"
# async_mode parameter removed - always async
)
return result
# async_mode now defaults to True (best performance)
result = client.add("I enjoy hiking", user_id="alice")
# You can still override if needed for synchronous processing
result = client.add("I enjoy hiking", user_id="alice", async_mode=False)
```
## Configuration Migration
@@ -221,7 +214,7 @@ config = {
}
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
config = {
"vector_store": {
@@ -297,7 +290,7 @@ except Exception as e:
print(f"Error: {e}")
```
### After (v1.0.0 Beta)
### After (v1.0.0 )
```python
try:
result = m.add("memory", user_id="alice")
@@ -414,7 +407,7 @@ TypeError: add() got an unexpected keyword argument 'output_format'
result = m.add(
"memory",
user_id="alice"
# Remove: output_format, version, async_mode
# Remove: output_format, version
)
```
@@ -454,7 +447,7 @@ result2 = m.add("memory 2", user_id="alice")
result3 = m.search("query", user_id="alice")
```
### After (v1.0.0 Beta)
### After (v1.0.0 )
```python
# Better async performance
async def batch_operations():
@@ -1,17 +1,17 @@
---
title: Enhanced Metadata Filtering
description: 'Advanced filtering capabilities for precise memory retrieval in Mem0 1.0.0 Beta'
description: 'Advanced filtering capabilities for precise memory retrieval in Mem0 1.0.0 '
icon: "filter"
iconType: "solid"
---
<Info>
Enhanced metadata filtering is available in **Mem0 1.0.0 Beta** and later versions. This feature provides powerful filtering capabilities with logical operators and comparison functions.
Enhanced metadata filtering is available in **Mem0 1.0.0 ** and later versions. This feature provides powerful filtering capabilities with logical operators and comparison functions.
</Info>
## Overview
Mem0 1.0.0 Beta introduces enhanced metadata filtering that allows you to perform complex queries on your memory metadata. You can now use logical operators, comparison functions, and advanced filtering patterns to retrieve exactly the memories you need.
Mem0 1.0.0 introduces enhanced metadata filtering that allows you to perform complex queries on your memory metadata. You can now use logical operators, comparison functions, and advanced filtering patterns to retrieve exactly the memories you need.
## Basic Filtering
@@ -204,7 +204,7 @@ results = m.search(
user_id="project_manager",
filters={
"AND": [
{"project": {"in": ["alpha", "beta"]}},
{"project": {"in": ["alpha", ""]}},
{"priority": {"gte": 8}},
{"status": {"ne": "completed"}},
{
@@ -315,12 +315,12 @@ Different vector stores support different filtering capabilities:
### Chroma
-  Basic operators (eq, ne, gt, lt, gte, lte)
-  Simple logical operations
-   Limited nested operations
-  Limited nested operations
### Pinecone
-  Good support for comparison operators
-  In/nin operations
-   Limited text operations
-  Limited text operations
### Weaviate
-  Full operator support
@@ -360,7 +360,7 @@ results = m.search(
)
```
### After (v1.0.0 Beta)
### After (v1.0.0 )
```python
# Enhanced filtering with operators
results = m.search(
+1
View File
@@ -26,6 +26,7 @@ Mem0 open-source provides a powerful, flexible foundation for AI memory manageme
### Memory Management
- **Synchronous & Asynchronous Operations**: Choose between sync and async memory operations based on your application needs
- **Smart Memory Retrieval**: Intelligent search and retrieval with semantic understanding
- **Advanced Reranking**: Improve search relevance with Zero Entropy, LLM-based, or custom reranking models
- **Memory Persistence**: Long-term storage with automatic optimization and cleanup
### Advanced Organization
@@ -1,12 +1,12 @@
---
title: Reranker-Enhanced Search
description: 'Improve search relevance with reranking models in Mem0 1.0.0 Beta'
description: 'Improve search relevance with reranking models in Mem0 1.0.0 '
icon: "sort"
iconType: "solid"
---
<Info>
Reranker-enhanced search is available in **Mem0 1.0.0 Beta** and later versions. This feature significantly improves search relevance by using specialized reranking models to reorder search results.
Reranker-enhanced search is available in **Mem0 1.0.0 ** and later versions. This feature significantly improves search relevance by using specialized reranking models to reorder search results.
</Info>
## Overview
@@ -385,7 +385,7 @@ results = m.search(
results = m.search("query", user_id="alice")
```
### To v1.0.0 Beta (With Reranking)
### To v1.0.0 (With Reranking)
```python
# Add reranker configuration
+130
View File
@@ -0,0 +1,130 @@
---
title: Reranking
description: 'Improve memory search relevance with advanced reranking capabilities'
icon: "arrow-up-arrow-down"
iconType: "solid"
---
## Overview
Reranking is an advanced feature that improves the relevance of memory search results by re-ordering them based on more sophisticated relevance scoring. After initial vector similarity search, rerankers use specialized models to provide more accurate relevance scores.
<Note>
Reranking operates as a post-processing step after the initial vector search. It takes the top results from vector similarity search and re-scores them using more advanced models or custom logic.
</Note>
## How It Works
1. **Vector Search**: Initial semantic similarity search retrieves candidate memories
2. **Reranking**: Selected reranker re-scores candidates using advanced models
3. **Final Results**: Re-ordered results with both vector and rerank scores
## Quick Start
Enable reranking by adding a `rerank` section to your memory configuration:
```python Python
from mem0 import Memory
config = {
"vector_store": {
"provider": "chroma",
"config": {
"collection_name": "my_memories",
"path": "./chroma_db"
}
},
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4o-mini"
}
},
"rerank": {
"provider": "zero_entropy",
"config": {
"model": "zerank-1",
"top_k": 5
}
}
}
memory = Memory.from_config(config)
# Add memories
messages = [
{"role": "user", "content": "I love Italian pasta, especially carbonara"},
{"role": "assistant", "content": "Carbonara is a classic Roman dish!"}
]
memory.add(messages, user_id="alice")
# Search with reranking - results automatically include rerank scores
results = memory.search("What Italian dishes does the user like?", user_id="alice")
for result in results['results']:
print(f"Memory: {result['memory']}")
print(f"Vector Score: {result['score']:.3f}")
print(f"Rerank Score: {result['rerank_score']:.3f}")
```
## Supported Providers
Mem0 supports multiple reranking providers:
- **[Zero Entropy](../../components/rerankers/models/zero_entropy)**: State-of-the-art neural reranking
- **[Cohere](../../components/rerankers/models/cohere)**: Enterprise-grade with multilingual support
- **[Sentence Transformer](../../components/rerankers/models/sentence_transformer)**: Local HuggingFace models
- **[LLM-based](../../components/rerankers/models/llm)**: Custom scoring using any LLM
## When to Use Reranking
Reranking is particularly effective for:
- **Improved Relevance**: When vector search alone doesn't provide sufficiently relevant results
- **Domain-Specific Queries**: Specialized terminology or context that benefits from advanced models
- **Customer Support**: Finding the most relevant help articles and documentation
- **Knowledge Management**: Better search results in internal knowledge bases
- **Personal AI Assistants**: More accurate memory recall for user queries
## Configuration Options
Each reranker has specific configuration options. See the [Rerankers Documentation](../../components/rerankers/overview) for detailed configuration parameters.
### Basic Configuration
```python Python
"rerank": {
"provider": "zero_entropy", # or "cohere", "sentence_transformer", "llm"
"config": {
"top_k": 5, # Limit results after reranking
"api_key": "your-key" # Provider-specific API key
}
}
```
### Controlling Reranking
You can enable or disable reranking per search:
```python Python
# Search with reranking (default when configured)
results = memory.search("query", user_id="alice", rerank=True)
# Search without reranking
results = memory.search("query", user_id="alice", rerank=False)
```
## Performance Considerations
- **Latency**: Reranking adds processing time but significantly improves relevance
- **Cost**: API-based rerankers (Zero Entropy, Cohere, LLM) have per-request costs
- **Local Options**: Sentence Transformer reranker runs locally with no API costs
- **Quality vs Speed**: Balance based on your application's requirements
## Next Steps
- Explore specific [reranker providers](../../components/rerankers/overview) and their capabilities
- Learn about [configuration options](../../components/rerankers/config) for fine-tuning
- Check out [Vector Stores](../../components/vectordbs/overview) for different storage backends
- See [Async Memory](./async-memory) for non-blocking reranking operations
+3 -3
View File
@@ -4888,7 +4888,7 @@
"title": "Output format",
"type": "string",
"nullable": true,
"default": "v1.0"
"default": "v1.1"
},
"custom_categories": {
"description": "A list of categories with category name and its description.",
@@ -4913,7 +4913,7 @@
"description": "Whether to add the memory completely asynchronously.",
"title": "Async mode",
"type": "boolean",
"default": false
"default": true
},
"timestamp": {
"description": "The timestamp of the memory. Format: Unix timestamp",
@@ -5020,7 +5020,7 @@
"title": "Output format",
"type": "string",
"nullable": true,
"default": "v1.0",
"default": "v1.1",
"description": "The search method supports two output formats: `v1.0` (default) and `v1.1`. We recommend using `v1.1` as `v1.0` will be deprecated soon."
},
"org_id": {
+180 -66
View File
@@ -283,36 +283,70 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \
### Search with Custom Filters
Our advanced search allows you to set custom search filters. You can filter by `user_id`, `agent_id`, `app_id`, `run_id`, `created_at`, `updated_at`, `categories`, and `text`. The filters support logical operators (AND, OR) and comparison operators (`in`, `gte`, `lte`, `gt`, `lt`, `ne`, `contains`, `icontains`, `*`). The wildcard character (`*`) matches everything for a specific field.
Our advanced search allows you to set custom search filters for precise memory retrieval. You can filter by `user_id`, `agent_id`, `app_id`, `run_id`, `created_at`, `updated_at`, `categories`, and `text`. The filters support logical operators (AND, OR) and comparison operators (`in`, `gte`, `lte`, `gt`, `lt`, `ne`, `contains`, `icontains`, `*`). The wildcard character (`*`) matches everything for a specific field.
For the **categories** field specifically:
- Use `contains` for partial matching (e.g., `{"categories": {"contains": "finance"}}`)
- Use `in` for exact matching (e.g., `{"categories": {"in": ["personal_information"]}}`).
#### Filterable Fields
You need to define `version` as `v2` in the search method.
You can filter by the following fields:
- **Session identifiers**: `user_id`, `agent_id`, `run_id`, `app_id`
- **Timestamps**: `created_at`, `updated_at`
- **Content**: `categories`, `metadata` fields
- **Text**: Memory content (platform-specific)
#### Example 1: Search using user_id and agent_id filters
#### Filter Operators
**Logical Operators:**
- `AND`: All conditions must match
- `OR`: At least one condition must match
- `NOT`: Exclude matching conditions (platform-specific)
**Comparison Operators:**
- `in`: Match any value in array (e.g., `{"agent_id": {"in": ["bot1", "bot2"]}}`)
- `gte`, `lte`: Greater/less than or equal (dates, numbers)
- `gt`, `lt`: Greater/less than (dates, numbers)
- `ne`: Not equal to
- `contains`: Partial text match (e.g., `{"categories": {"contains": "finance"}}`)
- `icontains`: Case-insensitive partial match
- `*`: Wildcard - matches any value for the field
#### Using Filters
**Method 1: Direct Parameters (Recommended for simple queries)**
```python
# Search for a specific user
client.search("query", user_id="alice")
# Search with agent context
client.search("query", user_id="alice", agent_id="travel-bot")
```
**Method 2: Filters Object (For complex queries)**
```python
# Combine multiple conditions
filters = {
"AND": [
{"user_id": "alice"},
{"agent_id": {"in": ["bot1", "bot2"]}}
]
}
client.search("query", filters=filters)
```
#### Example 1: OR Logic - Multiple User or Agent IDs
Search memories from either a specific user OR from specific agents:
<CodeGroup>
```python Python
query = "What do you know about me?"
filters = {
"OR":[
{
"user_id":"alex"
},
{
"agent_id":{
"in":[
"travel-assistant",
"customer-support"
]
}
}
"OR": [
{"user_id": "alex"},
{"agent_id": {"in": ["travel-assistant", "customer-support"]}}
]
}
client.search(query, version="v2", filters=filters)
client.search(query, filters=filters)
```
```javascript JavaScript
@@ -332,13 +366,13 @@ const filters = {
}
]
};
client.search(query, { version: "v2", filters })
client.search(query, { filters })
.then(results => console.log(results))
.catch(error => console.error(error));
```
```bash cURL
curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
curl -X POST "https://api.mem0.ai/v2/memories/search/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
@@ -367,43 +401,41 @@ curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
query = "What do you know about me?"
filters = {
"AND": [
{"created_at": {"gte": "2024-07-20", "lte": "2024-07-10"}},
{"user_id": "alex"}
{"user_id": "alex"},
{"created_at": {"gte": "2024-07-01", "lte": "2024-07-31"}}
]
}
client.search(query, version="v2", filters=filters)
client.search(query, filters=filters)
```
```javascript JavaScript
const query = "What do you know about me?";
const filters = {
"AND": [
{"created_at": {"gte": "2024-07-20", "lte": "2024-07-10"}},
{"user_id": "alex"}
{"user_id": "alex"},
{"created_at": {"gte": "2024-07-01", "lte": "2024-07-31"}}
]
};
client.search(query, { version: "v2", filters })
client.search(query, { filters })
.then(results => console.log(results))
.catch(error => console.error(error));
```
```bash cURL
curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
curl -X POST "https://api.mem0.ai/v2/memories/search/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
"query": "What do you know about me?",
"filters": {
"AND": [
{"user_id": "alex"},
{
"created_at": {
"gte": "2024-07-20",
"lte": "2024-07-10"
"gte": "2024-07-01",
"lte": "2024-07-31"
}
},
{
"user_id": "alex"
}
]
}
@@ -427,7 +459,7 @@ filters = {
}
]
}
client.search(query, version="v2", filters=filters)
client.search(query, filters=filters)
# Example 3b: Using 'in' for exact matching
query = "What personal information do you have?"
@@ -441,7 +473,7 @@ filters = {
}
]
}
client.search(query, version="v2", filters=filters)
client.search(query, filters=filters)
```
```javascript JavaScript
@@ -458,7 +490,7 @@ const filters1 = {
]
};
client.search(query1, { version: "v2", filters: filters1 })
client.search(query1, { filters: filters1 })
.then(results => console.log(results))
.catch(error => console.error(error));
@@ -475,14 +507,14 @@ const filters2 = {
]
};
client.search(query2, { version: "v2", filters: filters2 })
client.search(query2, { filters: filters2 })
.then(results => console.log(results))
.catch(error => console.error(error));
```
```bash cURL
# Example 3a: Using 'contains' for partial matching
curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
curl -X POST "https://api.mem0.ai/v2/memories/search/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
@@ -500,7 +532,7 @@ curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
}'
# Example 3b: Using 'in' for exact matching
curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
curl -X POST "https://api.mem0.ai/v2/memories/search/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
@@ -525,36 +557,38 @@ curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
```python Python
query = "What do you know about me?"
filters = {
"NOT": [
"AND": [
{"user_id": "alex"},
{
"categories": {
"contains": "food_preferences"
}
"NOT": [
{"categories": {"contains": "food_preferences"}}
]
}
]
}
client.search(query, version="v2", filters=filters)
client.search(query, filters=filters)
```
```javascript JavaScript
const query = "What do you know about me?";
const filters = {
"NOT": [
"AND": [
{"user_id": "alex"},
{
"categories": {
"contains": "food_preferences"
}
"NOT": [
{"categories": {"contains": "food_preferences"}}
]
}
]
};
client.search(query, { version: "v2", filters })
client.search(query, { filters })
.then(results => console.log(results))
.catch(error => console.error(error));
```
```bash cURL
curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
curl -X POST "https://api.mem0.ai/v2/memories/search/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
@@ -572,22 +606,20 @@ curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
```
</CodeGroup>
#### Example 5: Search using wildcard filters
#### Example 5: Wildcard Filters - Match Any Value
Use `*` wildcard to match memories that have any value for a specific field:
<CodeGroup>
```python Python
query = "What do you know about me?"
filters = {
"AND": [
{
"user_id": "alex"
},
{
"run_id": "*" # Matches all run_ids
}
{"user_id": "alex"},
{"run_id": "*"} # Only memories that have a run_id (any value)
]
}
client.search(query, version="v2", filters=filters)
client.search(query, filters=filters)
```
```javascript JavaScript
@@ -603,13 +635,13 @@ const filters = {
]
};
client.search(query, { version: "v2", filters })
client.search(query, { filters })
.then(results => console.log(results))
.catch(error => console.error(error));
```
```bash cURL
curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
curl -X POST "https://api.mem0.ai/v2/memories/search/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
@@ -628,6 +660,88 @@ curl -X POST "https://api.mem0.ai/v1/memories/search/?version=v2" \
```
</CodeGroup>
### Filter Best Practices
**1. Always Scope to User or Agent**
Always include at least a `user_id`, `agent_id`, or `run_id` to scope your search:
```python
# Good: Scoped to user
client.search("query", user_id="alice")
# Better: Scoped to user and agent
client.search("query", user_id="alice", agent_id="travel-bot")
# Best: Scoped to specific session
client.search("query", user_id="alice", agent_id="travel-bot", run_id="session-123")
```
**2. Use Direct Parameters for Simple Queries**
For single-condition filters, use direct parameters instead of the filters object:
```python
# Simple and clean
client.search("query", user_id="alice", agent_id="bot")
# Unnecessarily complex
client.search("query", filters={"AND": [{"user_id": "alice"}, {"agent_id": "bot"}]})
```
**3. Use Filters Object for Complex Logic**
Use the `filters` parameter when you need OR logic, comparison operators, or nested conditions:
```python
# Multiple agents OR specific run
filters = {
"OR": [
{"agent_id": {"in": ["bot1", "bot2"]}},
{"run_id": "special-session"}
]
}
client.search("query", user_id="alice", filters=filters)
```
**4. Combine Direct Parameters with Filters**
You can mix direct parameters with filters for cleaner code:
```python
# User is required, plus complex date/category logic
filters = {
"AND": [
{"created_at": {"gte": "2024-07-01"}},
{"categories": {"contains": "important"}}
]
}
client.search("query", user_id="alice", filters=filters)
```
**5. Platform vs OSS Differences**
Some features are Platform-only:
- **Categories**: Auto-generated on Platform, manual on OSS
- **Date filters**: Platform tracks timestamps automatically
- **NOT operator**: Only available on Platform
- **Wildcard (`*`)**: Behavior may vary
```python
# This works everywhere
m.search("query", user_id="alice", agent_id="bot")
# This is Platform-only
client.search("query", filters={
"AND": [
{"user_id": "alice"},
{"categories": {"contains": "travel"}} # Platform only
]
})
```
---
## Advanced Retrieval Operations
### Get All Memories with Pagination
@@ -774,10 +888,10 @@ filters = {
}
# Default (No Pagination)
client.get_all(version="v2", filters=filters)
client.get_all(filters=filters)
# Pagination (You can also use the page and page_size parameters)
client.get_all(version="v2", filters=filters, page=1, page_size=50)
client.get_all(filters=filters, page=1, page_size=50)
```
```javascript JavaScript
@@ -801,19 +915,19 @@ const filters = {
};
// Default (No Pagination)
client.getAll({ version: "v2", filters })
client.getAll({ filters })
.then(memories => console.log(memories))
.catch(error => console.error(error));
// Pagination (You can also use the page and page_size parameters)
client.getAll({ version: "v2", filters, page: 1, page_size: 50 })
client.getAll({ filters, page: 1, page_size: 50 })
.then(memories => console.log(memories))
.catch(error => console.error(error));
```
```bash cURL
# Default (No Pagination)
curl -X GET "https://api.mem0.ai/v1/memories/?version=v2" \
curl -X GET "https://api.mem0.ai/v2/memories/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
@@ -832,7 +946,7 @@ curl -X GET "https://api.mem0.ai/v1/memories/?version=v2" \
}'
# Pagination (You can also use the page and page_size parameters)
curl -X GET "https://api.mem0.ai/v1/memories/?version=v2&page=1&page_size=50" \
curl -X GET "https://api.mem0.ai/v2/memories/&page=1&page_size=50" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
+16 -20
View File
@@ -81,7 +81,7 @@ Once defined, register the criteria to your project:
client.project.update(retrieval_criteria=retrieval_criteria)
```
Criteria apply project-wide. Once set, they affect all searches using `version="v2"`.
Criteria apply project-wide. Once set, they affect all searches automatically.
## Example Walkthrough
@@ -104,22 +104,18 @@ client.add(messages, user_id="alice")
### Run Standard vs. Criteria-Based Search
```python
# With criteria
filters = {
"AND": [
{"user_id": "alice"}
]
}
# Search with criteria enabled
filters = {"user_id": "alice"}
results_with_criteria = client.search(
query="Why I am feeling happy today?",
filters=filters,
version="v2"
filters=filters
)
# Without criteria
# To disable criteria for a specific search
results_without_criteria = client.search(
query="Why I am feeling happy today?",
user_id="alice"
filters=filters,
use_criteria=False # Disable criteria-based scoring
)
```
@@ -163,10 +159,10 @@ results_without_criteria = client.search(
| Control Over Relevance | None | Fully customizable with weighted criteria |
| Memory Reordering | Static based on similarity | Dynamically re-ranked by intent alignment |
| Emotional Sensitivity | No tone or trait awareness | Incorporates emotion, tone, or custom behaviors |
| Version Required | Defaults | `search(version="v2")` |
| Activation | Default (no criteria defined) | Enabled when criteria are defined in project |
<Note>
If no criteria are defined for a project, `version="v2"` behaves like normal search.
If no criteria are defined for a project, search behaves normally based on semantic similarity only.
</Note>
@@ -184,23 +180,23 @@ If no criteria are defined for a project, `version="v2"` behaves like normal sea
## How It Works
1. **Criteria Definition**: Define custom criteria with a name, description, and weight. These describe what matters in a memory (e.g., joy, urgency, empathy).
2. **Project Configuration**: Register these criteria using `project.update()`. They apply at the project level and influence all searches using `version="v2"`.
3. **Memory Retrieval**: When you perform a search with `version="v2"`, Mem0 first retrieves relevant memories based on the query and your defined criteria.
4. **Weighted Scoring**: Each retrieved memory is evaluated and scored against the defined criteria and weights.
2. **Project Configuration**: Register these criteria using `project.update()`. They apply at the project level and automatically influence all searches.
3. **Memory Retrieval**: When you perform a search, Mem0 first retrieves relevant memories based on the query.
4. **Weighted Scoring**: Each retrieved memory is evaluated and scored against your defined criteria and weights.
This lets you prioritize memories that align with your agent’s goals and not just those that look similar to the query.
This lets you prioritize memories that align with your agent's goals and not just those that look similar to the query.
<Note>
Criteria retrieval is currently supported only in search v2. Make sure to use `version="v2"` when performing searches with custom criteria.
Criteria retrieval is automatically enabled when criteria are defined in your project. Use `use_criteria=False` in search to temporarily disable it for a specific query.
</Note>
## Summary
- Define what “relevant” means using criteria
- Define what "relevant" means using criteria
- Apply them per project via `project.update()`
- Use `version="v2"` to activate criteria-aware search
- Criteria-aware search activates automatically when criteria are configured
- Build agents that reason not just with relevance, but **contextual importance**
---
+1 -1
View File
@@ -68,7 +68,7 @@ You can retrieve all memories using the `get_all` method.
<CodeGroup>
```python Python
client.get_all(query="What is Alice's favorite sport?", user_id="alice", output_format="v1.1")
client.get_all(query="What is Alice's favorite sport?", user_id="alice")
```
```json Output
+15 -25
View File
@@ -21,7 +21,7 @@ The Graph Memory feature analyzes how each entity connects and relates to each o
## Using Graph Memory
To use Graph Memory, you need to enable it in your API calls by setting the `enable_graph=True` parameter. You'll also need to specify `output_format="v1.1"` to receive the enriched response format.
To use Graph Memory, you need to enable it in your API calls by setting the `enable_graph=True` parameter.
### Adding Memories with Graph Memory
@@ -46,11 +46,9 @@ messages = [
# Enable graph memory when adding
client.add(
messages,
user_id="joseph",
version="v1",
enable_graph=True,
output_format="v1.1"
messages,
user_id="joseph",
enable_graph=True
)
```
@@ -73,9 +71,7 @@ const messages = [
await client.add({
messages,
user_id: "joseph",
version: "v1",
enable_graph: true,
output_format: "v1.1"
enable_graph: true
});
```
@@ -125,10 +121,9 @@ When searching memories, Graph Memory helps retrieve entities that are contextua
```python Python
# Search with graph memory enabled
results = client.search(
"what is my name?",
user_id="joseph",
enable_graph=True,
output_format="v1.1"
"what is my name?",
user_id="joseph",
enable_graph=True
)
print(results)
@@ -139,8 +134,7 @@ print(results)
const results = await client.search({
query: "what is my name?",
user_id: "joseph",
enable_graph: true,
output_format: "v1.1"
enable_graph: true
});
console.log(results);
@@ -196,9 +190,8 @@ When retrieving all memories, Graph Memory provides additional relationship cont
```python Python
# Get all memories with graph context
memories = client.get_all(
user_id="joseph",
enable_graph=True,
output_format="v1.1"
user_id="joseph",
enable_graph=True
)
print(memories)
@@ -208,8 +201,7 @@ print(memories)
// Get all memories with graph context
const memories = await client.getAll({
user_id: "joseph",
enable_graph: true,
output_format: "v1.1"
enable_graph: true
});
console.log(memories);
@@ -304,8 +296,7 @@ messages = [
client.add(
messages,
user_id="joseph",
output_format="v1.1"
user_id="joseph"
)
```
@@ -319,7 +310,7 @@ const client = new MemoryClient({
});
// Enable graph memory for all operations in this project
await client.updateProject({ enable_graph: true, version: "v1" });
await client.project.update({ enable_graph: true });
// Now all add operations will use graph memory by default
const messages = [
@@ -330,8 +321,7 @@ const messages = [
await client.add({
messages,
user_id: "joseph",
output_format: "v1.1"
user_id: "joseph"
});
```
+4 -6
View File
@@ -63,7 +63,6 @@ messages = [
response = client.add(
messages,
run_id="group_chat_1",
output_format="v1.1",
infer=True
)
print(response)
@@ -103,6 +102,7 @@ Retrieve all memories from a specific group chat session:
```python Python
# Get all memories for a specific run_id
# Use wildcard "*" for user_id to match all participants
filters = {
"AND": [
{"user_id": "*"},
@@ -110,7 +110,7 @@ filters = {
]
}
all_memories = client.get_all(version="v2", filters=filters, page=1)
all_memories = client.get_all(filters=filters, page=1)
print(all_memories)
```
@@ -160,7 +160,7 @@ filters = {
]
}
charlie_memories = client.get_all(version="v2", filters=filters, page=1)
charlie_memories = client.get_all(filters=filters, page=1)
print(charlie_memories)
```
@@ -197,8 +197,7 @@ filters = {
search_response = client.search(
query="What are the tasks?",
filters=filters,
version="v2"
filters=filters
)
print(search_response)
```
@@ -229,7 +228,6 @@ Group chat also supports async processing for improved performance:
response = client.add(
messages,
run_id="groupchat_async",
output_format="v1.1",
infer=True,
async_mode=True
)
+11 -8
View File
@@ -77,12 +77,13 @@ You can optionally provide additional instructions to guide how memories are pro
```python Python
# Basic export request
filters = {"user_id": "alice"}
response = client.create_memory_export(
schema=json_schema,
user_id="alice"
filters=filters
)
# Export with custom instructions
# Export with custom instructions and additional filters
export_instructions = """
1. Create a comprehensive profile with detailed information in each category
2. Only mark fields as "None" when absolutely no relevant information exists
@@ -91,10 +92,10 @@ export_instructions = """
5. Clearly distinguish between factual statements and inferences
"""
# For create operation, using only user_id filter as requested
filters = {
"AND": [
{"user_id": "alex"}
{"user_id": "alex"},
{"created_at": {"gte": "2024-01-01"}}
]
}
@@ -109,12 +110,13 @@ print(response)
```javascript JavaScript
// Basic Export request
const filters = {"user_id": "alice"};
const response = await client.createMemoryExport({
schema: json_schema,
user_id: "alice"
filters: filters
});
// Export with custom instructions
// Export with custom instructions and additional filters
const export_instructions = `
1. Create a comprehensive profile with detailed information in each category
2. Only mark fields as "None" when absolutely no relevant information exists
@@ -126,7 +128,8 @@ const export_instructions = `
// For create operation, using only user_id filter as requested
const filters = {
"AND": [
{"user_id": "alex"}
{"user_id": "alex"},
{"created_at": {"gte": "2024-01-01"}}
]
}
@@ -145,7 +148,7 @@ curl -X POST "https://api.mem0.ai/v1/memories/export/" \
-H "Content-Type: application/json" \
-d '{
"schema": {json_schema},
"user_id": "alice",
"filters": {"user_id": "alice"},
"export_instructions": "1. Create a comprehensive profile with detailed information\n2. Only mark fields as \"None\" when absolutely no relevant information exists"
}'
```
+4 -4
View File
@@ -148,7 +148,7 @@ filters = {
}
]
}
client.search(query, version="v2", filters=filters)
client.search(query, filters=filters)
```
```javascript JavaScript
@@ -160,7 +160,7 @@ const filters = {
}
]
};
client.search(query, { version: "v2", filters })
client.search(query, { filters })
.then(results => console.log(results))
.catch(error => console.error(error));
```
@@ -219,7 +219,7 @@ filters = {
]
}
all_memories = client.get_all(version="v2", filters=filters, page=1, page_size=50)
all_memories = client.get_all(filters=filters, page=1, page_size=50)
```
```javascript JavaScript
@@ -231,7 +231,7 @@ const filters = {
]
};
client.getAll({ version: "v2", filters, page: 1, page_size: 50 })
client.getAll({ filters, page: 1, page_size: 50 })
.then(memories => console.log(memories))
.catch(error => console.error(error));
```
+17 -17
View File
@@ -6,18 +6,18 @@ iconType: "solid"
---
<Warning>
**This is legacy documentation for Mem0 v0.x.** For the latest FAQs, please refer to [v1.0.0 Beta FAQs](/faqs).
**This is legacy documentation for Mem0 v0.x.** For the latest FAQs, please refer to [v1.0.0 FAQs](/faqs).
</Warning>
## General Questions
### What is Mem0 v0.x?
Mem0 v0.x is the legacy version of Mem0's memory layer for LLMs. While still functional, it lacks the advanced features and optimizations available in v1.0.0 Beta.
Mem0 v0.x is the legacy version of Mem0's memory layer for LLMs. While still functional, it lacks the advanced features and optimizations available in v1.0.0 .
### Should I upgrade to v1.0.0 Beta?
### Should I upgrade to v1.0.0 ?
Yes! v1.0.0 Beta offers significant improvements:
Yes! v1.0.0 offers significant improvements:
- Enhanced filtering with logical operators
- Reranking support for better search relevance
- Improved async performance
@@ -28,7 +28,7 @@ See our [migration guide](/migration/v0-to-v1) for upgrade instructions.
### Is v0.x still supported?
v0.x receives minimal maintenance but no new features. We recommend upgrading to v1.0.0 Beta for the latest improvements and active support.
v0.x receives minimal maintenance but no new features. We recommend upgrading to v1.0.0 for the latest improvements and active support.
## API Questions
@@ -128,17 +128,17 @@ No! Most changes are simple parameter removals:
# Before (v0.x)
result = m.add("memory", user_id="alice", output_format="v1.1", version="v1.0")
# After (v1.0.0 Beta)
# After (v1.0.0 )
result = m.add("memory", user_id="alice")
```
### Will I lose my data?
No! Your existing memories remain fully compatible with v1.0.0 Beta.
No! Your existing memories remain fully compatible with v1.0.0 .
### Do I need to re-index my vectors?
No! Existing vector data works with v1.0.0 Beta without changes.
No! Existing vector data works with v1.0.0 without changes.
### Can I rollback if needed?
@@ -152,10 +152,10 @@ pip install mem0ai==0.1.20 # Last stable v0.x
### Does v0.x support reranking?
No, reranking is only available in v1.0.0 Beta:
No, reranking is only available in v1.0.0 :
```python
# v1.0.0 Beta only
# v1.0.0 only
results = m.search("query", user_id="alice", rerank=True)
```
@@ -167,7 +167,7 @@ No, only basic key-value filtering:
# v0.x - basic only
filters = {"category": "food", "user_id": "alice"}
# v1.0.0 Beta - advanced operators
# v1.0.0 - advanced operators
filters = {
"AND": [
{"category": "food"},
@@ -191,9 +191,9 @@ results = m.search(
## Performance Questions
### Is v0.x slower than v1.0.0 Beta?
### Is v0.x slower than v1.0.0 ?
Yes, v1.0.0 Beta includes several performance optimizations:
Yes, v1.0.0 includes several performance optimizations:
- Better async handling
- Optimized vector operations
- Improved memory management
@@ -203,11 +203,11 @@ Yes, v1.0.0 Beta includes several performance optimizations:
1. Use async mode when possible
2. Configure appropriate vector store settings
3. Use efficient metadata filters
4. Consider upgrading to v1.0.0 Beta
4. Consider upgrading to v1.0.0
### Can I batch operations in v0.x?
Limited support. Better batch processing available in v1.0.0 Beta.
Limited support. Better batch processing available in v1.0.0 .
## Troubleshooting
@@ -251,7 +251,7 @@ async_m = AsyncMemory()
### Documentation
- [v0.x Quickstart](/v0x/quickstart)
- [Migration Guide](/migration/v0-to-v1)
- [v1.0.0 Beta Docs](/)
- [v1.0.0 Docs](/)
### Community
- [GitHub Discussions](https://github.com/mem0ai/mem0/discussions)
@@ -263,5 +263,5 @@ async_m = AsyncMemory()
- [API Changes](/migration/api-changes)
<Info>
**Ready to upgrade?** Check out our [migration guide](/migration/v0-to-v1) to move to v1.0.0 Beta and access the latest features!
**Ready to upgrade?** Check out our [migration guide](/migration/v0-to-v1) to move to v1.0.0 and access the latest features!
</Info>
+1 -1
View File
@@ -6,7 +6,7 @@ iconType: "solid"
---
<Warning>
**This is legacy documentation for Mem0 v0.x.** For the latest features and improvements, please refer to [v1.0.0 Beta documentation](/).
**This is legacy documentation for Mem0 v0.x.** For the latest features and improvements, please refer to [v1.0.0 documentation](/).
</Warning>
## Welcome to Mem0 v0.x
+5 -5
View File
@@ -6,7 +6,7 @@ iconType: "solid"
---
<Warning>
**This is legacy documentation for Mem0 v0.x.** For the latest features, please refer to [v1.0.0 Beta documentation](/quickstart).
**This is legacy documentation for Mem0 v0.x.** For the latest features, please refer to [v1.0.0 documentation](/quickstart).
</Warning>
## Installation
@@ -167,14 +167,14 @@ result = m.add("I love coffee", user_id="alice", output_format="v1.1")
## Migration Path
To upgrade to v1.0.0 Beta:
To upgrade to v1.0.0 :
1. **Remove deprecated parameters:**
```python
# Old (v0.x)
m.add("memory", user_id="alice", output_format="v1.0", version="v1.0")
# New (v1.0.0 Beta)
# New (v1.0.0 )
m.add("memory", user_id="alice")
```
@@ -186,7 +186,7 @@ To upgrade to v1.0.0 Beta:
for item in result:
print(item["memory"])
# New (v1.0.0 Beta)
# New (v1.0.0 )
result = m.add("memory", user_id="alice")
for item in result["results"]:
print(item["memory"])
@@ -242,5 +242,5 @@ print("Previous context:", history)
</CardGroup>
<Info>
**Ready to upgrade?** Check out the [migration guide](/migration/v0-to-v1) to move to v1.0.0 Beta and access new features like reranking and enhanced filtering.
**Ready to upgrade?** Check out the [migration guide](/migration/v0-to-v1) to move to v1.0.0 and access new features like reranking and enhanced filtering.
</Info>