-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
🚀 The feature
TLDR: Add a get_profile() method that generates an evolving, compact user profile (200–400 tokens) for use as baseline session context. Profiles update automatically from memories and provide a semantic “who the user is” layer alongside episodic RAG retrieval.
I want to add a get_profile() method that generates a continuously-updated user profile for every AI interaction. This could piggy-back off of custom fact extraction methods.
- Compact (200–400 tokens)
- Configurable (prompt, size, update rules)
- Cached + auto-updated
- Complements RAG
Example Config (mirrors custom_fact_extraction_prompt)
from mem0 import Memory
config = {
"llm": {"provider": "openai", "config": {"model": "gpt-4o-mini"}},
# NEW: Custom profile prompt
"custom_profile_prompt": """
Generate a concise user profile (200-400 tokens) covering:
- Demographics and role
- Communication preferences
- Key expertise/skills
- Major interests and preferences
- Current goals/context
Focus on stable, high-level traits, not specific events.
""",
# NEW: Profile auto-update config
"profile_config": {
"max_tokens": 400,
"auto_update": True,
"update_triggers": {
"memory_count": 10, # Update after N new memories
"time_elapsed": 86400 # Update daily
}
}
}
m = Memory.from_config(config_dict=config)
# Profile auto-updates in background (like custom facts)
m.add(messages, user_id="alice")
# Fast retrieval - always returns cached version
profile = m.get_profile(user_id="alice")
Usage in session context
system_prompt = f"""You are an AI assistant.
User Profile:
{profile}
Relevant Memories:
{m.search(query=user_message, user_id="alice", limit=3)}
"""
Motivation, pitch
Mem0 currently excels at extracting episodic memories (facts/events) via RAG. But there’s no way to generate a holistic, semantic profile that answers “who is this person?” Humans maintain both episodic (specific) and semantic (general) memory; mem0 only covers episodic well today.
My Use Case (I'm building MindMe, an AI mental health companion)
In MindMe (AI mental health assistant), each session would includes:
- User Profile (300 tokens, every session)
- Retrieved Memories (200 tokens, query-specific)
- Conversation History Window(last 5 turns)
Example profiles:
Customer Support: "Alice is a premium customer, prefers technical details, timezone PST"
Healthcare: "Patient has diabetes, prefers morning appointments, anxious about needles"
Education: "Student struggles with calculus, visual learner, preparing for AP exam"