{"id":60135,"date":"2025-12-26T09:54:44","date_gmt":"2025-12-26T09:54:44","guid":{"rendered":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/"},"modified":"2025-12-26T09:54:44","modified_gmt":"2025-12-26T09:54:44","slug":"a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms","status":"publish","type":"post","link":"https:\/\/youzum.net\/th\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/","title":{"rendered":"A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms"},"content":{"rendered":"<p>In this tutorial, we dive into the cutting edge of Agentic AI by building a \u201cZettelkasten\u201d memory system, a \u201cliving\u201d architecture that organizes information much like the human brain. We move beyond standard retrieval methods to construct a dynamic knowledge graph where an agent autonomously decomposes inputs into atomic facts, links them semantically, and even \u201csleeps\u201d to consolidate memories into higher-order insights. Using Google\u2019s Gemini, we implement a robust solution that addresses real-world API constraints, ensuring our agent stores data and also actively understands the evolving context of our projects. Check out the\u00a0<strong><a href=\"https:\/\/github.com\/Marktechpost\/AI-Tutorial-Codes-Included\/blob\/main\/Agentic%20AI%20Memory\/Agentic_Zettelkasten_Memory_Martechpost.ipynb\" target=\"_blank\" rel=\"noreferrer noopener\">FULL CODES here<\/a><\/strong>.<\/p>\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\">\n<div class=\"control-language\">\n<div class=\"dm-buttons\">\n<div class=\"dm-buttons-left\">\n<div class=\"dm-button-snippet red-button\"><\/div>\n<div class=\"dm-button-snippet orange-button\"><\/div>\n<div class=\"dm-button-snippet green-button\"><\/div>\n<\/div>\n<div class=\"dm-buttons-right\"><a><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\">Copied<\/span><span class=\"dm-error-message\">Use a different Browser<\/span><\/a><\/div>\n<\/div>\n<pre class=\"no-line-numbers\"><code class=\"no-wrap language-php\">!pip install -q -U google-generativeai networkx pyvis scikit-learn numpy\n\n\nimport os\nimport json\nimport uuid\nimport time\nimport getpass\nimport random\nimport networkx as nx\nimport numpy as np\nimport google.generativeai as genai\nfrom dataclasses import dataclass, field\nfrom typing import List\nfrom sklearn.metrics.pairwise import cosine_similarity\nfrom IPython.display import display, HTML\nfrom pyvis.network import Network\nfrom google.api_core import exceptions\n\n\ndef retry_with_backoff(func, *args, **kwargs):\n   max_retries = 5\n   base_delay = 5\n  \n   for attempt in range(max_retries):\n       try:\n           return func(*args, **kwargs)\n       except exceptions.ResourceExhausted:\n           wait_time = base_delay * (2 ** attempt) + random.uniform(0, 1)\n           print(f\"   <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png\" alt=\"\u23f3\" class=\"wp-smiley\" \/> Quota limit hit. Cooling down for {wait_time:.1f}s...\")\n           time.sleep(wait_time)\n       except Exception as e:\n           if \"429\" in str(e):\n               wait_time = base_delay * (2 ** attempt) + random.uniform(0, 1)\n               print(f\"   <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png\" alt=\"\u23f3\" class=\"wp-smiley\" \/> Quota limit hit (HTTP 429). Cooling down for {wait_time:.1f}s...\")\n               time.sleep(wait_time)\n           else:\n               print(f\"   <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/26a0.png\" alt=\"\u26a0\" class=\"wp-smiley\" \/> Unexpected Error: {e}\")\n               return None\n   print(\"   <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/274c.png\" alt=\"\u274c\" class=\"wp-smiley\" \/> Max retries reached.\")\n   return None\n\n\nprint(\"Enter your Google AI Studio API Key (Input will be hidden):\")\nAPI_KEY = getpass.getpass()\n\n\ngenai.configure(api_key=API_KEY)\nMODEL_NAME = \"gemini-2.5-flash\" \nEMBEDDING_MODEL = \"models\/text-embedding-004\"\n\n\nprint(f\"<img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/2705.png\" alt=\"\u2705\" class=\"wp-smiley\" \/> API Key configured. Using model: {MODEL_NAME}\")<\/code><\/pre>\n<\/div>\n<\/div>\n<p>We begin by importing essential libraries for graph management and AI model interaction, while also securing our API key input. Crucially, we define a robust retry_with_backoff function that automatically handles rate limit errors, ensuring our agent gracefully pauses and recovers when the API quota is exceeded during heavy processing. Check out the\u00a0<strong><a href=\"https:\/\/github.com\/Marktechpost\/AI-Tutorial-Codes-Included\/blob\/main\/Agentic%20AI%20Memory\/Agentic_Zettelkasten_Memory_Martechpost.ipynb\" target=\"_blank\" rel=\"noreferrer noopener\">FULL CODES here<\/a><\/strong>.<\/p>\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\">\n<div class=\"control-language\">\n<div class=\"dm-buttons\">\n<div class=\"dm-buttons-left\">\n<div class=\"dm-button-snippet red-button\"><\/div>\n<div class=\"dm-button-snippet orange-button\"><\/div>\n<div class=\"dm-button-snippet green-button\"><\/div>\n<\/div>\n<div class=\"dm-buttons-right\"><a><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\">Copied<\/span><span class=\"dm-error-message\">Use a different Browser<\/span><\/a><\/div>\n<\/div>\n<pre class=\"no-line-numbers\"><code class=\"no-wrap language-php\">@dataclass\nclass MemoryNode:\n   id: str\n   content: str\n   type: str\n   embedding: List[float] = field(default_factory=list)\n   timestamp: int = 0\n\n\nclass RobustZettelkasten:\n   def __init__(self):\n       self.graph = nx.Graph()\n       self.model = genai.GenerativeModel(MODEL_NAME)\n       self.step_counter = 0\n\n\n   def _get_embedding(self, text):\n       result = retry_with_backoff(\n           genai.embed_content,\n           model=EMBEDDING_MODEL,\n           content=text\n       )\n       return result['embedding'] if result else [0.0] * 768<\/code><\/pre>\n<\/div>\n<\/div>\n<p>We define the fundamental MemoryNode structure to hold our content, types, and vector embeddings in an organized data class. We then initialize the main RobustZettelkasten class, establishing the network graph and configuring the Gemini embedding model that serves as the backbone of our semantic search capabilities. Check out the\u00a0<strong><a href=\"https:\/\/github.com\/Marktechpost\/AI-Tutorial-Codes-Included\/blob\/main\/Agentic%20AI%20Memory\/Agentic_Zettelkasten_Memory_Martechpost.ipynb\" target=\"_blank\" rel=\"noreferrer noopener\">FULL CODES here<\/a><\/strong>.<\/p>\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\">\n<div class=\"control-language\">\n<div class=\"dm-buttons\">\n<div class=\"dm-buttons-left\">\n<div class=\"dm-button-snippet red-button\"><\/div>\n<div class=\"dm-button-snippet orange-button\"><\/div>\n<div class=\"dm-button-snippet green-button\"><\/div>\n<\/div>\n<div class=\"dm-buttons-right\"><a><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\">Copied<\/span><span class=\"dm-error-message\">Use a different Browser<\/span><\/a><\/div>\n<\/div>\n<pre class=\"no-line-numbers\"><code class=\"no-wrap language-php\">def _atomize_input(self, text):\n       prompt = f\"\"\"\n       Break the following text into independent atomic facts.\n       Output JSON: {{ \"facts\": [\"fact1\", \"fact2\"] }}\n       Text: \"{text}\"\n       \"\"\"\n       response = retry_with_backoff(\n           self.model.generate_content,\n           prompt,\n           generation_config={\"response_mime_type\": \"application\/json\"}\n       )\n       try:\n           return json.loads(response.text).get(\"facts\", []) if response else [text]\n       except:\n           return [text]\n\n\n   def _find_similar_nodes(self, embedding, top_k=3, threshold=0.45):\n       if not self.graph.nodes: return []\n      \n       nodes = list(self.graph.nodes(data=True))\n       embeddings = [n[1]['data'].embedding for n in nodes]\n       valid_embeddings = [e for e in embeddings if len(e) &gt; 0]\n      \n       if not valid_embeddings: return []\n\n\n       sims = cosine_similarity([embedding], embeddings)[0]\n       sorted_indices = np.argsort(sims)[::-1]\n      \n       results = []\n       for idx in sorted_indices[:top_k]:\n           if sims[idx] &gt; threshold:\n               results.append((nodes[idx][0], sims[idx]))\n       return results\n\n\n   def add_memory(self, user_input):\n       self.step_counter += 1\n       print(f\"n<img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/1f9e0.png\" alt=\"\ud83e\udde0\" class=\"wp-smiley\" \/> [Step {self.step_counter}] Processing: \"{user_input}\"\")\n      \n       facts = self._atomize_input(user_input)\n      \n       for fact in facts:\n           print(f\"   -&gt; Atom: {fact}\")\n           emb = self._get_embedding(fact)\n           candidates = self._find_similar_nodes(emb)\n          \n           node_id = str(uuid.uuid4())[:6]\n           node = MemoryNode(id=node_id, content=fact, type='fact', embedding=emb, timestamp=self.step_counter)\n           self.graph.add_node(node_id, data=node, title=fact, label=fact[:15]+\"...\")\n          \n           if candidates:\n               context_str = \"n\".join([f\"ID {c[0]}: {self.graph.nodes[c[0]]['data'].content}\" for c in candidates])\n               prompt = f\"\"\"\n               I am adding: \"{fact}\"\n               Existing Memory:\n               {context_str}\n              \n               Are any of these directly related? If yes, provide the relationship label.\n               JSON: {{ \"links\": [{{ \"target_id\": \"ID\", \"rel\": \"label\" }}] }}\n               \"\"\"\n               response = retry_with_backoff(\n                   self.model.generate_content,\n                   prompt,\n                   generation_config={\"response_mime_type\": \"application\/json\"}\n               )\n              \n               if response:\n                   try:\n                       links = json.loads(response.text).get(\"links\", [])\n                       for link in links:\n                           if self.graph.has_node(link['target_id']):\n                               self.graph.add_edge(node_id, link['target_id'], label=link['rel'])\n                               print(f\"      <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/1f517.png\" alt=\"\ud83d\udd17\" class=\"wp-smiley\" \/> Linked to {link['target_id']} ({link['rel']})\")\n                   except:\n                       pass\n          \n           time.sleep(1)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>We construct an ingestion pipeline that decomposes complex user inputs into atomic facts to prevent information loss. We immediately embed these facts and use our agent to identify and create semantic links to existing nodes, effectively building a knowledge graph in real time that mimics associative memory. Check out the\u00a0<strong><a href=\"https:\/\/github.com\/Marktechpost\/AI-Tutorial-Codes-Included\/blob\/main\/Agentic%20AI%20Memory\/Agentic_Zettelkasten_Memory_Martechpost.ipynb\" target=\"_blank\" rel=\"noreferrer noopener\">FULL CODES here<\/a><\/strong>.<\/p>\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\">\n<div class=\"control-language\">\n<div class=\"dm-buttons\">\n<div class=\"dm-buttons-left\">\n<div class=\"dm-button-snippet red-button\"><\/div>\n<div class=\"dm-button-snippet orange-button\"><\/div>\n<div class=\"dm-button-snippet green-button\"><\/div>\n<\/div>\n<div class=\"dm-buttons-right\"><a><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\">Copied<\/span><span class=\"dm-error-message\">Use a different Browser<\/span><\/a><\/div>\n<\/div>\n<pre class=\"no-line-numbers\"><code class=\"no-wrap language-php\">def consolidate_memory(self):\n       print(f\"n<img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/1f4a4.png\" alt=\"\ud83d\udca4\" class=\"wp-smiley\" \/> [Consolidation Phase] Reflecting...\")\n       high_degree_nodes = [n for n, d in self.graph.degree() if d &gt;= 2]\n       processed_clusters = set()\n\n\n       for main_node in high_degree_nodes:\n           neighbors = list(self.graph.neighbors(main_node))\n           cluster_ids = tuple(sorted([main_node] + neighbors))\n          \n           if cluster_ids in processed_clusters: continue\n           processed_clusters.add(cluster_ids)\n          \n           cluster_content = [self.graph.nodes[n]['data'].content for n in cluster_ids]\n          \n           prompt = f\"\"\"\n           Generate a single high-level insight summary from these facts.\n           Facts: {json.dumps(cluster_content)}\n           JSON: {{ \"insight\": \"Your insight here\" }}\n           \"\"\"\n           response = retry_with_backoff(\n               self.model.generate_content,\n               prompt,\n               generation_config={\"response_mime_type\": \"application\/json\"}\n           )\n          \n           if response:\n               try:\n                   insight_text = json.loads(response.text).get(\"insight\")\n                   if insight_text:\n                       insight_id = f\"INSIGHT-{uuid.uuid4().hex[:4]}\"\n                       print(f\"   <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/2728.png\" alt=\"\u2728\" class=\"wp-smiley\" \/> Insight: {insight_text}\")\n                       emb = self._get_embedding(insight_text)\n                      \n                       insight_node = MemoryNode(id=insight_id, content=insight_text, type='insight', embedding=emb)\n                       self.graph.add_node(insight_id, data=insight_node, title=f\"INSIGHT: {insight_text}\", label=\"INSIGHT\", color=\"#ff7f7f\")\n                       self.graph.add_edge(insight_id, main_node, label=\"abstracted_from\")\n               except:\n                   continue\n           time.sleep(1)\n\n\n   def answer_query(self, query):\n       print(f\"n<img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/1f50d.png\" alt=\"\ud83d\udd0d\" class=\"wp-smiley\" \/> Querying: \"{query}\"\")\n       emb = self._get_embedding(query)\n       candidates = self._find_similar_nodes(emb, top_k=2)\n      \n       if not candidates:\n           print(\"No relevant memory found.\")\n           return\n\n\n       relevant_context = set()\n       for node_id, score in candidates:\n           node_content = self.graph.nodes[node_id]['data'].content\n           relevant_context.add(f\"- {node_content} (Direct Match)\")\n           for n1 in self.graph.neighbors(node_id):\n               rel = self.graph[node_id][n1].get('label', 'related')\n               content = self.graph.nodes[n1]['data'].content\n               relevant_context.add(f\"  - linked via '{rel}' to: {content}\")\n              \n       context_text = \"n\".join(relevant_context)\n       prompt = f\"\"\"\n       Answer based ONLY on context.\n       Question: {query}\n       Context:\n       {context_text}\n       \"\"\"\n       response = retry_with_backoff(self.model.generate_content, prompt)\n       if response:\n           print(f\"<img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/1f916.png\" alt=\"\ud83e\udd16\" class=\"wp-smiley\" \/> Agent Answer:n{response.text}\")<\/code><\/pre>\n<\/div>\n<\/div>\n<p>We implement the cognitive functions of our agent, enabling it to \u201csleep\u201d and consolidate dense memory clusters into higher-order insights. We also define the query logic that traverses these connected paths, allowing the agent to reason across multiple hops in the graph to answer complex questions. Check out the\u00a0<strong><a href=\"https:\/\/github.com\/Marktechpost\/AI-Tutorial-Codes-Included\/blob\/main\/Agentic%20AI%20Memory\/Agentic_Zettelkasten_Memory_Martechpost.ipynb\" target=\"_blank\" rel=\"noreferrer noopener\">FULL CODES here<\/a><\/strong>.<\/p>\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\">\n<div class=\"control-language\">\n<div class=\"dm-buttons\">\n<div class=\"dm-buttons-left\">\n<div class=\"dm-button-snippet red-button\"><\/div>\n<div class=\"dm-button-snippet orange-button\"><\/div>\n<div class=\"dm-button-snippet green-button\"><\/div>\n<\/div>\n<div class=\"dm-buttons-right\"><a><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\">Copied<\/span><span class=\"dm-error-message\">Use a different Browser<\/span><\/a><\/div>\n<\/div>\n<pre class=\"no-line-numbers\"><code class=\"no-wrap language-php\">def show_graph(self):\n       try:\n           net = Network(notebook=True, cdn_resources='remote', height=\"500px\", width=\"100%\", bgcolor='#222222', font_color='white')\n           for n, data in self.graph.nodes(data=True):\n               color = \"#97c2fc\" if data['data'].type == 'fact' else \"#ff7f7f\"\n               net.add_node(n, label=data.get('label', ''), title=data['data'].content, color=color)\n           for u, v, data in self.graph.edges(data=True):\n               net.add_edge(u, v, label=data.get('label', ''))\n           net.show(\"memory_graph.html\")\n           display(HTML(\"memory_graph.html\"))\n       except Exception as e:\n           print(f\"Graph visualization error: {e}\")\n\n\nbrain = RobustZettelkasten()\n\n\nevents = [\n   \"The project 'Apollo' aims to build a dashboard for tracking solar panel efficiency.\",\n   \"We chose React for the frontend because the team knows it well.\",\n   \"The backend must be Python to support the data science libraries.\",\n   \"Client called. They are unhappy with React performance on low-end devices.\",\n   \"We are switching the frontend to Svelte for better performance.\"\n]\n\n\nprint(\"--- PHASE 1: INGESTION ---\")\nfor event in events:\n   brain.add_memory(event)\n   time.sleep(2)\n\n\nprint(\"--- PHASE 2: CONSOLIDATION ---\")\nbrain.consolidate_memory()\n\n\nprint(\"--- PHASE 3: RETRIEVAL ---\")\nbrain.answer_query(\"What is the current frontend technology for Apollo and why?\")\n\n\nprint(\"--- PHASE 4: VISUALIZATION ---\")\nbrain.show_graph()<\/code><\/pre>\n<\/div>\n<\/div>\n<p>We wrap up by adding a visualization method that generates an interactive HTML graph of our agent\u2019s memory, allowing us to inspect the nodes and edges. Finally, we execute a test scenario involving a project timeline to verify that our system correctly links concepts, generates insights, and retrieves the right context.<\/p>\n<p>In conclusion, we now have a fully functional \u201cLiving Memory\u201d prototype that transcends simple database storage. By enabling our agent to actively link related concepts and reflect on its experiences during a \u201cconsolidation\u201d phase, we solve the critical problem of fragmented context in long-running AI interactions. This system demonstrates that true intelligence requires processing power and a structured, evolving memory, marking the way for us to build more capable, personalized autonomous agents.<\/p>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n<p>Check out the\u00a0<strong><a href=\"https:\/\/github.com\/Marktechpost\/AI-Tutorial-Codes-Included\/blob\/main\/Agentic%20AI%20Memory\/Agentic_Zettelkasten_Memory_Martechpost.ipynb\" target=\"_blank\" rel=\"noreferrer noopener\">FULL CODES here<\/a><\/strong>.\u00a0Also,\u00a0feel free to follow us on\u00a0<strong><a href=\"https:\/\/x.com\/intent\/follow?screen_name=marktechpost\" target=\"_blank\" rel=\"noreferrer noopener\"><mark>Twitter<\/mark><\/a><\/strong>\u00a0and don\u2019t forget to join our\u00a0<strong><a href=\"https:\/\/www.reddit.com\/r\/machinelearningnews\/\" target=\"_blank\" rel=\"noreferrer noopener\">100k+ ML SubReddit<\/a><\/strong>\u00a0and Subscribe to\u00a0<strong><a href=\"https:\/\/www.aidevsignals.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">our Newsletter<\/a><\/strong>. Wait! are you on telegram?\u00a0<strong><a href=\"https:\/\/t.me\/machinelearningresearchnews\" target=\"_blank\" rel=\"noreferrer noopener\">now you can join us on telegram as well.<\/a><\/strong><\/p>\n<p>The post <a href=\"https:\/\/www.marktechpost.com\/2025\/12\/25\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/\">A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms<\/a> appeared first on <a href=\"https:\/\/www.marktechpost.com\/\">MarkTechPost<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we dive into the cutting edge of Agentic AI by building a \u201cZettelkasten\u201d memory system, a \u201cliving\u201d architecture that organizes information much like the human brain. We move beyond standard retrieval methods to construct a dynamic knowledge graph where an agent autonomously decomposes inputs into atomic facts, links them semantically, and even \u201csleeps\u201d to consolidate memories into higher-order insights. Using Google\u2019s Gemini, we implement a robust solution that addresses real-world API constraints, ensuring our agent stores data and also actively understands the evolving context of our projects. Check out the\u00a0FULL CODES here. Copy CodeCopiedUse a different Browser !pip install -q -U google-generativeai networkx pyvis scikit-learn numpy import os import json import uuid import time import getpass import random import networkx as nx import numpy as np import google.generativeai as genai from dataclasses import dataclass, field from typing import List from sklearn.metrics.pairwise import cosine_similarity from IPython.display import display, HTML from pyvis.network import Network from google.api_core import exceptions def retry_with_backoff(func, *args, **kwargs): max_retries = 5 base_delay = 5 for attempt in range(max_retries): try: return func(*args, **kwargs) except exceptions.ResourceExhausted: wait_time = base_delay * (2 ** attempt) + random.uniform(0, 1) print(f&#8221; Quota limit hit. Cooling down for {wait_time:.1f}s&#8230;&#8221;) time.sleep(wait_time) except Exception as e: if &#8220;429&#8221; in str(e): wait_time = base_delay * (2 ** attempt) + random.uniform(0, 1) print(f&#8221; Quota limit hit (HTTP 429). Cooling down for {wait_time:.1f}s&#8230;&#8221;) time.sleep(wait_time) else: print(f&#8221; Unexpected Error: {e}&#8221;) return None print(&#8221; Max retries reached.&#8221;) return None print(&#8220;Enter your Google AI Studio API Key (Input will be hidden):&#8221;) API_KEY = getpass.getpass() genai.configure(api_key=API_KEY) MODEL_NAME = &#8220;gemini-2.5-flash&#8221; EMBEDDING_MODEL = &#8220;models\/text-embedding-004&#8243; print(f&#8221; API Key configured. Using model: {MODEL_NAME}&#8221;) We begin by importing essential libraries for graph management and AI model interaction, while also securing our API key input. Crucially, we define a robust retry_with_backoff function that automatically handles rate limit errors, ensuring our agent gracefully pauses and recovers when the API quota is exceeded during heavy processing. Check out the\u00a0FULL CODES here. Copy CodeCopiedUse a different Browser @dataclass class MemoryNode: id: str content: str type: str embedding: List[float] = field(default_factory=list) timestamp: int = 0 class RobustZettelkasten: def __init__(self): self.graph = nx.Graph() self.model = genai.GenerativeModel(MODEL_NAME) self.step_counter = 0 def _get_embedding(self, text): result = retry_with_backoff( genai.embed_content, model=EMBEDDING_MODEL, content=text ) return result[&#8217;embedding&#8217;] if result else [0.0] * 768 We define the fundamental MemoryNode structure to hold our content, types, and vector embeddings in an organized data class. We then initialize the main RobustZettelkasten class, establishing the network graph and configuring the Gemini embedding model that serves as the backbone of our semantic search capabilities. Check out the\u00a0FULL CODES here. Copy CodeCopiedUse a different Browser def _atomize_input(self, text): prompt = f&#8221;&#8221;&#8221; Break the following text into independent atomic facts. Output JSON: {{ &#8220;facts&#8221;: [&#8220;fact1&#8221;, &#8220;fact2&#8221;] }} Text: &#8220;{text}&#8221; &#8220;&#8221;&#8221; response = retry_with_backoff( self.model.generate_content, prompt, generation_config={&#8220;response_mime_type&#8221;: &#8220;application\/json&#8221;} ) try: return json.loads(response.text).get(&#8220;facts&#8221;, []) if response else [text] except: return [text] def _find_similar_nodes(self, embedding, top_k=3, threshold=0.45): if not self.graph.nodes: return [] nodes = list(self.graph.nodes(data=True)) embeddings = [n[1][&#8216;data&#8217;].embedding for n in nodes] valid_embeddings = [e for e in embeddings if len(e) &gt; 0] if not valid_embeddings: return [] sims = cosine_similarity([embedding], embeddings)[0] sorted_indices = np.argsort(sims)[::-1] results = [] for idx in sorted_indices[:top_k]: if sims[idx] &gt; threshold: results.append((nodes[idx][0], sims[idx])) return results def add_memory(self, user_input): self.step_counter += 1 print(f&#8221;n [Step {self.step_counter}] Processing: &#8220;{user_input}&#8221;&#8221;) facts = self._atomize_input(user_input) for fact in facts: print(f&#8221; -&gt; Atom: {fact}&#8221;) emb = self._get_embedding(fact) candidates = self._find_similar_nodes(emb) node_id = str(uuid.uuid4())[:6] node = MemoryNode(id=node_id, content=fact, type=&#8217;fact&#8217;, embedding=emb, timestamp=self.step_counter) self.graph.add_node(node_id, data=node, title=fact, label=fact[:15]+&#8221;&#8230;&#8221;) if candidates: context_str = &#8220;n&#8221;.join([f&#8221;ID {c[0]}: {self.graph.nodes[c[0]][&#8216;data&#8217;].content}&#8221; for c in candidates]) prompt = f&#8221;&#8221;&#8221; I am adding: &#8220;{fact}&#8221; Existing Memory: {context_str} Are any of these directly related? If yes, provide the relationship label. JSON: {{ &#8220;links&#8221;: [{{ &#8220;target_id&#8221;: &#8220;ID&#8221;, &#8220;rel&#8221;: &#8220;label&#8221; }}] }} &#8220;&#8221;&#8221; response = retry_with_backoff( self.model.generate_content, prompt, generation_config={&#8220;response_mime_type&#8221;: &#8220;application\/json&#8221;} ) if response: try: links = json.loads(response.text).get(&#8220;links&#8221;, []) for link in links: if self.graph.has_node(link[&#8216;target_id&#8217;]): self.graph.add_edge(node_id, link[&#8216;target_id&#8217;], label=link[&#8216;rel&#8217;]) print(f&#8221; Linked to {link[&#8216;target_id&#8217;]} ({link[&#8216;rel&#8217;]})&#8221;) except: pass time.sleep(1) We construct an ingestion pipeline that decomposes complex user inputs into atomic facts to prevent information loss. We immediately embed these facts and use our agent to identify and create semantic links to existing nodes, effectively building a knowledge graph in real time that mimics associative memory. Check out the\u00a0FULL CODES here. Copy CodeCopiedUse a different Browser def consolidate_memory(self): print(f&#8221;n [Consolidation Phase] Reflecting&#8230;&#8221;) high_degree_nodes = [n for n, d in self.graph.degree() if d &gt;= 2] processed_clusters = set() for main_node in high_degree_nodes: neighbors = list(self.graph.neighbors(main_node)) cluster_ids = tuple(sorted([main_node] + neighbors)) if cluster_ids in processed_clusters: continue processed_clusters.add(cluster_ids) cluster_content = [self.graph.nodes[n][&#8216;data&#8217;].content for n in cluster_ids] prompt = f&#8221;&#8221;&#8221; Generate a single high-level insight summary from these facts. Facts: {json.dumps(cluster_content)} JSON: {{ &#8220;insight&#8221;: &#8220;Your insight here&#8221; }} &#8220;&#8221;&#8221; response = retry_with_backoff( self.model.generate_content, prompt, generation_config={&#8220;response_mime_type&#8221;: &#8220;application\/json&#8221;} ) if response: try: insight_text = json.loads(response.text).get(&#8220;insight&#8221;) if insight_text: insight_id = f&#8221;INSIGHT-{uuid.uuid4().hex[:4]}&#8221; print(f&#8221; Insight: {insight_text}&#8221;) emb = self._get_embedding(insight_text) insight_node = MemoryNode(id=insight_id, content=insight_text, type=&#8217;insight&#8217;, embedding=emb) self.graph.add_node(insight_id, data=insight_node, title=f&#8221;INSIGHT: {insight_text}&#8221;, label=&#8221;INSIGHT&#8221;, color=&#8221;#ff7f7f&#8221;) self.graph.add_edge(insight_id, main_node, label=&#8221;abstracted_from&#8221;) except: continue time.sleep(1) def answer_query(self, query): print(f&#8221;n Querying: &#8220;{query}&#8221;&#8221;) emb = self._get_embedding(query) candidates = self._find_similar_nodes(emb, top_k=2) if not candidates: print(&#8220;No relevant memory found.&#8221;) return relevant_context = set() for node_id, score in candidates: node_content = self.graph.nodes[node_id][&#8216;data&#8217;].content relevant_context.add(f&#8221;- {node_content} (Direct Match)&#8221;) for n1 in self.graph.neighbors(node_id): rel = self.graph[node_id][n1].get(&#8216;label&#8217;, &#8216;related&#8217;) content = self.graph.nodes[n1][&#8216;data&#8217;].content relevant_context.add(f&#8221; &#8211; linked via &#8216;{rel}&#8217; to: {content}&#8221;) context_text = &#8220;n&#8221;.join(relevant_context) prompt = f&#8221;&#8221;&#8221; Answer based ONLY on context. Question: {query} Context: {context_text} &#8220;&#8221;&#8221; response = retry_with_backoff(self.model.generate_content, prompt) if response: print(f&#8221; Agent Answer:n{response.text}&#8221;) We implement the cognitive functions of our agent, enabling it to \u201csleep\u201d and consolidate dense memory clusters into higher-order insights. We also define the query logic that traverses these connected paths, allowing the agent to reason across multiple hops in the graph to answer complex questions. Check out the\u00a0FULL CODES here. Copy CodeCopiedUse a different Browser def show_graph(self): try: net = Network(notebook=True, cdn_resources=&#8217;remote&#8217;, height=&#8221;500px&#8221;, width=&#8221;100%&#8221;, bgcolor=&#8217;#222222&#8242;, font_color=&#8217;white&#8217;) for n, data in self.graph.nodes(data=True): color = &#8220;#97c2fc&#8221; if data[&#8216;data&#8217;].type == &#8216;fact&#8217; else &#8220;#ff7f7f&#8221; net.add_node(n, label=data.get(&#8216;label&#8217;, &#8221;), title=data[&#8216;data&#8217;].content, color=color) for u, v, data in self.graph.edges(data=True): net.add_edge(u, v, label=data.get(&#8216;label&#8217;, &#8221;)) net.show(&#8220;memory_graph.html&#8221;) display(HTML(&#8220;memory_graph.html&#8221;)) except Exception as e:<\/p>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"pmpro_default_level":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_pvb_checkbox_block_on_post":false,"footnotes":""},"categories":[52,5,7,1],"tags":[],"class_list":["post-60135","post","type-post","status-publish","format-standard","hentry","category-ai-club","category-committee","category-news","category-uncategorized","pmpro-has-access"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms - YouZum<\/title>\n<meta name=\"description\" content=\"\u0e01\u0e34\u0e08\u0e01\u0e23\u0e23\u0e21\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a\u0e42\u0e14\u0e23\u0e19\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/youzum.net\/th\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/\" \/>\n<meta property=\"og:locale\" content=\"th_TH\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms - YouZum\" \/>\n<meta property=\"og:description\" content=\"\u0e01\u0e34\u0e08\u0e01\u0e23\u0e23\u0e21\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a\u0e42\u0e14\u0e23\u0e19\" \/>\n<meta property=\"og:url\" content=\"https:\/\/youzum.net\/th\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/\" \/>\n<meta property=\"og:site_name\" content=\"YouZum\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DroneAssociationTH\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-12-26T09:54:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png\" \/>\n<meta name=\"author\" content=\"admin NU\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin NU\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u0e19\u0e32\u0e17\u0e35\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/\"},\"author\":{\"name\":\"admin NU\",\"@id\":\"https:\/\/yousum.gpucore.co\/#\/schema\/person\/97fa48242daf3908e4d9a5f26f4a059c\"},\"headline\":\"A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms\",\"datePublished\":\"2025-12-26T09:54:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/\"},\"wordCount\":543,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/yousum.gpucore.co\/#organization\"},\"image\":{\"@id\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png\",\"articleSection\":[\"AI\",\"Committee\",\"News\",\"Uncategorized\"],\"inLanguage\":\"th\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/\",\"url\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/\",\"name\":\"A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms - YouZum\",\"isPartOf\":{\"@id\":\"https:\/\/yousum.gpucore.co\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png\",\"datePublished\":\"2025-12-26T09:54:44+00:00\",\"description\":\"\u0e01\u0e34\u0e08\u0e01\u0e23\u0e23\u0e21\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a\u0e42\u0e14\u0e23\u0e19\",\"breadcrumb\":{\"@id\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#breadcrumb\"},\"inLanguage\":\"th\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"th\",\"@id\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#primaryimage\",\"url\":\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png\",\"contentUrl\":\"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/youzum.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/yousum.gpucore.co\/#website\",\"url\":\"https:\/\/yousum.gpucore.co\/\",\"name\":\"YouSum\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/yousum.gpucore.co\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/yousum.gpucore.co\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"th\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/yousum.gpucore.co\/#organization\",\"name\":\"Drone Association Thailand\",\"url\":\"https:\/\/yousum.gpucore.co\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"th\",\"@id\":\"https:\/\/yousum.gpucore.co\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/youzum.net\/wp-content\/uploads\/2024\/11\/tranparent-logo.png\",\"contentUrl\":\"https:\/\/youzum.net\/wp-content\/uploads\/2024\/11\/tranparent-logo.png\",\"width\":300,\"height\":300,\"caption\":\"Drone Association Thailand\"},\"image\":{\"@id\":\"https:\/\/yousum.gpucore.co\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/DroneAssociationTH\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/yousum.gpucore.co\/#\/schema\/person\/97fa48242daf3908e4d9a5f26f4a059c\",\"name\":\"admin NU\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"th\",\"@id\":\"https:\/\/yousum.gpucore.co\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/youzum.net\/wp-content\/uploads\/avatars\/2\/1746849356-bpfull.png\",\"contentUrl\":\"https:\/\/youzum.net\/wp-content\/uploads\/avatars\/2\/1746849356-bpfull.png\",\"caption\":\"admin NU\"},\"url\":\"https:\/\/youzum.net\/th\/members\/adminnu\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms - YouZum","description":"\u0e01\u0e34\u0e08\u0e01\u0e23\u0e23\u0e21\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a\u0e42\u0e14\u0e23\u0e19","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/youzum.net\/th\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/","og_locale":"th_TH","og_type":"article","og_title":"A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms - YouZum","og_description":"\u0e01\u0e34\u0e08\u0e01\u0e23\u0e23\u0e21\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a\u0e42\u0e14\u0e23\u0e19","og_url":"https:\/\/youzum.net\/th\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/","og_site_name":"YouZum","article_publisher":"https:\/\/www.facebook.com\/DroneAssociationTH\/","article_published_time":"2025-12-26T09:54:44+00:00","og_image":[{"url":"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png","type":"","width":"","height":""}],"author":"admin NU","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin NU","Est. reading time":"8 \u0e19\u0e32\u0e17\u0e35"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#article","isPartOf":{"@id":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/"},"author":{"name":"admin NU","@id":"https:\/\/yousum.gpucore.co\/#\/schema\/person\/97fa48242daf3908e4d9a5f26f4a059c"},"headline":"A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms","datePublished":"2025-12-26T09:54:44+00:00","mainEntityOfPage":{"@id":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/"},"wordCount":543,"commentCount":0,"publisher":{"@id":"https:\/\/yousum.gpucore.co\/#organization"},"image":{"@id":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#primaryimage"},"thumbnailUrl":"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png","articleSection":["AI","Committee","News","Uncategorized"],"inLanguage":"th","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/","url":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/","name":"A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms - YouZum","isPartOf":{"@id":"https:\/\/yousum.gpucore.co\/#website"},"primaryImageOfPage":{"@id":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#primaryimage"},"image":{"@id":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#primaryimage"},"thumbnailUrl":"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png","datePublished":"2025-12-26T09:54:44+00:00","description":"\u0e01\u0e34\u0e08\u0e01\u0e23\u0e23\u0e21\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a\u0e42\u0e14\u0e23\u0e19","breadcrumb":{"@id":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#breadcrumb"},"inLanguage":"th","potentialAction":[{"@type":"ReadAction","target":["https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/"]}]},{"@type":"ImageObject","inLanguage":"th","@id":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#primaryimage","url":"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png","contentUrl":"https:\/\/s.w.org\/images\/core\/emoji\/16.0.1\/72x72\/23f3.png"},{"@type":"BreadcrumbList","@id":"https:\/\/youzum.net\/a-coding-implementation-on-building-self-organizing-zettelkasten-knowledge-graphs-and-sleep-consolidation-mechanisms\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/youzum.net\/"},{"@type":"ListItem","position":2,"name":"A Coding Implementation on Building Self-Organizing Zettelkasten Knowledge Graphs and Sleep-Consolidation Mechanisms"}]},{"@type":"WebSite","@id":"https:\/\/yousum.gpucore.co\/#website","url":"https:\/\/yousum.gpucore.co\/","name":"YouSum","description":"","publisher":{"@id":"https:\/\/yousum.gpucore.co\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/yousum.gpucore.co\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"th"},{"@type":"Organization","@id":"https:\/\/yousum.gpucore.co\/#organization","name":"Drone Association Thailand","url":"https:\/\/yousum.gpucore.co\/","logo":{"@type":"ImageObject","inLanguage":"th","@id":"https:\/\/yousum.gpucore.co\/#\/schema\/logo\/image\/","url":"https:\/\/youzum.net\/wp-content\/uploads\/2024\/11\/tranparent-logo.png","contentUrl":"https:\/\/youzum.net\/wp-content\/uploads\/2024\/11\/tranparent-logo.png","width":300,"height":300,"caption":"Drone Association Thailand"},"image":{"@id":"https:\/\/yousum.gpucore.co\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DroneAssociationTH\/"]},{"@type":"Person","@id":"https:\/\/yousum.gpucore.co\/#\/schema\/person\/97fa48242daf3908e4d9a5f26f4a059c","name":"admin NU","image":{"@type":"ImageObject","inLanguage":"th","@id":"https:\/\/yousum.gpucore.co\/#\/schema\/person\/image\/","url":"https:\/\/youzum.net\/wp-content\/uploads\/avatars\/2\/1746849356-bpfull.png","contentUrl":"https:\/\/youzum.net\/wp-content\/uploads\/avatars\/2\/1746849356-bpfull.png","caption":"admin NU"},"url":"https:\/\/youzum.net\/th\/members\/adminnu\/"}]}},"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"admin NU","author_link":"https:\/\/youzum.net\/th\/members\/adminnu\/"},"rttpg_comment":0,"rttpg_category":"<a href=\"https:\/\/youzum.net\/th\/category\/ai-club\/\" rel=\"category tag\">AI<\/a> <a href=\"https:\/\/youzum.net\/th\/category\/committee\/\" rel=\"category tag\">Committee<\/a> <a href=\"https:\/\/youzum.net\/th\/category\/news\/\" rel=\"category tag\">News<\/a> <a href=\"https:\/\/youzum.net\/th\/category\/uncategorized\/\" rel=\"category tag\">Uncategorized<\/a>","rttpg_excerpt":"In this tutorial, we dive into the cutting edge of Agentic AI by building a \u201cZettelkasten\u201d memory system, a \u201cliving\u201d architecture that organizes information much like the human brain. We move beyond standard retrieval methods to construct a dynamic knowledge graph where an agent autonomously decomposes inputs into atomic facts, links them semantically, and even&hellip;","_links":{"self":[{"href":"https:\/\/youzum.net\/th\/wp-json\/wp\/v2\/posts\/60135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/youzum.net\/th\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/youzum.net\/th\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/youzum.net\/th\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/youzum.net\/th\/wp-json\/wp\/v2\/comments?post=60135"}],"version-history":[{"count":0,"href":"https:\/\/youzum.net\/th\/wp-json\/wp\/v2\/posts\/60135\/revisions"}],"wp:attachment":[{"href":"https:\/\/youzum.net\/th\/wp-json\/wp\/v2\/media?parent=60135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/youzum.net\/th\/wp-json\/wp\/v2\/categories?post=60135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/youzum.net\/th\/wp-json\/wp\/v2\/tags?post=60135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}