Release 4.5.0: Added demo script, fixed HDV JSON bugs, applied HF YAML tags
Browse files- README.md +19 -0
- demo_wow.py +66 -0
- src/mnemocore/core/holographic.py +2 -2
- upload_hf.py +34 -0
README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# MnemoCore
|
| 2 |
|
| 3 |
### Infrastructure for Persistent Cognitive Memory
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: MnemoCore
|
| 3 |
+
emoji: 🧠
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
language:
|
| 10 |
+
- en
|
| 11 |
+
tags:
|
| 12 |
+
- memory
|
| 13 |
+
- vector-database
|
| 14 |
+
- cognitive-architecture
|
| 15 |
+
- agents
|
| 16 |
+
- hyperdimensional-computing
|
| 17 |
+
- vsa
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
# MnemoCore
|
| 21 |
|
| 22 |
### Infrastructure for Persistent Cognitive Memory
|
demo_wow.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
MnemoCore 60-Second "Wow" Demo
|
| 3 |
+
Showcasing Persistent Cognitive Memory, Analogy Reasoning, and Decay.
|
| 4 |
+
Run this directly: `python demo_wow.py`
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import asyncio
|
| 8 |
+
import tempfile
|
| 9 |
+
import os
|
| 10 |
+
from mnemocore.core.engine import HAIMEngine
|
| 11 |
+
|
| 12 |
+
async def main():
|
| 13 |
+
print("[1] Booting MnemoCore HAIM Engine...")
|
| 14 |
+
|
| 15 |
+
# We use a temporary directory for this quick demo so we don't leave files behind.
|
| 16 |
+
temp_dir = tempfile.mkdtemp()
|
| 17 |
+
demo_db_path = os.path.join(temp_dir, "demo_memory.jsonl")
|
| 18 |
+
|
| 19 |
+
engine = HAIMEngine(persist_path=demo_db_path)
|
| 20 |
+
|
| 21 |
+
# Temporarily override the conceptual memory storage to avoid corrupting the real ConceptualMemory
|
| 22 |
+
from mnemocore.core.holographic import ConceptualMemory
|
| 23 |
+
engine.soul = ConceptualMemory(dimension=engine.dimension, storage_dir=temp_dir)
|
| 24 |
+
|
| 25 |
+
await engine.initialize()
|
| 26 |
+
|
| 27 |
+
print("\n[2] Teaching the AI facts and procedures...")
|
| 28 |
+
await engine.store("The company's main language is Python.", goal_id="onboarding")
|
| 29 |
+
await engine.store("If the database locks, restart the Redis pod.", metadata={"type": "procedure"})
|
| 30 |
+
|
| 31 |
+
# Wait for the async worker to process the events
|
| 32 |
+
print(" [Syncing memory tiers...]")
|
| 33 |
+
await asyncio.sleep(0.5)
|
| 34 |
+
|
| 35 |
+
print("\n[3] Retrieving context associatively...")
|
| 36 |
+
results = await engine.query("If the database locks, what should I do?")
|
| 37 |
+
print(f" [Debug: raw query results: {results}]")
|
| 38 |
+
if results:
|
| 39 |
+
mem = await engine.get_memory(results[0][0])
|
| 40 |
+
print(f" -> Top memory retrieved: '{mem.content}' (Score: {results[0][1]:.2f})")
|
| 41 |
+
else:
|
| 42 |
+
print(" -> No memories found.")
|
| 43 |
+
|
| 44 |
+
print("\n[4] VSA Analogical Reasoning (Math in 16k-dimensions)...")
|
| 45 |
+
await engine.define_concept("CTO", {"role": "technical_leader", "gender": "neutral"})
|
| 46 |
+
await engine.define_concept("CEO", {"role": "business_leader", "gender": "neutral"})
|
| 47 |
+
await engine.define_concept("code", {"domain": "technical_leader"})
|
| 48 |
+
|
| 49 |
+
print(" If CTO : code :: CEO : ?")
|
| 50 |
+
analogy = await engine.reason_by_analogy(src="CTO", val="code", tgt="CEO")
|
| 51 |
+
print(f" -> The engine deduced: {analogy[0][0]} (Confidence: {analogy[0][1]:.2f})")
|
| 52 |
+
|
| 53 |
+
print("\n[Success] MnemoCore transforms data storage into cognitive reasoning. Try it in your agents today!")
|
| 54 |
+
await engine.close()
|
| 55 |
+
|
| 56 |
+
# Clean up temp file
|
| 57 |
+
if os.path.exists(demo_db_path):
|
| 58 |
+
os.remove(demo_db_path)
|
| 59 |
+
if os.path.exists(os.path.join(temp_dir, "codebook.json")):
|
| 60 |
+
os.remove(os.path.join(temp_dir, "codebook.json"))
|
| 61 |
+
if os.path.exists(os.path.join(temp_dir, "concepts.json")):
|
| 62 |
+
os.remove(os.path.join(temp_dir, "concepts.json"))
|
| 63 |
+
os.rmdir(temp_dir)
|
| 64 |
+
|
| 65 |
+
if __name__ == "__main__":
|
| 66 |
+
asyncio.run(main())
|
src/mnemocore/core/holographic.py
CHANGED
|
@@ -167,7 +167,7 @@ class ConceptualMemory:
|
|
| 167 |
codebook_data = {}
|
| 168 |
for k, v in self.symbols.items():
|
| 169 |
codebook_data[k] = {
|
| 170 |
-
"data":
|
| 171 |
"dimension": v.dimension
|
| 172 |
}
|
| 173 |
with open(self.codebook_path, 'w') as f:
|
|
@@ -177,7 +177,7 @@ class ConceptualMemory:
|
|
| 177 |
concepts_data = {}
|
| 178 |
for k, v in self.concepts.items():
|
| 179 |
concepts_data[k] = {
|
| 180 |
-
"data":
|
| 181 |
"dimension": v.dimension
|
| 182 |
}
|
| 183 |
with open(self.concepts_path, 'w') as f:
|
|
|
|
| 167 |
codebook_data = {}
|
| 168 |
for k, v in self.symbols.items():
|
| 169 |
codebook_data[k] = {
|
| 170 |
+
"data": v.data.tolist(), # Store as standard Python ints
|
| 171 |
"dimension": v.dimension
|
| 172 |
}
|
| 173 |
with open(self.codebook_path, 'w') as f:
|
|
|
|
| 177 |
concepts_data = {}
|
| 178 |
for k, v in self.concepts.items():
|
| 179 |
concepts_data[k] = {
|
| 180 |
+
"data": v.data.tolist(),
|
| 181 |
"dimension": v.dimension
|
| 182 |
}
|
| 183 |
with open(self.concepts_path, 'w') as f:
|
upload_hf.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from huggingface_hub import HfApi
|
| 3 |
+
|
| 4 |
+
def upload_to_hf():
|
| 5 |
+
api = HfApi()
|
| 6 |
+
|
| 7 |
+
# We are uploading the whole repo but excluding internal/unwanted files
|
| 8 |
+
# User explicitly requested to NOT include the newsletter
|
| 9 |
+
exclude_patterns = [
|
| 10 |
+
".git/**",
|
| 11 |
+
".venv/**",
|
| 12 |
+
".pytest_cache/**",
|
| 13 |
+
"__pycache__/**",
|
| 14 |
+
"data/**",
|
| 15 |
+
"demo_error*.log",
|
| 16 |
+
"*newsletter*",
|
| 17 |
+
"*nyhetsbrev*",
|
| 18 |
+
".gemini/**",
|
| 19 |
+
".claude/**",
|
| 20 |
+
".tmp_phase43_tests/**"
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
print("Uploading to HF...")
|
| 24 |
+
api.upload_folder(
|
| 25 |
+
folder_path="c:/Users/Robin/MnemoCore-Infrastructure-for-Persistent-Cognitive-Memory",
|
| 26 |
+
repo_id="Granis87/MnemoCore",
|
| 27 |
+
repo_type="model",
|
| 28 |
+
ignore_patterns=exclude_patterns,
|
| 29 |
+
commit_message="Release 4.5.0: Added demo script, fixed HDV JSON bugs, applied HF YAML tags"
|
| 30 |
+
)
|
| 31 |
+
print("Upload completed successfully!")
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
upload_to_hf()
|