Personal Memory Model Architecture: A Three-Database Fusion Approach
Abstract: Today's large language models are fundamentally stateless β every conversation starts from scratch. To give AI a persistent past, you need an external memory system. This paper presents our personal memory model architecture: a foundation built on MySQL (structured data) + Milvus (vector search) + Neo4j (knowledge graph), incorporating memory tiering, segmented heat decay, and multi-dimensional importance scoring β enabling AI to remember what matters and forget what doesn't, just like humans do.
1. Why AI Needs Persistent Memory
If you've ever chatted with an AI assistant, you've probably experienced this: yesterday you told it you're allergic to peanuts, today it recommends peanut sauce. The model isn't stupid β it simply can't remember. When a conversation ends, the context window is wiped clean.
Humans build lasting relationships, accumulate experience, and make personalized decisions through memory. An AI without memory, regardless of its parameter count, is just a "clever instant-answer machine." For AI to evolve from tool to companion, three problems must be solved:
- Retention: Reliably storing what has happened.
- Retrieval: Quickly and accurately finding relevant memories when needed.
- Prioritization: Like humans β holding tightly to what matters, letting trivia fade.
Each of these hides engineering challenges. Take "retrieval" β when memory entries reach tens of thousands, traditional keyword matching is both slow and imprecise. When a user says "working late," the system needs to connect that to last week's conversation about "project crunch" and "4 AM." That requires semantic-level understanding. Or "prioritization" β if you dump every conversation into a database, noise quickly drowns out the signal.
We built our memory system to solve all three systematically.
2. Overall Architecture: Three Databases, Three Jobs
We didn't shove everything into one database. Instead, we adopted a three-database fusion architecture. The reason is straightforward: no single database can efficiently handle precise matching, semantic similarity, and relationship reasoning simultaneously.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Memory Service Layer β
β (HTTP API + Save Pipeline + Search Pipeline + Cron) β
ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββΌβββββββββββββββββ
βΌ βΌ βΌ
βββββββββββ βββββββββββ βββββββββββ
β MySQL β β Milvus β β Neo4j β
βStructuredβ β Vector β β Graph β
β Exact β βSemantic β βRelationsβ
βββββββββββ βββββββββββ βββββββββββ
Each database has a clear role:
| Database | What It's Good At | Role in Memory System |
|---|---|---|
| MySQL | Structured queries, full-text search, transactions | Stores raw memory text, metadata, tags, statistics; exact keyword matching |
| Milvus | Approximate nearest neighbor search on high-dim vectors | Converts each memory into a 1024-dimensional vector for semantic similarity search |
| Neo4j | Graph traversal, multi-hop relationship reasoning | Builds entity-relationship knowledge graphs for "following the thread" |
Here's how it works in practice. When a user mentions "working late," all three databases fire simultaneously β MySQL uses full-text indexing to find memories literally containing "working late"; Milvus finds semantically similar content (even if the original text said "project crunch" or "pulling an all-nighter"); Neo4j follows the knowledge graph from the "working late" entity to related people, events, and projects. The three result sets merge, and a fusion algorithm produces the final ranking β giving the AI a context that's both precise and associative.
Tech Stack
- Backend language: Go. Compared to Python, Go offers more stable performance in high-concurrency, long-running server scenarios. A single instance can support tens of thousands of users with hundreds concurrently active.
- Embedding model: bge-large-zh, outputting 1024-dimensional vectors β strong Chinese semantic understanding.
- LLM: Used for entity extraction, summary generation, and chain-of-thought compression.
3. Memory Tiering: Hot, Warm, Cold, Archive
The human brain doesn't treat all memories equally: recent events are clearest, older ones get fuzzier, and truly ancient ones sink into the subconscious. Our system mimics this with four tiers:
| Tier | Time Range | Characteristics |
|---|---|---|
| Hot | Today | Frequently retrieved, highest priority |
| Warm | 1β30 days | Normal memories, participate in retrieval |
| Cold | 30 days β 1 year | Rarely accessed, lower weight |
| Archive | 1+ years | Mostly dormant, can be "awakened" if needed |
Tiering is handled by a cron job that runs daily. Every night, the system scans all memories and migrates them from hot β warm β cold β archive based on age. This keeps the hot tier small and fast, while the archive β though large β never slows down everyday queries.
This closely mirrors the human "short-term β long-term memory" conversion: recent events sit in working memory, instantly accessible, while distant memories require deeper recollection.
4. Heat Decay: Teaching AI to "Forget"
Tiering by time isn't enough. Two memories from the same warm-tier month might have vastly different importance: one was mentioned once and never again, the other comes up every week. Clearly the latter matters more. To capture this, we designed a segmented heat decay algorithm.
The core idea: every memory has a "heat score" from 0β100, determined by three factors:
- Base heat: Segmented by age. Today = 100, within 7 days = 90, within 30 days = 70, within 90 days = 50, within 1 year = 30, 1+ years = 10.
- Access bonus: +5 per retrieval (max +30).
- Mention bonus: +3 per re-mention (max +20).
func CalculateHeat(createdAt time.Time, accessCount, mentionCount int) float64 {
days := time.Since(createdAt).Hours() / 24
var baseHeat float64
switch {
case days <= 1: baseHeat = 100 // Today
case days <= 7: baseHeat = 90 // Within a week
case days <= 30: baseHeat = 70 // Within a month
case days <= 90: baseHeat = 50
case days <= 365: baseHeat = 30
default: baseHeat = 10 // Over a year
}
accessBonus := math.Min(float64(accessCount)*5, 30)
mentionBonus := math.Min(float64(mentionCount)*3, 20)
return math.Min(baseHeat+accessBonus+mentionBonus, 100)
}
Differential half-life is the key innovation. Different types of memories should decay at different rates: a "life milestone" memory (graduation, wedding) should decay slowly; "what I had for lunch today" should fade fast. We distinguish memory types in the importance scoring (next section) and link decay rate accordingly β important memories decay slowly, trivial ones quickly.
This gives the system an authentic "forgetting" capability. Memories don't just pile up endlessly β the system naturally remembers what matters and lets go of what doesn't, keeping the AI's focus on what's truly meaningful.
5. Multi-Dimensional Importance Scoring: Quantifying "Worth Remembering"
Heat measures "how active lately," but how important a memory is inherently is a separate dimension. We use a multi-dimensional scoring algorithm to quantify this.
When a new memory arrives, the system scores it across multiple dimensions, summing to a 0β100 importance score:
| Dimension | Max Points | Criteria |
|---|---|---|
| Base | 50 | Starting score for every memory |
| Temporal | 0β15 | Contains specific time references (tomorrow, next week, 2026) |
| Emotional | 0β15 | Carries emotional weight (happy, sad, angry) |
| Action | 0β10 | Involves concrete actions (go, do, complete) |
| Numeric | 0β5 | Contains numbers, amounts, quantities |
| Length | 0β5 | Content length (longer tends to be more significant) |
| Entity | 0β10 | Number of entities mentioned (people, places, concepts) |
For example:
- "Nice weather today" β Almost no temporal/emotional/action/numeric/entity signals. Importance ~50β55. "Note it and move on."
- "Next Wednesday, meeting Xiao Wang in Shanghai to sign a 2-million-yuan contract" β Time (next Wednesday), action (meeting, sign), number (2 million), multiple entities (Xiao Wang, Shanghai, contract). Importance 85+. "Must remember."
Importance scoring serves two purposes: at write time, it determines a memory's initial weight; at retrieval time, it factors into final ranking β important memories surface first.
6. Dual-Mode Storage: Raw Text + Summary
Many memory systems compress conversations into summaries before storage. But summaries lose detail β "User's mom is sick" becomes "family health topic," and the emotional weight vanishes.
We use dual-mode storage: keeping both raw content (content) and a generated summary (summary).
- Raw storage: Preserves the complete original text β no detail or emotion lost. Returned preferentially during retrieval.
- Summary storage: The LLM compresses long conversations into concise summaries for quick understanding and vectorization.
This balances completeness with efficiency. During retrieval, summaries quickly identify relevant memories via vectors, then raw text is pulled for the AI β fast, with nothing lost.
7. Comparison with Leading Memory Platforms
We didn't build in a vacuum. Several mature open-source memory platforms exist, and we benchmarked against the most representative:
| Capability | Typical Open-Source Platform | Our System |
|---|---|---|
| Long-term memory storage | β | β |
| Short-term / session memory | β | β |
| Memory tiering (hot/warm/cold) | Most β | β |
| Heat decay algorithm | Almost none β | β |
| Multi-dimensional importance scoring | β | β |
| Vector semantic search | β | β |
| Graph database relationship reasoning | Almost none β | β |
| Three-way recall + fusion ranking | β | β |
| Raw text + summary dual mode | Some β | β |
Our key differentiators:
- Three-way recall + fusion ranking: MySQL + Milvus + Neo4j working in concert, with RRF (Reciprocal Rank Fusion) to weight and merge results from all three β higher retrieval precision.
- Multi-dimensional importance scoring: Not just time or frequency β we quantify a memory's "substance" across seven dimensions.
- Segmented heat decay: Different memory types fade at different rates, closer to human memory patterns.
- Memory lifecycle management: Fully automated migration from hot to archive tier β the system maintains itself.
Honestly, we still trail in ecosystem, standardization, and multi-language SDKs β leading platforms have mature Python/JS SDKs and cloud services, while we're Go-native, private-deployment only. But on memory depth and retrieval precision, the three-database fusion architecture gives us a unique technical edge.
8. The Save Pipeline: Birth of a Memory
With architecture and algorithms understood, let's trace a memory from input to storage. We designed it as an 11-step pipeline:
Raw conversation content
β
Step 0 Establish database connections
Step 1a System message filtering (heartbeats, commands, media markers)
Step 1b Deduplication check (content hash)
Step 2 Chain-of-thought processing (extract & compress reasoning)
Step 3 Error correction rules (user-specific text fixes)
Step 4 Voice input cleanup (dedup, punctuation)
Step 5 Sentence segmentation
Step 6 NLP extraction (entities, tags, memory type, importance)
Step 7 Vector generation (1024-dim)
Step 8 Anchor construction (link entities to tags)
Step 9 Entity dedup & ID assignment
Step 10 Merge LLM extraction results (override local extraction)
Step 11 Three-DB transactional write (MySQL β parallel Milvus + Neo4j)
β
Save complete
Two details deserve elaboration.
Deduplication is an engineering necessity. The host platform's plugin mechanism can trigger save logic repeatedly β without dedup, the database fills with duplicates. We use two layers: an outer time window (preventing rapid re-triggers) and an inner content hash (SHA256(content + userID + turnID)) as a database unique constraint β eliminating duplication at the root.
Three-database transactions are the trickiest part. MySQL, Milvus, and Neo4j are independent systems with no native distributed transactions. Our strategy: write MySQL first to get an auto-increment ID, then write Milvus and Neo4j in parallel. If Milvus fails, roll back MySQL and Neo4j. If only Neo4j fails, degrade gracefully (graph search capability is temporarily lost, but core storage is unaffected). This "best-effort consistency + graceful degradation" approach ensures system robustness.
9. The Retrieval Pipeline: Three-Way Recall + Fusion Ranking
Retrieval is the memory system's "moment of truth." The user says something, and the system must find the most relevant memories from tens of thousands of entries in milliseconds:
User message (e.g., "working late")
β
LLM extracts query keywords & entities
β
Generate 1024-dim query vector
β
Three-way parallel search
ββ MySQL full-text search (exact text match, Top 50)
ββ Milvus vector search (semantic similarity, Top 50)
ββ Neo4j graph search (entity relations, Top 50)
β
RRF fusion ranking (weight by each path's rank)
β
Multi-dimensional weighted score (fusion Γ 0.4 + importance Γ 0.3 + heat Γ 0.2 + freshness Γ 0.1)
β
Return Top K results, injected into LLM context
RRF (Reciprocal Rank Fusion) is an elegant, well-established information retrieval algorithm. Instead of comparing raw scores across paths (which have different scales), it looks only at rank β a memory that ranks high across multiple paths gets a higher fusion score:
fusion_score(id) = Ξ£ 1 / (60 + rank_in_each_path)
The constant 60 is the recommended value from the literature, preventing top-ranked results from dominating.
The final context injected into the LLM isn't a pile of scattered memories β it's a structured brief: relevant entities first, then conversation summaries, then specific raw dialogue, and finally personal memories. This layered structure lets the LLM efficiently "understand the past" rather than drowning in raw data.
10. Scheduled Tasks: Memory That Evolves Itself
A memory system isn't "store once and done." It needs continuous self-maintenance. We designed 7 types of scheduled tasks running nightly during off-peak hours:
| Task | Purpose |
|---|---|
| Heat decay | Recalculate heat scores for all memories |
| Tier migration | Move memories from hot β warm β cold β archive |
| Memory consolidation | Merge highly similar memories, reduce redundancy |
| Catchphrase analysis | Identify user's frequently used expressions |
| Error correction evolution | Learn from user corrections, improve voice recognition |
| Episode organization | Cluster scattered conversations into meaningful "episodes" |
| Trending topic extraction | Discover themes the user cares about recently |
"Memory consolidation" deserves special mention. It's inspired by sleep β the human brainζ΄ηs the day's memories during sleep, merging similar ones and reinforcing important ones. Our system does the same thing every night: finding highly similar memory entries and merging them into a more complete single memory. This saves storage and keeps memories "clean."
11. Conclusion
Memory is the foundation of lasting relationships. A person matters to you largely because you share a wealth of memories. The same is true for AI β only when it can remember the little things you've experienced together does it truly qualify as a companion.
The three-database fusion architecture is, at its core, an acknowledgment that "memory" is inherently complex: it involves structured metadata, semantic similarity, and entity relationship networks. No single storage system can fully capture it. By combining MySQL + Milvus + Neo4j with tiering, decay, importance scoring, and fusion ranking, we've given our AI a memory that's precise, associative, and discerning.
The road ahead is long. Next steps include multi-language SDKs, standardized evaluation benchmarks, and exploring the balance between "collective memory" across users and privacy boundaries. But for now, our Bao'er is no longer the AI that "forgets what you said yesterday" β she remembers you, and she's getting to know you better every day.
This paper is based on the real engineering practice of Hangzhou Shizhi Shikong Technology's Personal Memory Model (Bao'er Memory System 3.0). Certain proprietary algorithm parameters and internal architecture details have been omitted.