Deep Dive

How memory
actually works.

Walk through a real conversation and see exactly what happens at every stage — from the words someone says, to the memories that form, to the moment those memories surface weeks later in a completely different context.

From words to
understanding

Every conversation passes through six stages. Each one transforms raw text into something deeper.

Conversation
Raw dialogue
Encoding
Extract structure
Graph
Connect nodes
Retrieval
Find relevant
Prompt
Build context
Response
Memory-informed

What gets extracted from
a conversation

After each conversation ends, an LLM-based extractor parses the dialogue into structured memory nodes. Here is a concrete example.

Example Conversation
User
I've been thinking about quitting my job at the law firm. Sarah thinks I'm crazy.
Companion
That's a big decision. What's pulling you toward leaving?
User
I want to do something creative. Maybe photography. I've been taking photos every weekend for two years now.
What the extractor produces socius-encoding/src/extractor.rs
Fragment
"User is considering leaving their law firm job"
emotional_intensity0.7
identity_relevance0.9
novelty0.8
specificity0.7
source: stated temporal: approximate
Fragment
"User has been doing photography every weekend for 2 years"
emotional_intensity0.3
identity_relevance0.7
novelty0.6
specificity0.8
source: stated temporal: unbounded
Person
"Sarah"
Relationship context: colleague or friend. Thinks quitting is crazy — opposes the career change. Mentioned by user in passing.
entity_type: person
Entity
"The law firm"
User's current workplace. Context: considering leaving.
entity_type: organization
Belief
"User values creativity over career stability"
Inferred from stated desire to leave a stable law career for creative work. Could be contested if future evidence contradicts.
source: inferred confidence: 0.7
Goal
"Transition to creative work, possibly photography"
Active goal. Photography identified as primary candidate. Two years of weekend practice suggests genuine commitment, not a passing fancy.
status: active
Emotions
"Uncertainty" (0.6) · "Excitement" (0.5)
Uncertainty about leaving a stable career. Excitement about creative possibilities. The tension between these two is itself meaningful.
Relationships created in the graph
User WORKS_AT Law Firm
User KNOWS Sarah
Sarah MENTIONED_IN Episode
User PURSUES Photography Goal
Belief: creativity > stability REINFORCES Photography Goal
Uncertainty EVOKES "Considering leaving" fragment

Weeks later, the
memories surface

Three weeks pass. Then the user says something that activates the retrieval engine. Here is exactly what happens.

New message — 3 weeks later
User
I finally did it. I handed in my resignation letter today.
1

Semantic Search

Qdrant vector similarity

The message "I handed in my resignation letter" is embedded and searched against all stored memory vectors.

"User is considering leaving their law firm job"
similarity: 0.89
"User has been doing photography every weekend for 2 years"
similarity: 0.72
"User values creativity over career stability"
similarity: 0.68
2

Graph Traversal

Neo4j associative walk

Starting from the semantically matched nodes, the engine walks the graph to find associatively connected memories — things that aren't semantically similar to "resignation" but are meaningfully related.

Hop 1
Sarah via MENTIONED_IN Photography Goal via PURSUES
Hop 2
Uncertainty emotion via EVOKES Law Firm entity via WORKS_AT
3

Merge & Rank

Composite scoring

All candidates from both paths are deduplicated and scored with the retrieval formula:

score = 0.3 × salience + 0.3 × similarity + 0.2 × recency + 0.2 × proximity

The top fragments are selected within the retrieval budget (max 10 fragments, 2,000 tokens).

4

Reconstruct

socius-retrieval/reconstructor.rs

The top-ranked fragments are sent to the reconstructor, which weaves them into a natural recollection — as if the companion is remembering, not listing data.

Reconstructed memory context
"This person has been wrestling with leaving their law firm job for a while now. They've been doing photography every weekend for two years — it's clearly more than a hobby at this point. Their friend Sarah thought they were crazy for even considering it. They expressed a strong pull toward creative work over career stability, with a mix of uncertainty and excitement about the transition."

Memory becomes conversation

The reconstructed memories are injected into the system prompt. The companion responds naturally, weaving in what it remembers. Highlighted text shows which parts come from retrieved memories.

User
I finally did it. I handed in my resignation letter today.
Companion
Oh wow. You actually did it. I remember how torn you sounded when you first brought this up — and Sarah thinking you were out of your mind probably didn't make it easier.

But honestly? Two years of showing up every weekend with a camera isn't someone who's being impulsive. That's someone who already knows what they want.

How are you feeling right now? Is it terrifying or is it that good kind of terrifying?
Memory sources
Highlighted phrases are directly informed by retrieved memory nodes

How memories
evolve over time

