v9.1.1
Menu

Chapter 6: Memory II: Hybrid Stores, Mem0 & Skill Libraries

Week 5-6

Beyond MemGPT's two-tier model: hybrid memory architectures that fuse vector, graph, and lexical retrieval; the Mem0 architecture for production-scale agent memory; Voyager-style skill libraries that turn execution traces into reusable code.

Topics
5
Videos
3
Min read
14

Chapter Overview

MemGPT solved the capacity problem — how to store more than fits in the context window. Memory II is about the quality problem — when you have memory, how do you find the right piece, and how do you turn experience into reusable knowledge?

Two families of techniques:

  1. Hybrid retrieval. A single retrieval mode (vector similarity) misses important matches. Mem0 (the production memory framework) fuses vector, graph, and lexical search, then re-ranks. The win: ~26% better recall vs. vector-only, with lower context usage.
  2. Skill libraries. Voyager (Wang et al., 2023) showed that an agent can turn successful execution traces into named, reusable skills (functions in code). On novel tasks, the agent retrieves matching skills instead of re-deriving them — exponential speedup on familiar problem classes.

This chapter covers:

  • Hybrid vector + graph + lexical memory — when each retrieval mode wins
  • Mem0 architecture — production-grade agent memory
  • Voyager skill libraries — turning experience into code
  • Skill acquisition vs retrieval — when to learn a new skill, when to use an old one
  • Memory evaluation — how to measure whether your memory system is actually helping

Chapter Roadmap

Click any topic to jump in

Explainer video
1
Hybrid Retrieval

Vector + graph + lexical retrieval, fused via RRF. Each mode wins different queries.

What Each Retrieval Mode Is Good AtReciprocal Rank Fusion (RRF)
Two complementary memory architectures

Declarative facts (Mem0) and procedural skills (Voyager)

2
Mem0

Production memory framework: atomic facts, relationships, summaries — hybrid retrieval at all three levels.

The Mem0 Memory ModelFact Extraction: Where the Quality Comes From
3
Voyager Skills

Persistent procedural memory — turn successful execution traces into named, retrievable skills.

How Voyager Builds SkillsSkill Libraries Beyond Games
The discipline that keeps a skill library healthy
4
Acquisition vs Retrieval

When to learn a new skill, when to use an old one. The library-as-codebase discipline.

When to Acquire a New SkillLibrary Maintenance
The metrics that tell you whether any of this is working
5
Memory Evaluation

Recall@k, consistency, latency, and the 'did memory help?' test that matters most.

Three Quality DimensionsThe 'Did Memory Help?' Test

Topics

5 topics in this chapter

Chapter 5 gave the agent somewhere to put its memories; it said nothing about how to find the right one again. The default answer in 2023 was a single move: embed every memory, embed the query, return the nearest vectors by cosine similarity. That works often enough to feel solved, which is exactly why its failures are dangerous. Vector search misses three whole classes of query — a fact that shares an entity with the query but none of its words, an exact identifier like an order number drowning under semantically similar neighbours, and a multi-hop question whose answer no single embedding ever captured. This topic is where memory retrieval stops being one algorithm and becomes a portfolio. You will meet the three retrieval modes — dense vector, graph traversal, and lexical BM25 — and see precisely which query each one wins and loses. Then the next topic, Reciprocal Rank Fusion, shows how to combine their rankings into one without needing their scores to live on the same scale. Hybrid retrieval is the foundation the rest of the chapter's production memory stack sits on.

Definition

Hybrid memory retrieval runs several complementary retrievers — typically dense vector search, knowledge-graph traversal, and lexical BM25 keyword matching — over the same memory store in parallel, then fuses their separate rankings into one. Each mode covers the queries the others miss, so the combined recall exceeds any single retriever, especially on entity-sharing, exact-identifier, and multi-hop questions.

In this topic

  1. 1What Each Retrieval Mode Is Good At
  2. 2Reciprocal Rank Fusion (RRF)
1 of 2
What Each Retrieval Mode Is Good At

Vector retrieval. Embeds memory and query into a shared dense space; returns top-kk by cosine similarity. Wins when: the user's question and the relevant memory share concepts but not words ('the doctor I saw last month' → memory about Dr. Lee). Loses when: the user wants an exact identifier ('order #1234') — a vector store may return 'similar' orders rather than the exact match.

Graph retrieval. Stores memory as a knowledge graph: entities (people, projects, topics) connected by typed relationships ('works_with', 'mentioned_in'). Traverses from a query entity outward by relation. Wins when: the question is multi-hop ('what did Alice say about Bob's project?'). Loses when: the query is unstructured natural language with no clear entities.

Lexical retrieval (BM25 / keyword). Classic IR — score by term frequency × inverse document frequency. Wins when: the user uses specific keywords (acronyms, identifiers, proper nouns). Loses when: the user's terminology differs from what's in memory.

No single mode wins all queries. Hybrid retrieval runs all three in parallel and fuses the results.

2 of 2
Reciprocal Rank Fusion (RRF)

score(d)=∑r∈rankers1k+rankr(d)\text{score}(d) = \sum_{r \in \text{rankers}} \frac{1}{k + \text{rank}_r(d)}

The dominant fusion method: Reciprocal Rank Fusion (RRF). For each retriever, get the top-NN results in ranked order. For each candidate document, sum 1/(k+rank)1 / (k + \text{rank}) across all retrievers (with a constant k≈60k \approx 60 to dampen the head). The fused ranking is by the summed score.

RRF's appeal: scale-free. It does not require calibrated scores from each retriever (which is hard — vector cosines and BM25 scores live on different scales). Just the rank matters. A document that's #1 in vector AND #3 in BM25 is almost certainly the best answer. A document that's only #1 in vector but #50 in BM25 is suspect.

Production systems weight the retrievers (vector_weight = 0.6, lexical_weight = 0.3, graph_weight = 0.1) — typically learned from a retrieval-quality eval set.