Skip to content

Latest commit

 

History

History
424 lines (330 loc) · 12.2 KB

File metadata and controls

424 lines (330 loc) · 12.2 KB

Memory Implementations

This document provides an overview of all memory implementations in the MultiMind SDK, including their status and key features.

Implemented Memory Types

Core Memory Types

  1. Base Memory (BaseMemory)

    • Abstract base class for all memory implementations
    • Defines core memory interface and common functionality
  2. Conversation Memory

    • BufferMemory: Stores conversation history in a buffer
    • BufferWindowMemory: Maintains a sliding window of conversation history
    • SummaryMemory / SummaryBufferMemory: Maintain summarized conversation history
  3. Entity Memory (EntityMemory)

    • Stores and retrieves information about entities
    • Maintains relationships between entities
  4. Vector Store Memory (VectorStoreMemory)

    • Implements vector-based similarity search
    • Uses embeddings for efficient memory retrieval
  5. Knowledge Graph Memory (KnowledgeGraphMemory)

    • Stores information in a graph structure
    • Maintains relationships and semantic connections

Advanced Memory Types

  1. Time-Weighted Memory (TimeWeightedMemory)

    • Implements time-based memory decay
    • Prioritizes recent memories
  2. Token Buffer Memory (TokenBufferMemory)

    • Manages memory based on token count
    • Implements token-based memory limits
  3. Hybrid Memory (HybridMemory)

    • Combines multiple memory types
    • Provides unified interface for different memory systems
  4. Hierarchical Memory (HierarchicalMemory)

    • Organizes memories in a hierarchical structure
    • Supports multi-level memory access
  5. Contextual Memory (ContextualMemory)

    • Maintains context-aware memory retrieval
    • Supports contextual relevance scoring
  6. Episodic Memory (EpisodicMemory)

    • Stores event-based memories
    • Maintains temporal sequence of events
  7. Semantic Memory (SemanticMemory)

    • Stores conceptual knowledge
    • Implements semantic similarity search
  8. Procedural Memory (ProceduralMemory)

    • Stores action sequences and procedures
    • Maintains skill-based knowledge
  9. Working Memory (WorkingMemory)

    • Implements short-term memory processing
    • Manages active cognitive tasks
  10. Associative Memory (AssociativeMemory)

    • Implements pattern-based memory retrieval
    • Maintains associative connections
  11. Emotional Memory (EmotionalMemory)

    • Stores emotionally significant memories
    • Implements emotional valence tracking
  12. Declarative Memory (DeclarativeMemory)

    • Stores factual knowledge
    • Implements explicit memory retrieval
  13. Spatial Memory (SpatialMemory)

    • Stores spatial relationships
    • Implements spatial reasoning
  14. Temporal Memory (TemporalMemory)

    • Manages time-based memory organization
    • Implements temporal reasoning
  15. Sensory Memory (SensoryMemory)

    • Stores sensory information
    • Implements sensory processing
  16. Forgetting Curve Memory (ForgettingCurveMemory)

    • Implements Ebbinghaus forgetting curve
    • Manages memory decay over time
  17. Novelty Memory (NoveltyMemory)

    • Tracks novel information
    • Implements novelty detection
  18. Versioned Memory (VersionedMemory)

    • Maintains memory versions
    • Implements version control for memories
  19. Event-Sourced Memory (EventSourcedMemory)

    • Stores memory as event sequences
    • Implements event-based memory reconstruction
  20. Cognitive Scratchpad Memory (CognitiveScratchpadMemory)

    • Implements temporary working memory
    • Manages active cognitive processing
  21. Federated Memory (FederatedMemory)

    • Implements distributed memory storage
    • Supports privacy-preserving memory sharing
  22. Active Learning Memory (ActiveLearningMemory)

    • Implements active learning for memory
    • Optimizes memory acquisition
  23. Differentiable Neural Computer Memory (DNCMemory)

    • Implements DNC architecture
    • Supports complex memory operations
  24. Meta Memory (MetaMemory)

    • Manages memory about memories
    • Implements memory self-awareness
  25. Sketch Memory (SketchMemory)

    • Implements approximate memory storage
    • Supports efficient memory compression
  26. Causal Memory (CausalMemory)

    • Stores causal relationships
    • Implements causal reasoning
  27. Neuro-Symbolic Memory (NeuroSymbolicMemory)

    • Combines neural and symbolic memory
    • Supports hybrid reasoning
  28. Autobiographical Memory (AutobiographicalMemory)

    • Stores personal experiences
    • Implements self-referential memory
  29. Prospective Memory (ProspectiveMemory)

    • Manages future-oriented memory
    • Implements intention memory
  30. Implicit Memory (ImplicitMemory)

    • Stores unconscious memories
    • Implements procedural learning
  31. Explicit Memory (ExplicitMemory)

    • Stores conscious memories
    • Implements declarative learning
  32. Short-Term Memory (ShortTermMemory)

    • Manages temporary memory storage
    • Implements working memory
  33. Long-Term Memory (LongTermMemory)

    • Manages permanent memory storage
    • Implements persistent memory
  34. Consensus Memory (ConsensusMemory)

    • Implements distributed consensus
    • Uses RAFT protocol for consistency
  35. Reinforcement Memory (ReinforcementMemory)

    • Implements memory budgeting
    • Uses reinforcement learning for optimization
  36. Adaptive Memory (AdaptiveMemory)

    • Implements self-adapting memory
    • Optimizes memory based on usage
  37. Planning Memory (PlanningMemory)

    • Implements memory-based planning
    • Supports action planning with rollouts
  38. Fast-Weight Memory (FastWeightMemory)

    • Implements Hebbian learning
    • Supports rapid in-context learning
    • Uses weight matrix for memory storage
  39. Adapter Memory (AdapterMemory)

    • Implements adapter-based session memory
    • Supports fine-tuning per session
    • Uses adapter layers for memory adaptation
  40. Hierarchical Temporal Memory (HTMMemory)

    • Implements HTM architecture
    • Supports sequence prediction
    • Uses sparse distributed representations
  41. Quantum Random-Access Memory (QRAM)

    • Implements quantum memory using bucket-brigade design
    • Supports coherent memory access
    • Uses quantum state for addressing
    • Features error correction and coherence tracking
  42. Quantum Associative Memory (QAM)

    • Implements quantum Hopfield network
    • Supports pattern-based memory retrieval
    • Uses quantum energy landscape
    • Features pattern diversity tracking
  43. Topological Quantum Memory (TopologicalMemory)

    • Implements topological quantum memory using anyons
    • Supports braiding operations for memory access
    • Uses logical qubits for error protection
    • Features anyon-based encoding and decoding
  44. Quantum-Classical Hybrid Memory (QuantumClassicalHybridMemory)

    • Implements hybrid quantum-classical memory
    • Supports both quantum and classical storage
    • Uses quantum enhancement for classical data
    • Features adaptive encoding selection