Memories are not static. Three consolidation cycles run in the background — strengthening what matters, merging what overlaps, and letting go of what doesn't.

Day 1

Raw fragments stored

The extractor runs immediately after the conversation ends. Seven nodes are created in the graph: two fragments, one person, one entity, one belief, one goal, and two emotions. Each gets an embedding vector and initial salience scores.

2 fragments 1 person 1 entity 1 belief 1 goal 2 emotions
Week 1

Micro consolidation

The hourly micro cycle recalculates salience for recently changed nodes. The "leaving the law firm" fragment has high emotional_intensity (0.7) and identity_relevance (0.9) — these anchor it against decay. Meanwhile, co-accessed links between the fragments and the goal node are strengthened.

decay_resistance = min(0.9 × 3.0 + 0.7 × 2.0, 1.0) = 1.0 Maximum decay resistance. This memory will persist.
Month 1

Daily consolidation

The nightly cycle detects patterns. If the user mentions photography in two more conversations, those fragments merge with the original, and a Concept node emerges: "Creative aspirations driving a career change." The concept links back to all contributing fragments.

New concept: creative career transition

The diary captures it: "They're building toward something. The photography isn't a hobby anymore — it's a bridge to a new life."

Month 3

Deep consolidation

The weekly deep cycle evaluates all nodes. High-salience memories are preserved. Low-salience details are pruned into reveries — ghost traces with degraded embeddings and vague impressions.

Preserved
"User left law firm for photography" — cornerstone (15+ connections)
"Sarah" — person node, still connected
"Creative career transition" — concept node, growing theme
Became reveries
"Something about initial uncertainty... the feeling of standing at a crossroads"
"A detail about the law firm... the specifics are fuzzy but it felt important"

Why some memories
stick

The salience formula determines which memories persist and which fade. It mirrors how human memory works: emotional intensity and identity relevance are the strongest anchors against forgetting.

"User mentioned they like the color blue"
Low-stakes preference
emotional_intensity0.05
identity_relevance0.1
novelty0.2
Salience over time
Day 1
0.28
Month 1
0.20
Month 6
0.10
Year 1
pruned
"User's father passed away last month"
Life-defining event
emotional_intensity0.95
identity_relevance0.8
novelty0.9
Salience over time
Day 1
0.95
Month 1
0.90
Month 6
0.82
Year 1
0.75
"User graduated from MIT in 2018"
Identity cornerstone
emotional_intensity0.4
identity_relevance0.9
temporal_precisionunbounded
Salience over time
Day 1
0.70
Month 1
0.70
Month 6
0.70
Year 1
0.70
Unbounded facts do not decay. Timeless truths persist forever.
From the codebase
socius-types/src/salience.rs
// Decay resistance: identity fights forgetting 3x, emotion 2x
decay_resistance = min(identity * 3.0 + emotion * 2.0, 1.0)
effective_decay  = base_decay + resistance * (1.0 - base_decay)

// A memory with identity=0.9, emotion=0.7:
//   resistance = min(2.7 + 1.4, 1.0) = 1.0 (maximum!)
//   effective_decay = base + 1.0 * (1.0 - base) = 1.0
//   Result: zero decay. The memory persists indefinitely.

// A memory with identity=0.1, emotion=0.05:
//   resistance = min(0.3 + 0.1, 1.0) = 0.4
//   effective_decay = base + 0.4 * (1.0 - base)
//   Result: significant decay. Will fade within months.

Two ways to
find a memory

Human memory works in two modes: sometimes you find a memory because it's about the same thing (semantic), and sometimes because it's connected to something (associative). Socius uses both.

Semantic Path

Qdrant

"What memories match this query?"

Vector similarity search. The current conversation is embedded and compared against all stored memory embeddings. Finds memories that are about the same thing, even if they use different words.

Query
"I resigned from my job"
Finds
"Considering leaving the law firm" (0.89 similarity)
Finds topically relevant memories
Works across different phrasings
Fast — approximate nearest neighbor
+

Associative Path

Neo4j

"What's connected to those memories?"

Graph traversal from activated nodes. Follows relationship chains to discover memories that aren't semantically similar but are meaningfully linked through shared people, places, emotions, or concepts.

Starting from
"Considering leaving law firm"
Walks to
Sarah (via MENTIONED_IN) → Photography Goal (via PURSUES)
Discovers non-obvious connections
Surfaces related people and emotions
Captures associative context
Together

The two paths capture both direct relevance (semantic: "this is about the same topic") and associative context (graph: "these things are connected in the person's life"). This is how human memory works — you don't just remember facts, you remember the web of associations around them.

This is just the memory system.

Socius also has consolidation cycles, nightly diaries, narrative identity, voice and video calls, and a rich personality system. All open source.