MotteMB - Memory Bank

Intelligent vector memory system

MotteMB provides sophisticated memory management using vector embeddings for context-aware agent memory and semantic retrieval with OpenAI's text-embedding-3-large model.

Core Components

Vector Embeddings

1536-dimensional vectors using OpenAI's text-embedding-3-large model for semantic understanding.

  • • High-quality semantic representations
  • • Multilingual support
  • • Optimized for similarity search

Semantic Search

Find relevant memories using natural language queries with cosine similarity matching.

  • • Context-aware retrieval
  • • Configurable similarity thresholds
  • • Ranked results by relevance

Storage System

PostgreSQL with pgvector extension for efficient vector storage and indexing with HNSW algorithms.

Bulk Operations

Import/export memories in JSON, CSV, TXT, and JSONL formats with batch processing capabilities.

Memory Schema

Memory Object Structure

{
  "id": "mem_abc123",
  "content": "Customer refund policy allows returns within 30 days...",
  "embedding": [0.123, -0.456, 0.789, ...], // 1536 dimensions
  "metadata": {
    "category": "policy",
    "source": "handbook",
    "priority": "high",
    "tags": ["refund", "policy", "customer-service"],
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  },
  "similarity_score": 0.87 // Only present in search results
}

Search Algorithms

AlgorithmUse CasePerformanceAccuracy
Cosine SimilarityGeneral semantic searchFastHigh
HNSW IndexLarge-scale retrievalVery FastHigh
Exact SearchSmall datasetsSlowPerfect

Optimization Features

Duplicate Detection

Automatically identify and remove duplicate or near-duplicate memories using similarity thresholds >0.95.

Index Optimization

Rebuild HNSW indexes for optimal query performance with configurable ef_construction and M parameters.

Storage Compression

Compress vector storage using quantization techniques to reduce memory usage by up to 75%.

Batch Processing

Process large datasets efficiently with chunked embedding generation and parallel database operations.

API Endpoints

Store Memory

POST /api/memory/store
Content-Type: application/json

{
  "content": "Customer refund policy allows returns within 30 days for digital products and 60 days for physical products.",
  "metadata": {
    "category": "policy",
    "source": "handbook",
    "priority": "high",
    "tags": ["refund", "policy", "customer-service"]
  }
}

Stores a new memory with automatic embedding generation and metadata indexing.

Search Memories

POST /api/memory/search
Content-Type: application/json

{
  "query": "What is our refund policy for digital products?",
  "limit": 5,
  "threshold": 0.7,
  "filters": {
    "category": "policy",
    "priority": ["high", "medium"]
  }
}

Searches for relevant memories using semantic similarity with optional metadata filters.

Bulk Import

POST /api/memory/import
Content-Type: multipart/form-data

file: [uploaded file]
format: "json" | "csv" | "txt" | "jsonl"
batch_size: 100 (optional)
auto_categorize: true (optional)

Bulk import memories from various file formats with automatic processing and categorization.

Memory Statistics

GET /api/memory/stats

Response:
{
  "total_memories": 1250,
  "categories": {
    "policy": 45,
    "faq": 120,
    "procedures": 85
  },
  "storage_size": "2.3 MB",
  "index_size": "1.1 MB",
  "last_optimization": "2024-01-15T10:30:00Z"
}

Get comprehensive statistics about your memory bank including storage usage and categorization.

Performance Tuning

Search Optimization

  • Similarity Threshold: 0.7-0.8 for general use, 0.8-0.9 for precise matching
  • Result Limit: 5-10 results for most applications, 20+ for comprehensive search
  • Index Parameters: ef_construction=200, M=16 for balanced performance
  • Batch Size: 50-100 for imports, 10-20 for real-time processing

Memory Management

  • Regular Cleanup: Remove outdated memories monthly
  • Duplicate Removal: Run weekly with 0.95+ similarity threshold
  • Index Rebuilding: Rebuild indexes after 10k+ new memories
  • Backup Strategy: Export memories weekly for disaster recovery