How iam-saiteja/ncm works
NCM is a small, local-first long-term memory library for conversational AI. An application adds conversation turns; NCM embeds and indexes them, records affect and persona evidence, and retains them in a single file. For a new query, NCM combines dense and keyword retrieval, optionally reranks results, and builds a prompt block with persona, mood, and neighboring turns for the application’s LLM. The graph focuses on the runtime package; benchmark and comparison tooling is excluded. Relationships reflect README-described behavior and the shown memory-module references; unsampled internals are not inferred.
Main entry points: memory.py Memory API · embed.py Text embedder · lexical.py BM25 index · legacy.py v1 import
Components 15
Memory ingestion
- Memory API
ncm/memory.py - Text embedder
ncm/embed.py - Affect analysis
ncm/affect.py - Persona evidence
ncm/persona.py - BM25 index
ncm/lexical.py
Recall and context
- Hybrid recall
ncm/memory.py - Optional reranker
ncm/embed.py - Persona selection
ncm/persona.py - Prompt context
ncm/memory.py - Mood summary
ncm/memory.py
Memory state
- Activation and forgetting
ncm/memory.py - NCM file
ncm/memory.py - v1 import
ncm/legacy.py
Other components
- Application
- Application LLM
Connections 17
- Application → Memory API: adds turns
README.md - Memory API → Text embedder: embeds turns
ncm/memory.py - Memory API → BM25 index: indexes words
ncm/memory.py - Memory API → Affect analysis: records affect
ncm/memory.py - Memory API → Persona evidence: scores evidence
ncm/memory.py - Application → Memory API: queries
README.md - Memory API → Hybrid recall: ranks memories
README.md - Hybrid recall → Text embedder: embeds query
README.md - Hybrid recall → BM25 index: scores keywords
README.md - Hybrid recall → Optional reranker: optionally reranks
README.md - Memory API → Persona selection: selects statements
README.md - Memory API → Mood summary: summarizes mood
README.md - Memory API → Prompt context: builds prompt block
README.md - Prompt context → Application LLM: supplies context
README.md - Memory API → Activation and forgetting: forgets overflow
README.md - Memory API → NCM file: saves and loads
README.md - v1 import → Memory API: imports v1 data
ncm/legacy.py