feat: add local semantic memory with embedding + vector search#2421
Open
0xbyt4 wants to merge 10 commits intoOpenMind:mainfrom
Open
feat: add local semantic memory with embedding + vector search#24210xbyt4 wants to merge 10 commits intoOpenMind:mainfrom
0xbyt4 wants to merge 10 commits intoOpenMind:mainfrom
Conversation
Add SemanticMemoryProvider using sentence-transformers (all-MiniLM-L6-v2) and ChromaDB for persistent semantic memory. Robot stores sensory-action pairs and retrieves relevant memories via cosine similarity, injecting them into the LLM prompt as RELEVANT MEMORIES section.
- Move sentence-transformers, chromadb, onnxruntime to [project.optional-dependencies] memory group to avoid ~500MB+ ML dependency bloat for users who don't use semantic memory. Install with: uv sync --extra memory - Fix test_retrieve_filters_by_threshold to assert empty list instead of just isinstance check
…t config
- Use pytest.importorskip("chromadb") at top-level so tests are skipped
when memory extras are not installed (CI runs uv sync without --extra memory)
- Remove all function-level imports in favor of top-level imports
- Remove semantic_memory fields from conversation.json5 since memory is
an optional feature that users opt into
Base already includes torch, ultralytics, deepface, tf-keras. sentence-transformers and chromadb are small in comparison. Keeping them in base ensures CI runs tests without workflow changes.
…manager - test_fuser_injects_memories_when_enabled: verify RELEVANT MEMORIES in prompt - test_fuser_skips_memories_when_disabled: verify no injection when disabled - test_update_history_stores_to_semantic_memory: verify store() called with correct mode - test_update_history_skips_store_when_memory_disabled: verify store() not called
Keep both semantic memory and knowledge base features in fuser. Adapt semantic memory tests to async fuse() signature.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
faiss-cpu and sentence-transformers native libraries conflict on macOS ARM64, causing SIGSEGV (exit code 139) when both are loaded in the same process. Move KnowledgeBase import from top-level to lazy import inside __init__, so faiss is only loaded when KB config is present.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OM1 currently has short-term memory (LLMHistoryManager: last N messages + summarization) but no long-term memory - the robot cannot learn from previous interactions. This PR adds local semantic memory using embedding-based vector search, allowing the robot to store experiences and automatically retrieve relevant memories during conversations.
How It Works
Each tick, the Fuser queries semantic memory with the current sensor input. ChromaDB returns the top-k most similar past experiences (filtered by cosine similarity threshold). These are injected into the prompt as a
RELEVANT MEMORIESsection between inputs and actions. After the LLM responds, the input-response pair is stored as a new memory.Technical Details
config/memory/embeddings/om1_{mode_name})semantic_memory_enabled: trueResource Budget (Apple M3, 8GB RAM)
Configuration
Disabled by default. Enable per config:
Changes
src/providers/semantic_memory_provider.pysrc/llm/__init__.pysrc/runtime/cortex.pysrc/providers/llm_history_manager.pysrc/fuser/__init__.pytests/providers/test_semantic_memory_provider.pypyproject.tomlVerified Manually
Tested with MockInput (WebSocket) + conversation config. Robot successfully: