<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alexander Bering</title>
    <description>The latest articles on DEV Community by Alexander Bering (@alexanderbering).</description>
    <link>https://dev.to/alexanderbering</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4036370%2F16071376-c036-47c0-a1df-08cf5bcba5f0.png</url>
      <title>DEV Community: Alexander Bering</title>
      <link>https://dev.to/alexanderbering</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexanderbering"/>
    <language>en</language>
    <item>
      <title>7-Layer Memory Architecture: How ZenBrain Remembers Like a Human Brain</title>
      <dc:creator>Alexander Bering</dc:creator>
      <pubDate>Sun, 19 Jul 2026 10:32:12 +0000</pubDate>
      <link>https://dev.to/alexanderbering/7-layer-memory-architecture-how-zenbrain-remembers-like-a-human-brain-jb1</link>
      <guid>https://dev.to/alexanderbering/7-layer-memory-architecture-how-zenbrain-remembers-like-a-human-brain-jb1</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published on the &lt;a href="https://zensation.ai/en/blog/7-layer-memory" rel="noopener noreferrer"&gt;ZenSation Research blog&lt;/a&gt;. ZenBrain is open source (Apache-2.0).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why Conventional AI Memory Falls Short
&lt;/h2&gt;

&lt;p&gt;Most AI systems treat memory as a flat vector store. Embed text, store vectors, retrieve by cosine similarity. It works — but it has fundamental limitations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No temporal decay&lt;/strong&gt; — A fact from 3 years ago has the same weight as yesterday's insight&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No consolidation&lt;/strong&gt; — Memories are never strengthened or reorganized&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No active forgetting&lt;/strong&gt; — Everything is stored forever, creating noise&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No relational context&lt;/strong&gt; — Facts exist in isolation, no connections between them&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The human brain solves all of these. It actively forgets irrelevant information, strengthens important memories during sleep, and builds dense networks of associations. We wanted our AI to do the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 7 Layers
&lt;/h2&gt;

&lt;p&gt;ZenBrain's HiMeS (Hierarchical Memory System) architecture implements seven layers, each serving a distinct cognitive function:&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 1: Working Memory
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt; Active task focus — your mental scratchpad.&lt;/p&gt;

&lt;p&gt;Working memory holds the current context. It's small (like human working memory, approximately 7 items), fast, and constantly refreshed. When you switch tasks, working memory clears and reloads.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 2: Short-Term Memory
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt; Session context — what you remember from this conversation.&lt;/p&gt;

&lt;p&gt;Short-term memory persists across a single session. It tracks the flow of conversation, maintains context, and provides continuity. It decays naturally when the session ends.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 3: Episodic Memory
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt; Concrete experiences — "Last Tuesday, when we discussed the API redesign..."&lt;/p&gt;

&lt;p&gt;Episodic memories are timestamped, contextual records of specific interactions. They capture not just &lt;em&gt;what&lt;/em&gt; was said, but &lt;em&gt;when&lt;/em&gt;, &lt;em&gt;where&lt;/em&gt; (which context), and &lt;em&gt;what emotional valence&lt;/em&gt; the interaction had. Most systems don't distinguish between facts and experiences — we do.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 4: Semantic Memory
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt; Facts and concepts — "PostgreSQL supports pgvector for embeddings."&lt;/p&gt;

&lt;p&gt;Semantic memory stores factual knowledge stripped of temporal context. These memories are built up from repeated episodic experiences — just like in the human brain, where individual episodes gradually crystallize into general knowledge.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 5: Procedural Memory
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt; How-to knowledge — processes and workflows.&lt;/p&gt;

&lt;p&gt;Procedural memory captures &lt;em&gt;how to do things&lt;/em&gt;. "When the user asks for a code review, first check the diff, then analyze patterns, then provide feedback." These are learned from successful interactions and refined through feedback.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 6: Prospective Memory
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt; Future planning — "Remember to follow up on Monday."&lt;/p&gt;

&lt;p&gt;Prospective memory handles intentions and planned actions. It enables the AI to proactively remind you about things, track deadlines, and maintain awareness of future commitments.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 7: Long-Term Memory
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt; Persistent knowledge — your life experience.&lt;/p&gt;

&lt;p&gt;Long-term memory is the permanent store. Facts that have been consolidated, reinforced through repetition, and proven important over time live here. This layer uses Ebbinghaus-style decay curves — memories that aren't accessed gradually fade, but each retrieval strengthens them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sleep Consolidation: The Secret Weapon
&lt;/h2&gt;

&lt;p&gt;In neuroscience, sleep consolidation is the process where the brain replays recent experiences during rest periods, strengthening important memories and pruning weak connections. Stickgold &amp;amp; Walker (2013) showed that memory consolidation during sleep is critical for learning.&lt;/p&gt;

&lt;p&gt;We implemented the same mechanism. During idle periods, ZenBrain:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Selects&lt;/strong&gt; memories with high importance scores that haven't been consolidated yet&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replays&lt;/strong&gt; them — re-evaluates their importance in the context of everything else the system knows&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strengthens&lt;/strong&gt; connections between related memories using Hebbian learning ("neurons that fire together wire together")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prunes&lt;/strong&gt; weak connections — memories that haven't been accessed and have low importance scores decay and eventually get forgotten&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sleep-time consolidation is still rare in AI memory: most systems treat memory as append-only storage and never reorganize it. Modelling the &lt;em&gt;lifecycle&lt;/em&gt; — not just storage and retrieval — is where ZenBrain is different.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spaced Repetition with FSRS
&lt;/h2&gt;

&lt;p&gt;For knowledge that needs long-term retention, we use the FSRS (Free Spaced Repetition Scheduler) algorithm. Originally designed for flashcard apps like Anki, FSRS calculates optimal review intervals based on stability, difficulty, and elapsed time.&lt;/p&gt;

&lt;p&gt;Each memory gets a retrievability score (0-1) predicting the probability of successful recall. When retrievability drops below a threshold, the memory gets flagged for review.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hebbian Knowledge Graphs
&lt;/h2&gt;

&lt;p&gt;Memories don't exist in isolation. The brain builds dense networks of associations. We do the same:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Co-activation:&lt;/strong&gt; When two memories are accessed together, the connection strengthens&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decay:&lt;/strong&gt; Connections that aren't reinforced gradually weaken&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Normalization:&lt;/strong&gt; Connection weights are normalized to prevent runaway activation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The system naturally builds topic clusters, recognizes related concepts, and traverses knowledge paths that the user never explicitly defined.&lt;/p&gt;

&lt;h2&gt;
  
  
  Under the Hood
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;276 tests&lt;/strong&gt; for the memory algorithms alone (all passing)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;9 foundational algorithms&lt;/strong&gt; in &lt;code&gt;@zensation/algorithms&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;7 memory layers&lt;/strong&gt; in &lt;code&gt;@zensation/core&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero dependencies&lt;/strong&gt; — pure TypeScript&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;95% confidence intervals&lt;/strong&gt; for all probabilistic outputs&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;The entire system is open source:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @zensation/algorithms @zensation/core
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/zensation-ai/zenbrain" rel="noopener noreferrer"&gt;github.com/zensation-ai/zenbrain&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Questions or feedback? Drop them in the comments — happy to go deeper on any single layer, the FSRS math, or the sleep-consolidation loop.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>opensource</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