Partially Implemented Memory Types

  1. Neuromorphic Spiking Memory

    • Basic structure implemented
    • Needs completion of spike-timing-dependent plasticity
    • Requires integration with neuromorphic hardware
  2. Nonparametric Bayesian Memory

    • Basic clustering implemented
    • Needs completion of Bayesian inference
    • Requires optimization of hyperparameters
  3. Topological Quantum Memory

    • Basic structure implemented
    • Needs completion of error protection
    • Requires integration with quantum hardware
  4. Neuromorphic Quantum Memory

    • Basic structure implemented
    • Needs completion of quantum spike timing
    • Requires integration with neuromorphic hardware

Memory Types To Be Implemented

  1. Holographic Memory

    • Holographic storage
    • Interference patterns
    • Distributed memory representation
  2. DNA Memory

    • DNA-based storage
    • Molecular memory encoding
    • Biological memory systems
  3. Quantum-Classical Hybrid Memory

    • Quantum-classical interface
    • Hybrid state storage
    • Quantum-enhanced classical memory
  4. Neuromorphic Quantum Memory

    • Quantum neuromorphic computing
    • Quantum neural networks
    • Quantum spike timing

Usage Examples

FastWeightMemory and AdapterMemory require the finetune extra: pip install "multimind-sdk[finetune]".

