Memory Systems / AI Architecture

Episodic Memory

Advanced [4/5]
Event memory Experience memory Conversation history

Definition

Episodic Memory in AI systems stores specific events, experiences, and interactions - the "what, when, where" of past encounters. Unlike semantic memory (facts), episodic memory captures temporal sequences and contextual details of experiences.

For LLM applications, episodic memory enables systems to remember past conversations, user interactions, and specific events to provide more personalized and contextually aware responses.

Key Concepts

  • Temporal context: When did the event/interaction occur?
  • Autobiographical: First-person experience records
  • Retrieval cues: How to find relevant memories
  • Memory consolidation: Important events → long-term storage

Examples

Comparison
Episodic vs Semantic Memory
MEMORY TYPES IN AI SYSTEMS: SEMANTIC MEMORY (Facts/Knowledge): "Python is a programming language." "The capital of France is Paris." "Machine learning uses statistical methods." → General knowledge, context-independent EPISODIC MEMORY (Events/Experiences): "On March 15, user asked about Python sorting." "Last session, user mentioned they're a beginner." "User previously had trouble with async/await." → Specific experiences, context-dependent --- COMPARISON: ┌─────────────────┬────────────────┬─────────────────┐ │ Aspect │ Semantic │ Episodic │ ├─────────────────┼────────────────┼─────────────────┤ │ Content │ Facts, concepts│ Events, episodes│ │ Time-bound │ No │ Yes │ │ Personal │ No │ Yes │ │ Example │ "2+2=4" │ "User asked 2+2"│ │ Retrieval │ By topic │ By time/context │ │ Updates │ Rare │ Continuous │ └─────────────────┴────────────────┴─────────────────┘ --- IN LLM APPLICATIONS: Without Episodic Memory: User: "Remember when I asked about React?" Bot: "I don't have memory of past conversations." With Episodic Memory: User: "Remember when I asked about React?" Bot: "Yes, on Tuesday you asked about React hooks. We discussed useState and useEffect. You were building a todo app. How's that going?" VALUE OF EPISODIC MEMORY: ✓ Continuity across conversations ✓ Personalization ("You mentioned preferring...") ✓ Context ("Last time you were stuck on...") ✓ Relationship building (remembering preferences)
Implementation
Episodic Memory System Architecture
EPISODIC MEMORY IMPLEMENTATION: 1. MEMORY STRUCTURE: { "episode_id": "conv_2024_03_15_001", "timestamp": "2024-03-15T14:30:00Z", "user_id": "user_123", "context": { "topic": "Python debugging", "user_goal": "Fix async bug", "emotional_state": "frustrated" }, "events": [ { "type": "user_message", "content": "My async code isn't working", "time": "14:30:00" }, { "type": "assistant_response", "content": "Let's check your await usage...", "time": "14:30:15" }, { "type": "resolution", "outcome": "Fixed missing await keyword", "time": "14:45:00" } ], "summary": "Helped user fix async bug caused by missing await in Python code.", "tags": ["python", "async", "debugging", "resolved"] } 2. RETRIEVAL STRATEGIES: # Time-based retrieval recent = get_episodes(user_id, last_n_days=7) # Similarity-based retrieval relevant = search_episodes( user_id, query="async programming", top_k=5 ) # Context-based retrieval related = get_episodes( user_id, topic="python", outcome="unresolved" ) 3. MEMORY INJECTION INTO PROMPT: prompt = f""" Relevant past interactions with this user: {format_episodes(retrieved_episodes)} Current conversation: User: {current_message} Remember the user's past context when responding. """ 4. MEMORY LIFECYCLE: New Event → Short-term (current session) → Importance evaluation → If important: Long-term storage → Periodic consolidation/summarization → Retrieval when relevant IMPORTANCE SCORING: - User explicitly asked to remember: +10 - Problem was resolved: +5 - User expressed strong emotion: +3 - Mentioned future plans: +4 - Routine exchange: +1

Interactive Exercise

Design Memory Record

Scenario: A user says "I finally got that React hook working! Thanks for explaining useEffect last week."

Design the episodic memory record for this interaction. What should be stored?

Pro Tips
  • Store summaries, not full transcripts (saves space, protects privacy)
  • Include emotional context - it aids future personalization
  • Link related episodes together for richer retrieval
  • Implement forgetting - not all memories should persist forever

Related Terms