Memory Types
Understand how AI agents store, retrieve, and manage information across different memory systems
Your Progress
0 / 5 completedSmart Memory Retrieval
Having thousands of memories is useless if you can't find the right ones at the right time. Retrieval strategies determine which memories to surface when the agent needs context. The goal: maximum relevance with minimal cost.
Retrieval Strategy Comparison
Relevance-Based Retrieval (Semantic Search)
Find memories most semantically similar to current query using vector embeddings. Higher quality but computationally expensive.
similarities = cosine_sim(query_emb, memory_embs)
top_k = argsort(similarities)[:k]
- β’ Finds truly relevant information
- β’ Works across time spans
- β’ Handles paraphrasing well
- β’ Requires embedding all memories
- β’ Slower than simple sorting
- β’ May ignore recent context shifts
Interactive: Similarity Threshold Explorer
Query: "Book a flight to New York" - Adjust threshold to see which memories qualify
Retrieved Memories (3)
Strategy: relevanceAdvanced Retrieval Techniques
Multi-Index Search
Maintain multiple indexes: by time, by user, by topic, by importance. Query the relevant index based on context.
elif user_query: search(user_index)
Approximate Search (ANN)
Use HNSW, FAISS, or ScaNN for fast approximate nearest neighbor search. Trade accuracy for speed at scale.
results = index.search(query, k=10)
Caching Hot Memories
Cache frequently accessed memories in fast storage (Redis, in-memory). LRU eviction for less-used items.
return cache.get_or_fetch(memory_id)
Metadata Filtering
Pre-filter by metadata before semantic search. "Only memories from user X in last 30 days."
Β Β user=user_id, age<30
).search(query)