from multimind import OpenAIModel
from multimind.memory import (
    BufferMemory,
    VectorStoreMemory,
    HybridMemory,
    FastWeightMemory,   # requires multimind-sdk[finetune]
    AdapterMemory,      # requires multimind-sdk[finetune]
    HTMMemory,
    QRAM,
    QAM,
    TopologicalMemory,
    QuantumClassicalHybridMemory
)

model = OpenAIModel(model_name="gpt-4o-mini")

# Create a conversation memory
conv_memory = BufferMemory()

# Create a vector store memory (needs an LLM for embeddings/summaries)
vector_memory = VectorStoreMemory(llm=model)

# Create a hybrid memory (routes across memory types)
hybrid_memory = HybridMemory(
    llm=model,
    memory_types=[BufferMemory, VectorStoreMemory]
)

# Create a fast-weight memory
fast_memory = FastWeightMemory(
    input_size=768,
    memory_size=1024
)

# Create an adapter memory
adapter_memory = AdapterMemory(
    input_size=768,
    adapter_size=64
)

# Create an HTM memory
htm_memory = HTMMemory(
    input_size=1024,
    num_columns=2048
)

# Create a quantum random-access memory
qram = QRAM(
    num_qubits=8,
    memory_size=256,
    error_rate=0.01
)

# Create a quantum associative memory
qam = QAM(
    num_qubits=8,
    num_patterns=16,
    learning_rate=0.1
)

# Create a topological quantum memory
topological_memory = TopologicalMemory(
    num_qubits=8,
    surface_size=32,
    error_threshold=0.1
)

# Create a quantum-classical hybrid memory
quantum_hybrid_memory = QuantumClassicalHybridMemory(
    num_qubits=8,
    classical_size=1024,
    hybrid_threshold=0.5
)

# Add a message to the hybrid memory (routed to the best memory type)
await hybrid_memory.add_message(
    {"role": "user", "content": "This is an example memory"}
)

# Add memory to QRAM
await qram.add_memory(
    memory_id="quantum_example",
    content="This is a quantum memory example",
    metadata={"type": "quantum"}
)

# Add pattern to QAM
await qam.add_memory(
    memory_id="quantum_pattern",
    content="This is a quantum pattern",
    metadata={"type": "pattern"}
)

# Add memory to topological memory
await topological_memory.add_memory(
    memory_id="topological_example",
    content="This is a topological memory example",
    metadata={"type": "topological"}
)

# Add memory to hybrid memory
await quantum_hybrid_memory.add_memory(
    memory_id="hybrid_example",
    content="This is a hybrid memory example",
    metadata={"type": "hybrid"}
)

# Retrieve messages from the hybrid memory
messages = await hybrid_memory.get_messages()

# Retrieve from QRAM
qram_memory = await qram.get_memory("quantum_example")

# Retrieve from QAM
qam_memory = await qam.get_memory("quantum_pattern")

# Retrieve from topological memory
topological_result = await topological_memory.get_memory("topological_example")

# Retrieve from hybrid memory
hybrid_result = await quantum_hybrid_memory.get_memory("hybrid_example")

Best Practices

  1. Memory Selection

    • Choose memory type based on use case
    • Consider memory requirements
    • Evaluate performance needs
  2. Memory Configuration

    • Configure memory parameters appropriately
    • Monitor memory usage
    • Optimize memory settings
  3. Memory Management

    • Implement proper cleanup
    • Handle memory errors
    • Monitor memory statistics
  4. Quantum Memory Considerations

    • Monitor coherence times
    • Track error rates
    • Implement error correction
    • Consider quantum-classical interfaces
    • Handle anyon braiding operations
    • Manage hybrid memory allocation

Contributing

To contribute new memory implementations:

  1. Create a new file in the multimind/memory directory
  2. Implement the memory class inheriting from BaseMemory
  3. Add necessary imports to __init__.py
  4. Update documentation
  5. Add tests
  6. Submit a pull request