docs/platform/features/feedback-mechanism.mdx
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.
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.
You can give feedback on a memory by calling the feedback method on the Mem0 client.
from mem0 import MemoryClient
client = MemoryClient(api_key="your_api_key")
client.feedback(memory_id="your-memory-id", feedback="NEGATIVE", feedback_reason="I don't like this memory because it is not relevant.")
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: 'your-api-key'});
client.feedback({
memory_id: "your-memory-id",
feedback: "NEGATIVE",
feedback_reason: "I don't like this memory because it is not relevant."
})
The feedback parameter can be one of the following values:
POSITIVE: The memory is useful.NEGATIVE: The memory is not useful.VERY_NEGATIVE: The memory is not useful at all.The feedback method accepts these parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
memory_id | string | Yes | The ID of the memory to give feedback on |
feedback | string | No | Type of feedback: POSITIVE, NEGATIVE, or VERY_NEGATIVE |
feedback_reason | string | No | Optional explanation for the feedback |
For applications with high volumes of feedback, you can provide feedback on multiple memories at once:
<CodeGroup>from mem0 import MemoryClient
client = MemoryClient(api_key="your_api_key")
# Bulk feedback example
feedback_data = [
{
"memory_id": "memory-1",
"feedback": "POSITIVE",
"feedback_reason": "Accurately captured the user's preference"
},
{
"memory_id": "memory-2",
"feedback": "NEGATIVE",
"feedback_reason": "Contains outdated information"
}
]
for item in feedback_data:
client.feedback(**item)
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: 'your-api-key'});
// Bulk feedback example
const feedbackData = [
{
memory_id: "memory-1",
feedback: "POSITIVE",
feedback_reason: "Accurately captured the user's preference"
},
{
memory_id: "memory-2",
feedback: "NEGATIVE",
feedback_reason: "Contains outdated information"
}
];
for (const item of feedbackData) {
await client.feedback(item);
}
Provide specific, actionable feedback reasons:
Good examples:
Avoid vague reasons:
Handle potential errors when submitting feedback:
<CodeGroup>from mem0 import MemoryClient
from mem0.exceptions import MemoryNotFoundError, APIError
client = MemoryClient(api_key="your_api_key")
try:
client.feedback(
memory_id="memory-123",
feedback="POSITIVE",
feedback_reason="Helpful context for user query"
)
print("Feedback submitted successfully")
except MemoryNotFoundError:
print("Memory not found")
except APIError as e:
print(f"API error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: 'your-api-key'});
try {
await client.feedback({
memory_id: "memory-123",
feedback: "POSITIVE",
feedback_reason: "Helpful context for user query"
});
console.log("Feedback submitted successfully");
} catch (error) {
if (error.status === 404) {
console.log("Memory not found");
} else {
console.log(`Error: ${error.message}`);
}
}
Track the impact of your feedback by monitoring memory performance over time. Consider implementing: