Understanding Custom Categories in Mem0

Understanding Custom Categories in Mem0

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:

  • A cooking app might need categories for recipes, ingredients, and cooking techniques
  • A fitness platform could benefit from categories for workout types, nutrition, and progress tracking
  • A healthcare assistant might require categories for symptoms, medications, and treatment plans

When designing your custom categories, consider:

  • Your application's specific domain
  • User interaction patterns
  • Types of information you need to recall
  • How categories might evolve as your application grows

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

  • Be Descriptive: Provide detailed descriptions for your categories. The more specific you are, the better Mem0 can categorize and retrieve relevant information.
  • Avoid Overlap: Before creating custom categories, review Mem0's default categories to prevent redundancy
  • Stay Focused: Create categories that serve a clear purpose in your application. Don't create categories just because you can.

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 cutegories in your memory. You can also reach out to us at founders@mem0.ai.