Understanding Custom Categories in Mem0

Understanding Custom Categories in Mem0

Taranjeet Singh
October 25, 2024

Mem0's Custom Categories feature that is available on the Mem0 platform is a powerful tool for developers and businesses looking to create more intelligent and context-aware applications. This guide will walk you through everything you need to know about Custom Categories in Mem0.

What Are Custom Categories in Mem0?

At its core, Mem0 is an AI Memory Platform that helps reduce LLM costs while maintaining contextual understanding across interactions. Custom Categories enhance this capability by allowing you to define specialized memory categories tailored to your specific use case.

Mem0 comes with default categories so before creating custom categories make sure there is no overlap. The default categories are:

personal_details, family, professional_details, sports, travel, food, music, health, technology, hobbies, fashion, entertainment, milestones, user_preferences, misc

Why Use Custom Categories?

Think of custom categories as creating specialized "folders" in your AI's memory. While Mem0 comes with default categories covering common areas like personal details, sports, and entertainment, your application might need more specific categorization. For example:

When designing your custom categories, consider:

Implementing Custom Categories

Let's walk through a practical example of implementing Custom Categories:

from mem0 import MemoryClient

# Initialize the client
client = MemoryClient(api_key="your_api_key_here")

# Define custom categories
custom_categories = [
    {
        "gaming": "For users interested in video games, including gaming preferences, favorite titles, and gaming setup."
    },
    {
        "technology": "Includes content related to tech interests, such as programming languages and hardware preferences."
    }
]

# Example conversation
messages = [
    {"role": "user", "content": "Hi, I'm Mark. I mainly code in JavaScript."},
    {"role": "assistant", "content": "Hello Mark! JavaScript is a versatile language. How can I help you today?"},
    {"role": "user", "content": "I play League of Legends competitively."},
    {"role": "assistant", "content": "That's impressive! Competitive gaming requires great skill and dedication."},
]

# Add memories with custom categories
client.add(messages, user_id="mark", custom_categories=custom_categories, output_format="v1.1")

# Output in v1.1 format
{
    "results": [
        {
            "memory": "Codes in JavaScript",
            "event": "ADD",
        },
        {
            "memory": "Plays League of Legends competitively",
            "event": "ADD",
        },
    ],
    "status": "success"
}

Best Practices for Custom Categories

Conclusion

Custom Categories in Mem0 offer a powerful way to organize and retrieve AI memories efficiently. By following this guide and best practices, you can create a more intelligent, context-aware application that better serves your users' needs.

View Mem0's Custom Categories documentation to learn more about integrating custom categories in your memory. You can also reach out to us at founders@mem0.ai.