Update Docs (#3520)

This commit is contained in:
Deshraj Yadav
2025-09-30 08:41:36 -07:00
committed by GitHub
parent 135883935f
commit d68ed11d58
134 changed files with 2193 additions and 2090 deletions
+18 -17
View File
@@ -12,7 +12,8 @@ Advanced Retrieval gives you precise control over how memories are found and ran
## Search Enhancement Options
### Keyword Search
**Expands results** to include memories with specific terms, names, and technical keywords.
Expands results to include memories with specific terms, names, and technical keywords.
<Tabs>
<Tab title="When to Use">
@@ -44,8 +45,9 @@ results = client.search(
</Tab>
</Tabs>
### Reranking
**Reorders results** using deep semantic understanding to put the most relevant memories first.
### Reranking
Reorders results using deep semantic understanding to put the most relevant memories first.
<Tabs>
<Tab title="When to Use">
@@ -78,7 +80,8 @@ results = client.search(
</Tabs>
### Memory Filtering
**Filters results** to keep only the most precisely relevant memories.
Filters results to keep only the most precisely relevant memories.
<Tabs>
<Tab title="When to Use">
@@ -219,7 +222,7 @@ function standardSearch(query, userId) {
});
}
// High precision - good for critical applications
// High precision - good for critical applications
function preciseSearch(query, userId) {
return client.search(query, {
user_id: userId,
@@ -232,15 +235,17 @@ function preciseSearch(query, userId) {
## Best Practices
### ✅ Do
- **Start simple** with just one enhancement and measure impact
- **Use keyword search** for entity-heavy queries (names, places, technical terms)
- **Use reranking** when the top result quality matters most
- **Use filtering** for production systems where precision is critical
- **Handle empty results** gracefully when filtering is too aggressive
- **Monitor latency** and adjust based on your application's needs
### Do
- Start simple with just one enhancement and measure impact
- Use keyword search for entity-heavy queries (names, places, technical terms)
- Use reranking when the top result quality matters most
- Use filtering for production systems where precision is critical
- Handle empty results gracefully when filtering is too aggressive
- Monitor latency and adjust based on your application's needs
### Don't
### ❌ Don't
- Enable all options by default without measuring necessity
- Use filtering for broad exploratory queries
- Ignore latency impact in real-time applications
@@ -274,8 +279,4 @@ print(f"Search completed in {latency:.2f}s") # ~0.41s expected
3. **Implement fallback logic** when filtering returns empty results
4. **Monitor and alert** on search latency patterns
---
**Ready to enhance your search?** Start with keyword search for broader coverage, add reranking for better ordering, and use filtering when precision is critical.
<Snippet file="get-help.mdx" />
+3 -3
View File
@@ -7,7 +7,7 @@ description: "Add messages with automatic context management - no manual history
## What is Contextual Memory Creation?
Contextual memory creation automatically manages message history for you, so you can focus on building great AI experiences instead of tracking interactions manually. Simply send new messages, and Mem0 handles the context automatically.
Contextual memory creation automatically manages message history, allowing you to focus on building AI experiences without manually tracking interactions. Simply send new messages, and Mem0 handles the context automatically.
<CodeGroup>
```python Python
@@ -85,7 +85,7 @@ Choose the right approach based on your application's needs:
### User-Level Memories (`user_id` only)
Best for: Personal preferences, profile information, long-term user data
**Best for:** Personal preferences, profile information, long-term user data
<CodeGroup>
```python Python
@@ -113,7 +113,7 @@ await client.add(messages, { user_id: "user123", version: "v2" });
### Session-Specific Memories (`user_id` + `run_id`)
Best for: Task-specific context, separate interaction threads, project-based sessions
**Best for:** Task-specific context, separate interaction threads, project-based sessions
<CodeGroup>
```python Python
+10 -10
View File
@@ -4,15 +4,15 @@ icon: "magnifying-glass-plus"
iconType: "solid"
---
Mem0’s **Criteria Retrieval** feature allows you to retrieve memories based on your defined criteria. It goes beyond generic semantic relevance and rank memories based on what matters to your application - emotional tone, intent, behavioral signals, or other custom traits.
Mem0's Criteria Retrieval feature allows you to retrieve memories based on your defined criteria. It goes beyond generic semantic relevance and ranks memories based on what matters to your application: emotional tone, intent, behavioral signals, or other custom traits.
Instead of just searching for "how similar a memory is to this query?", you can define what *relevance* really means for your project. For example:
Instead of just searching for "how similar a memory is to this query," you can define what relevance truly means for your project. For example:
- Prioritize joyful memories when building a wellness assistant
- Downrank negative memories in a productivity-focused agent
- Highlight curiosity in a tutoring agent
You define **criteria** - custom attributes like "joy", "negativity", "confidence", or "urgency", and assign weights to control how they influence scoring. When you `search`, Mem0 uses these to re-rank memories that are semantically relevant, favoring those that better match your intent.
You define criteria: custom attributes like "joy", "negativity", "confidence", or "urgency", and assign weights to control how they influence scoring. When you search, Mem0 uses these to re-rank semantically relevant memories, favoring those that better match your intent.
This gives you nuanced, intent-aware memory search that adapts to your use case.
@@ -149,9 +149,9 @@ results_without_criteria = client.search(
## Search Results Comparison
1. **Memory Ordering**: With criteria, memories with high joy scores (like feeling refreshed and drawing) are ranked higher, while without criteria, the most relevant memory ("User is happy today") comes first.
2. **Score Distribution**: With criteria, scores are more spread out (0.116 to 0.666) and reflect the criteria weights, while without criteria, scores are more clustered (0.336 to 0.607) and based purely on relevance.
3. **Trait Sensitivity**: “Rainy day” content is penalized due to negative tone. “Storm curiosity” is recognized and scored accordingly.
1. **Memory Ordering**: With criteria, memories with high joy scores (like feeling refreshed and drawing) are ranked higher. Without criteria, the most relevant memory ("User is happy today") comes first.
2. **Score Distribution**: With criteria, scores are more spread out (0.116 to 0.666) and reflect the criteria weights. Without criteria, scores are more clustered (0.336 to 0.607) and based purely on relevance.
3. **Trait Sensitivity**: "Rainy day" content is penalized due to negative tone, while "Storm curiosity" is recognized and scored accordingly.
@@ -173,10 +173,10 @@ If no criteria are defined for a project, `version="v2"` behaves like normal sea
## Best Practices
- Choose **3–5 criteria** that reflect your application’s intent
- Make descriptions **clear and distinct**, those are interpreted by an LLM
- Use **stronger weights** to amplify impact of important traits
- Avoid redundant or ambiguous criteria (e.g. “positivity” + “joy”)
- Choose 3-5 criteria that reflect your application's intent
- Make descriptions clear and distinct; these are interpreted by an LLM
- Use stronger weights to amplify the impact of important traits
- Avoid redundant or ambiguous criteria (e.g., "positivity" and "joy")
- Always handle empty result sets in your application logic
+4 -3
View File
@@ -5,9 +5,9 @@ icon: "tags"
iconType: "solid"
---
## How to set custom categories?
## How to Set Custom Categories
You can now create custom categories tailored to your specific needs, instead of using the default categories such as travel, sports, music, and more (see [default categories](#default-categories) below). **When custom categories are provided, they will override the default categories.**
You can create custom categories tailored to your specific needs instead of using the default categories such as travel, sports, and music (see [default categories](#default-categories) below). When custom categories are provided, they will override the default categories.
There are two ways to set custom categories:
@@ -93,7 +93,8 @@ These project-level categories will be automatically applied to all new memories
### 2. During the `add` API call
### 2. During the `add` API Call
You can also set custom categories during the `add` API call. This will override any project-level custom categories for that specific memory addition. For example, if you want to use different categories for food-related memories, you can provide custom categories like "food" and "user_preferences" in the `add` call. These custom categories will be used instead of the project-level categories when categorizing those specific memories.
<CodeGroup>
@@ -7,7 +7,7 @@ iconType: "solid"
## What are Custom Instructions?
Custom instructions are natural language guidelines that tell Mem0 exactly what information to extract and remember from conversations. Think of them as smart filters that ensure your AI application captures only the most relevant data for your specific use case.
Custom instructions are natural language guidelines that tell Mem0 exactly what information to extract and remember from conversations. They act as smart filters that ensure your AI application captures only the most relevant data for your specific use case.
<CodeGroup>
```python Python
@@ -291,7 +291,7 @@ client.project.update(custom_instructions=advanced_prompt)
### Testing Your Instructions
Always test your custom instructions with real messages examples:
Always test your custom instructions with real message examples:
<CodeGroup>
```python Python
+9 -10
View File
@@ -5,9 +5,9 @@ icon: "arrow-right"
iconType: "solid"
---
## How to use Direct Import?
The Direct Import feature allows users to skip the memory deduction phase and directly input pre-defined memories into the system for storage and retrieval.
To enable this feature, you need to set the `infer` parameter to `False` in the `add` method.
## How to Use Direct Import
The Direct Import feature allows users to skip the memory deduction phase and directly input pre-defined memories into the system for storage and retrieval. To enable this feature, set the `infer` parameter to `False` in the `add` method.
<CodeGroup>
@@ -17,7 +17,7 @@ To enable this feature, you need to set the `infer` parameter to `False` in the
messages = [
{"role": "user", "content": "Alice loves playing badminton"},
{"role": "assistant", "content": "That's great! Alice is a fitness freak"},
{"role": "user", "content": "Alice mostly cook at home because of gym plan"},
{"role": "user", "content": "Alice mostly cooks at home because of her gym plan"},
]
@@ -29,12 +29,11 @@ client.add(messages, user_id="alice", infer=False)
```
</CodeGroup>
You can see that the output of add call is an empty list.
You can see that the output of the add call is an empty list.
<Note> Only messages with the role "user" will be used for storage. Messages with roles such as "assistant" or "system" will be ignored during the storage process. </Note>
<Note>Only messages with the role "user" will be used for storage. Messages with roles such as "assistant" or "system" will be ignored during the storage process.</Note>
## How to retrieve memories?
## How to Retrieve Memories
You can retrieve memories using the `search` method.
@@ -62,7 +61,7 @@ client.search("What is Alice's favorite sport?", user_id="alice")
</CodeGroup>
## How to retrieve all memories?
## How to Retrieve All Memories
You can retrieve all memories using the `get_all` method.
@@ -86,7 +85,7 @@ client.get_all(query="What is Alice's favorite sport?", user_id="alice", output_
},
{
"id": "8557f05d-7b3c-47e5-b409-9886f9e314fc",
"memory": "Alice mostly cook at home because of gym plan",
"memory": "Alice mostly cooks at home because of her gym plan",
"user_id": "pc123",
"metadata": null,
"categories": null,
+8 -9
View File
@@ -9,15 +9,14 @@ iconType: "solid"
Setting expiration dates for memories offers several advantages:
• **Time-Sensitive Information Management**: Handle information that's only relevant for a specific time period.
• **Event-Based Memory**: Manage information related to upcoming events that becomes irrelevant after the event passes.
- **Time-Sensitive Information Management**: Handle information that is only relevant for a specific time period.
- **Event-Based Memory**: Manage information related to upcoming events that becomes irrelevant after the event passes.
These benefits enable more sophisticated memory management for applications where temporal context matters.
## Setting Memory Expiration Date
You can set an expiration date for memories, after which they will no longer be retrieved in searches. This is useful for creating temporary memories or memories that are only relevant for a specific time period.
You can set an expiration date for memories, after which they will no longer be retrieved in searches. This is useful for creating temporary memories or memories that are relevant only for a specific time period.
<CodeGroup>
@@ -30,7 +29,7 @@ client = MemoryClient(api_key="your-api-key")
messages = [
{
"role": "user",
"content": "I'll be in San Francisco until end of this month."
"content": "I'll be in San Francisco until the end of this month."
}
]
@@ -48,7 +47,7 @@ const client = new MemoryClient({ apiKey: 'your-api-key' });
const messages = [
{
"role": "user",
"content": "I'll be in San Francisco until end of this month."
"content": "I'll be in San Francisco until the end of this month."
}
];
@@ -79,7 +78,7 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \
"messages": [
{
"role": "user",
"content": "I'll be in San Francisco until end of this month."
"content": "I'll be in San Francisco until the end of this month."
}
],
"user_id": "alex",
@@ -93,7 +92,7 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \
{
"id": "a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5",
"data": {
"memory": "In San Francisco until end of this month"
"memory": "In San Francisco until the end of this month"
},
"event": "ADD"
}
@@ -104,7 +103,7 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \
</CodeGroup>
<Note>
Once a memory reaches its expiration date, it won't be included in search or get results, though the data remains stored in the system.
Once a memory reaches its expiration date, it will not be included in search or get results, though the data remains stored in the system.
</Note>
If you have any questions, please feel free to reach out to us using one of the following methods:
+17 -14
View File
@@ -4,11 +4,11 @@ icon: "thumbs-up"
iconType: "solid"
---
Mem0's **Feedback Mechanism** allows you to provide feedback on the memories generated by your application. This feedback is used to improve the accuracy of the memories and the search results.
Mem0's Feedback Mechanism allows you to provide feedback on the memories generated by your application. This feedback is used to improve the accuracy of the memories and search results.
## How it works
The feedback mechanism is a simple API that allows you to provide feedback on the memories generated by your application. The feedback is stored in the database and is used to improve the accuracy of the memories and the search results. Over time, Mem0 continuously learns from this feedback, refining its memory generation and search capabilities for better performance.
The feedback mechanism is a simple API that allows you to provide feedback on the memories generated by your application. The feedback is stored in the database and used to improve the accuracy of the memories and search results. Over time, Mem0 continuously learns from this feedback, refining its memory generation and search capabilities for better performance.
## Give Feedback
@@ -118,27 +118,30 @@ for (const item of feedbackData) {
## Best Practices
### When to Provide Feedback
- **Immediately after memory retrieval** when you can assess relevance
- **During user interactions** when users explicitly indicate satisfaction/dissatisfaction
- **Through automated evaluation** using your application's success metrics
- Immediately after memory retrieval when you can assess relevance
- During user interactions when users explicitly indicate satisfaction or dissatisfaction
- Through automated evaluation using your application's success metrics
### Effective Feedback Reasons
Provide specific, actionable feedback reasons:
✅ **Good examples:**
**Good examples:**
- "Contains outdated contact information"
- "Accurately captured the user's dietary restrictions"
- "Irrelevant to the current conversation context"
❌ **Avoid vague reasons:**
**Avoid vague reasons:**
- "Bad memory"
- "Wrong"
- "Not good"
### Feedback Strategy
1. **Be consistent** - Apply the same criteria across similar memories
2. **Be specific** - Detailed reasons help improve the system faster
3. **Monitor patterns** - Regular feedback analysis helps identify improvement areas
1. Be consistent: Apply the same criteria across similar memories
2. Be specific: Detailed reasons help improve the system faster
3. Monitor patterns: Regular feedback analysis helps identify improvement areas
## Error Handling
@@ -194,8 +197,8 @@ try {
Track the impact of your feedback by monitoring memory performance over time. Consider implementing:
- **Feedback completion rates** - What percentage of memories receive feedback
- **Feedback distribution** - Balance of positive vs. negative feedback
- **Memory quality trends** - How accuracy improves with feedback volume
- **User satisfaction metrics** - Correlation between feedback and user experience
- Feedback completion rates: What percentage of memories receive feedback
- Feedback distribution: Balance of positive vs. negative feedback
- Memory quality trends: How accuracy improves with feedback volume
- User satisfaction metrics: Correlation between feedback and user experience
+7 -9
View File
@@ -7,7 +7,7 @@ description: "Enable graph-based memory retrieval for more contextually relevant
## Overview
Graph Memory enhances memory pipeline by creating relationships between entities in your data. It builds a network of interconnected information for more contextually relevant search results.
Graph Memory enhances the memory pipeline by creating relationships between entities in your data. It builds a network of interconnected information for more contextually relevant search results.
This feature allows your AI applications to understand connections between entities, providing richer context for responses. It's ideal for applications needing relationship tracking and nuanced information retrieval across related memories.
@@ -112,9 +112,7 @@ The graph memory would look like this:
<Note>
Response for the graph memory's `add` operation will not be available directly in the response.
As adding graph memories is an asynchronous operation due to heavy processing,
you can use the `get_all()` endpoint to retrieve the memory with the graph metadata.
Response for the graph memory's `add` operation will not be available directly in the response. As adding graph memories is an asynchronous operation due to heavy processing, you can use the `get_all()` endpoint to retrieve the memory with the graph metadata.
</Note>
@@ -320,10 +318,10 @@ const client = new MemoryClient({
project_id: "your-project-id"
});
# Enable graph memory for all operations in this project
// Enable graph memory for all operations in this project
await client.updateProject({ enable_graph: true, version: "v1" });
# Now all add operations will use graph memory by default
// Now all add operations will use graph memory by default
const messages = [
{ role: "user", content: "My name is Joseph" },
{ role: "assistant", content: "Hello Joseph, it's nice to meet you!" },
@@ -342,9 +340,9 @@ await client.add({
## Best Practices
- Enable Graph Memory for applications where understanding context and relationships between memories is important
- Graph Memory works best with a rich history of related conversations
- Consider Graph Memory for long-running assistants that need to track evolving information
- Enable Graph Memory for applications where understanding context and relationships between memories is important.
- Graph Memory works best with a rich history of related conversations.
- Consider Graph Memory for long-running assistants that need to track evolving information.
## Performance Considerations
+1 -3
View File
@@ -7,8 +7,6 @@ iconType: "solid"
<Snippet file="paper-release.mdx" />
## Introduction to the Group Chat
## Overview
The Group Chat feature enables Mem0 to process conversations involving multiple participants and automatically attribute memories to individual speakers. This allows for precise tracking of each participant's preferences, characteristics, and contributions in collaborative discussions, team meetings, or multi-agent conversations.
@@ -288,4 +286,4 @@ Each message in a group chat must include:
If you have any questions, please feel free to reach out to us using one of the following methods:
<Snippet file="get-help.mdx" />
<Snippet file="get-help.mdx" />
@@ -5,7 +5,7 @@ icon: "image"
iconType: "solid"
---
Mem0 extends its capabilities beyond text by supporting multimodal data, including images and documents. With this feature, users can seamlessly integrate visual and document content into their interactions—allowing Mem0 to extract relevant information from various media types and enrich the memory system.
Mem0 extends its capabilities beyond text by supporting multimodal data, including images and documents. With this feature, users can seamlessly integrate visual and document content into their interactions, allowing Mem0 to extract relevant information from various media types and enrich the memory system.
## How It Works
@@ -101,7 +101,7 @@ Mem0 currently supports the following media types:
### 1. Images
#### Using an Image URL (Recommended)
#### Using an Image URL
You can include an image by providing its direct URL. This method is simple and efficient for online images.
@@ -124,7 +124,7 @@ client.add([image_message], user_id="alice")
#### Using Base64 Image Encoding for Local Files
For local images—or when embedding the image directly is preferable—you can use a Base64-encoded string.
For local images or when embedding the image directly is preferable, you can use a Base64-encoded string.
<CodeGroup>
```python Python
+7 -13
View File
@@ -9,24 +9,19 @@ iconType: "solid"
Memory customization offers several key benefits:
• **Focused Storage**: Store only relevant information for a streamlined system.
• **Improved Accuracy**: Curate memories for more accurate and relevant retrieval.
• **Enhanced Privacy**: Exclude sensitive information for better privacy control.
• **Resource Efficiency**: Optimize storage and processing by keeping only pertinent data.
• **Personalization**: Tailor the experience to individual user preferences.
• **Contextual Relevance**: Improve effectiveness in specialized domains or applications.
- **Focused Storage**: Store only relevant information for a streamlined system.
- **Improved Accuracy**: Curate memories for more accurate and relevant retrieval.
- **Enhanced Privacy**: Exclude sensitive information for better privacy control.
- **Resource Efficiency**: Optimize storage and processing by keeping only pertinent data.
- **Personalization**: Tailor the experience to individual user preferences.
- **Contextual Relevance**: Improve effectiveness in specialized domains or applications.
These benefits allow users to fine-tune their memory systems, creating a more powerful and personalized AI assistant experience.
## Memory Inclusion
Users can define specific kinds of memories to store. This feature enhances memory management by focusing on relevant information, resulting in a more efficient and personalized experience.
Here’s how you can do it:
```python
import os
@@ -69,7 +64,6 @@ User loves playing baseball with friends.
## Memory Exclusion
In addition to specifying what to include, users can also define exclusion rules for their memory management. This feature allows for fine-tuning the memory system by instructing it to omit certain types of information.
Here’s how you can do it:
```python
from mem0 import MemoryClient
+4 -7
View File
@@ -20,13 +20,10 @@ By leveraging custom timestamps, you can ensure that your memory system maintain
Custom timestamps offer several important benefits:
• **Historical Accuracy**: Preserve the exact timing of past events and information.
• **Data Migration**: Seamlessly migrate existing data while maintaining original timestamps.
• **Time-Sensitive Analysis**: Enable time-based analysis and pattern recognition across memories.
• **Consistent Chronology**: Maintain proper ordering of memories for coherent storytelling.
- **Historical Accuracy**: Preserve the exact timing of past events and information.
- **Data Migration**: Seamlessly migrate existing data while maintaining original timestamps.
- **Time-Sensitive Analysis**: Enable time-based analysis and pattern recognition across memories.
- **Consistent Chronology**: Maintain proper ordering of memories for coherent storytelling.
## Using Custom Timestamps
+3 -6
View File
@@ -13,7 +13,7 @@ Webhooks enable real-time notifications for memory events in your Mem0 project.
### Create Webhook
Create a webhook for your project; it will receive events only from that project:
Create a webhook for your project. It will receive events only from that project:
<CodeGroup>
```python Python
@@ -188,13 +188,10 @@ When a memory event occurs, Mem0 sends an HTTP POST request to your webhook URL
## Best Practices
1. **Implement Retry Logic**: Ensure your webhook endpoint can handle temporary failures by implementing retry logic.
1. **Implement Retry Logic**: Ensure your webhook endpoint can handle temporary failures.
2. **Verify Webhook Source**: Implement security measures to verify that webhook requests originate from Mem0.
3. **Process Events Asynchronously**: Process webhook events asynchronously to avoid timeouts and ensure reliable handling.
4. **Monitor Webhook Health**: Regularly review your webhook logs to ensure functionality and promptly address any delivery failures.
4. **Monitor Webhook Health**: Regularly review your webhook logs to ensure functionality and promptly address delivery failures.
If you have any questions, please feel free to reach out to us using one of the following methods: