MemOS Configuration Guide

This document provides a comprehensive overview of all configuration fields and initialization methods across the different components in the MemOS system.
  1. Configuration Overview
  2. MOS Configuration
  3. LLM Configuration
  4. MemReader Configuration
  5. MemCube Configuration
  6. Memory Configuration
  7. Embedder Configuration
  8. Vector Database Configuration
  9. Graph Database Configuration
  10. Scheduler Configuration
  11. Initialization Methods
  12. Configuration Examples

Configuration Overview

MemOS uses a hierarchical configuration system with factory patterns for different backends. Each component has:

  • A base configuration class
  • Backend-specific configuration classes
  • A factory class that creates the appropriate configuration based on the backend

MOS Configuration

The main MOS configuration that orchestrates all components.

MOSConfig Fields

FieldTypeDefaultDescription
user_idstr"root"User ID for the MOS this Config User ID will as default
session_idstrauto-generated UUIDSession ID for the MOS
chat_modelLLMConfigFactoryrequiredLLM configuration for chat
mem_readerMemReaderConfigFactoryrequiredMemReader configuration
mem_schedulerSchedulerFactorynot requiredScheduler configuration
max_turns_windowint15Maximum conversation turns to keep
top_kint5Maximum memories to retrieve per query
enable_textual_memoryboolTrueEnable textual memory
enable_activation_memoryboolFalseEnable activation memory
enable_parametric_memoryboolFalseEnable parametric memory
enable_mem_schedulerboolFalseEnable scheduler memory

Example MOS Configuration

{
  "user_id": "root",
  "chat_model": {
    "backend": "huggingface",
    "config": {
      "model_name_or_path": "Qwen/Qwen3-1.7B",
      "temperature": 0.1,
      "remove_think_prefix": true,
      "max_tokens": 4096
    }
  },
  "mem_reader": {
    "backend": "simple_struct",
    "config": {
      "llm": {
        "backend": "ollama",
        "config": {
          "model_name_or_path": "qwen3:0.6b",
          "temperature": 0.8,
          "max_tokens": 1024,
          "top_p": 0.9,
          "top_k": 50
        }
      },
      "embedder": {
        "backend": "ollama",
        "config": {
          "model_name_or_path": "nomic-embed-text:latest"
        }
      },
    "chunker": {
      "backend": "sentence",
      "config": {
        "tokenizer_or_token_counter": "gpt2",
        "chunk_size": 512,
        "chunk_overlap": 128,
        "min_sentences_per_chunk": 1
      }
    }
    }
  },
  "max_turns_window": 20,
  "top_k": 5,
  "enable_textual_memory": true,
  "enable_activation_memory": false,
  "enable_parametric_memory": false
}

LLM Configuration

Configuration for different Large Language Model backends.

Base LLM Fields

FieldTypeDefaultDescription
model_name_or_pathstrrequiredModel name or path
temperaturefloat0.8Temperature for sampling
max_tokensint1024Maximum tokens to generate
top_pfloat0.9Top-p sampling parameter
top_kint50Top-k sampling parameter
remove_think_prefixboolFalseRemove think tags from output

Backend-Specific Fields

OpenAI LLM

FieldTypeDefaultDescription
api_keystrrequiredOpenAI API key
api_basestr"https://api.openai.com/v1"OpenAI API base URL

Ollama LLM

FieldTypeDefaultDescription
api_basestr"http://localhost:11434"Ollama API base URL

HuggingFace LLM

FieldTypeDefaultDescription
do_sampleboolFalseUse sampling vs greedy decoding
add_generation_promptboolTrueApply generation template

Example LLM Configurations

// OpenAI
{
  "backend": "openai",
  "config": {
    "model_name_or_path": "gpt-4o",
    "temperature": 0.8,
    "max_tokens": 1024,
    "top_p": 0.9,
    "top_k": 50,
    "api_key": "sk-...",
    "api_base": "https://api.openai.com/v1"
  }
}

// Ollama
{
  "backend": "ollama",
  "config": {
    "model_name_or_path": "qwen3:0.6b",
    "temperature": 0.8,
    "max_tokens": 1024,
    "top_p": 0.9,
    "top_k": 50,
    "api_base": "http://localhost:11434"
  }
}

// HuggingFace
{
  "backend": "huggingface",
  "config": {
    "model_name_or_path": "Qwen/Qwen3-1.7B",
    "temperature": 0.1,
    "remove_think_prefix": true,
    "max_tokens": 4096,
    "do_sample": false,
    "add_generation_prompt": true
  }
}

MemReader Configuration

Configuration for memory reading components.

Base MemReader Fields

FieldTypeDefaultDescription
created_atdatetimeauto-generatedCreation timestamp
llmLLMConfigFactoryrequiredLLM configuration
embedderEmbedderConfigFactoryrequiredEmbedder configuration
chunkerchunkerConfigFactoryrequiredchunker configuration

Backend Types

  • simple_struct: Structured memory reader

Example MemReader Configuration

{
  "backend": "simple_struct",
  "config": {
    "llm": {
      "backend": "ollama",
      "config": {
        "model_name_or_path": "qwen3:0.6b",
        "temperature": 0.0,
        "remove_think_prefix": true,
        "max_tokens": 8192
      }
    },
    "embedder": {
      "backend": "ollama",
      "config": {
        "model_name_or_path": "nomic-embed-text:latest"
      }
    },
    "chunker": {
      "backend": "sentence",
      "config": {
        "tokenizer_or_token_counter": "gpt2",
        "chunk_size": 512,
        "chunk_overlap": 128,
        "min_sentences_per_chunk": 1
      }
    }
  }
}

MemCube Configuration

Configuration for memory cube components.

GeneralMemCubeConfig Fields

FieldTypeDefaultDescription
user_idstr"default_user"User ID for the MemCube
cube_idstrauto-generated UUIDCube ID for the MemCube
text_memMemoryConfigFactoryrequiredTextual memory configuration
act_memMemoryConfigFactoryrequiredActivation memory configuration
para_memMemoryConfigFactoryrequiredParametric memory configuration

Allowed Backends

  • Text Memory: naive_text, general_text, tree_text, uninitialized
  • Activation Memory: kv_cache, uninitialized
  • Parametric Memory: lora, uninitialized

Example MemCube Configuration

{
  "user_id": "root",
  "cube_id": "root/mem_cube_kv_cache",
  "text_mem": {},
  "act_mem": {
    "backend": "kv_cache",
    "config": {
      "memory_filename": "activation_memory.pickle",
      "extractor_llm": {
        "backend": "huggingface",
        "config": {
          "model_name_or_path": "Qwen/Qwen3-1.7B",
          "temperature": 0.8,
          "max_tokens": 1024,
          "top_p": 0.9,
          "top_k": 50,
          "add_generation_prompt": true,
          "remove_think_prefix": false
        }
      }
    }
  },
  "para_mem": {
    "backend": "lora",
    "config": {
      "memory_filename": "parametric_memory.adapter",
      "extractor_llm": {
        "backend": "huggingface",
        "config": {
          "model_name_or_path": "Qwen/Qwen3-1.7B",
          "temperature": 0.8,
          "max_tokens": 1024,
          "top_p": 0.9,
          "top_k": 50,
          "add_generation_prompt": true,
          "remove_think_prefix": false
        }
      }
    }
  }
}

Memory Configuration

Configuration for different types of memory systems.

Base Memory Fields

FieldTypeDefaultDescription
cube_idstrNoneUnique MemCube identifier is can be cube_name or path as default

Textual Memory Configurations

Base Text Memory

FieldTypeDefaultDescription
memory_filenamestr"textual_memory.json"Filename for storing memories

Naive Text Memory

FieldTypeDefaultDescription
extractor_llmLLMConfigFactoryrequiredLLM for memory extraction

General Text Memory

FieldTypeDefaultDescription
extractor_llmLLMConfigFactoryrequiredLLM for memory extraction
vector_dbVectorDBConfigFactoryrequiredVector database configuration
embedderEmbedderConfigFactoryrequiredEmbedder configuration

Tree Text Memory

FieldTypeDefaultDescription
extractor_llmLLMConfigFactoryrequiredLLM for memory extraction
dispatcher_llmLLMConfigFactoryrequiredLLM for memory dispatching
embedderEmbedderConfigFactoryrequiredEmbedder configuration
graph_dbGraphDBConfigFactoryrequiredGraph database configuration

Activation Memory Configurations

Base Activation Memory

FieldTypeDefaultDescription
memory_filenamestr"activation_memory.pickle"Filename for storing memories

KV Cache Memory

FieldTypeDefaultDescription
extractor_llmLLMConfigFactoryrequiredLLM for memory extraction (must be huggingface)

Parametric Memory Configurations

Base Parametric Memory

FieldTypeDefaultDescription
memory_filenamestr"parametric_memory.adapter"Filename for storing memories

LoRA Memory

FieldTypeDefaultDescription
extractor_llmLLMConfigFactoryrequiredLLM for memory extraction (must be huggingface)

Example Memory Configurations

// Tree Text Memory
{
  "backend": "tree_text",
  "config": {
    "memory_filename": "tree_memory.json",
    "extractor_llm": {
      "backend": "ollama",
      "config": {
        "model_name_or_path": "qwen3:0.6b",
        "temperature": 0.0,
        "remove_think_prefix": true,
        "max_tokens": 8192
      }
    },
    "dispatcher_llm": {
      "backend": "ollama",
      "config": {
        "model_name_or_path": "qwen3:0.6b",
        "temperature": 0.0,
        "remove_think_prefix": true,
        "max_tokens": 8192
      }
    },
    "embedder": {
      "backend": "ollama",
      "config": {
        "model_name_or_path": "nomic-embed-text:latest"
      }
    },
    "graph_db": {
      "backend": "neo4j",
      "config": {
        "uri": "bolt://localhost:7687",
        "user": "neo4j",
        "password": "12345678",
        "db_name": "user08alice",
        "auto_create": true,
        "embedding_dimension": 768
      }
    }
  }
}

Embedder Configuration

Configuration for embedding models.

Base Embedder Fields

FieldTypeDefaultDescription
model_name_or_pathstrrequiredModel name or path
embedding_dimsintNoneNumber of embedding dimensions

Backend-Specific Fields

Ollama Embedder

FieldTypeDefaultDescription
api_basestr"http://localhost:11434"Ollama API base URL

Sentence Transformer Embedder

No additional fields beyond base configuration.

Example Embedder Configurations

// Ollama Embedder
{
  "backend": "ollama",
  "config": {
    "model_name_or_path": "nomic-embed-text:latest",
    "api_base": "http://localhost:11434"
  }
}

// Sentence Transformer Embedder
{
  "backend": "sentence_transformer",
  "config": {
    "model_name_or_path": "all-MiniLM-L6-v2",
    "embedding_dims": 384
  }
}

Vector Database Configuration

Configuration for vector databases.

Base Vector DB Fields

FieldTypeDefaultDescription
collection_namestrrequiredName of the collection
vector_dimensionintNoneDimension of the vectors
distance_metricstrNoneDistance metric (cosine, euclidean, dot)

Qdrant Vector DB Fields

FieldTypeDefaultDescription
hoststrNoneQdrant host
portintNoneQdrant port
pathstrNoneQdrant local path

Example Vector DB Configuration

{
  "backend": "qdrant",
  "config": {
    "collection_name": "memories",
    "vector_dimension": 768,
    "distance_metric": "cosine",
    "path": "/path/to/qdrant"
  }
}

Graph Database Configuration

Configuration for graph databases.

Base Graph DB Fields

FieldTypeDefaultDescription
uristrrequiredDatabase URI
userstrrequiredDatabase username
passwordstrrequiredDatabase password

Neo4j Graph DB Fields

FieldTypeDefaultDescription
db_namestrrequiredTarget database name
auto_createboolFalseCreate DB if it doesn't exist
embedding_dimensionint768Vector embedding dimension

Example Graph DB Configuration

{
  "backend": "neo4j",
  "config": {
    "uri": "bolt://localhost:7687",
    "user": "neo4j",
    "password": "12345678",
    "db_name": "user08alice",
    "auto_create": true,
    "embedding_dimension": 768
  }
}

Scheduler Configuration

Configuration for memory scheduling systems that manage memory retrieval and activation.

Base Scheduler Fields

FieldTypeDefaultDescription
top_kint10Number of top candidates to consider in initial retrieval
top_nint5Number of final results to return after processing
enable_parallel_dispatchboolTrueWhether to enable parallel message processing using thread pool
thread_pool_max_workersint5Maximum worker threads in pool (1-20)
consume_interval_secondsint3Interval for consuming messages from queue in seconds (0-60)

General Scheduler Fields

FieldTypeDefaultDescription
act_mem_update_intervalint300Interval in seconds for updating activation memory
context_window_sizeint5Size of the context window for conversation history
activation_mem_sizeint5Maximum size of the activation memory
act_mem_dump_pathstrauto-generatedFile path for dumping activation memory

Backend Types

  • general_scheduler: Advanced scheduler with activation memory management

Example Scheduler Configuration

{
  "backend": "general_scheduler",
  "config": {
    "top_k": 10,
    "top_n": 5,
    "act_mem_update_interval": 300,
    "context_window_size": 5,
    "activation_mem_size": 1000,
    "thread_pool_max_workers": 10,
    "consume_interval_seconds": 3,
    "enable_parallel_dispatch": true
  }
}

Initialization Methods

From JSON File

from memos.configs.mem_os import MOSConfig

# Load configuration from JSON file
mos_config = MOSConfig.from_json_file("path/to/config.json")

From Dictionary

from memos.configs.mem_os import MOSConfig

# Create configuration from dictionary
config_dict = {
    "user_id": "root",
    "chat_model": {
        "backend": "huggingface",
        "config": {
            "model_name_or_path": "Qwen/Qwen3-1.7B",
            "temperature": 0.1
        }
    }
    # ... other fields
}

mos_config = MOSConfig(**config_dict)

Factory Pattern Usage

from memos.configs.llm import LLMConfigFactory

# Create LLM configuration using factory
llm_config = LLMConfigFactory(
    backend="huggingface",
    config={
        "model_name_or_path": "Qwen/Qwen3-1.7B",
        "temperature": 0.1
    }
)

Configuration Examples

Complete MOS Setup

from memos.configs.mem_os import MOSConfig
from memos.mem_os.main import MOS

# Load configuration
mos_config = MOSConfig.from_json_file("examples/data/config/simple_memos_config.json")

# Initialize MOS
mos = MOS(mos_config)

# Create user and register cube
user_id = "user_123"
mos.create_user(user_id=user_id)
mos.register_mem_cube("path/to/mem_cube", user_id=user_id)

# Use MOS
response = mos.chat("Hello, how are you?", user_id=user_id)

Tree Memory Configuration

from memos.configs.memory import MemoryConfigFactory

# Create tree memory configuration
tree_memory_config = MemoryConfigFactory(
    backend="tree_text",
    config={
        "memory_filename": "tree_memory.json",
        "extractor_llm": {
            "backend": "ollama",
            "config": {
                "model_name_or_path": "qwen3:0.6b",
                "temperature": 0.0,
                "max_tokens": 8192
            }
        },
        "dispatcher_llm": {
            "backend": "ollama",
            "config": {
                "model_name_or_path": "qwen3:0.6b",
                "temperature": 0.0,
                "max_tokens": 8192
            }
        },
        "embedder": {
            "backend": "ollama",
            "config": {
                "model_name_or_path": "nomic-embed-text:latest"
            }
        },
        "graph_db": {
            "backend": "neo4j",
            "config": {
                "uri": "bolt://localhost:7687",
                "user": "neo4j",
                "password": "password",
                "db_name": "memories",
                "auto_create": True,
                "embedding_dimension": 768
            }
        }
    }
)

Multi-Backend LLM Configuration

from memos.configs.llm import LLMConfigFactory

# OpenAI configuration
openai_config = LLMConfigFactory(
    backend="openai",
    config={
        "model_name_or_path": "gpt-4o",
        "temperature": 0.8,
        "max_tokens": 1024,
        "api_key": "sk-...",
        "api_base": "https://api.openai.com/v1"
    }
)

# Ollama configuration
ollama_config = LLMConfigFactory(
    backend="ollama",
    config={
        "model_name_or_path": "qwen3:0.6b",
        "temperature": 0.8,
        "max_tokens": 1024,
        "api_base": "http://localhost:11434"
    }
)

# HuggingFace configuration
hf_config = LLMConfigFactory(
    backend="huggingface",
    config={
        "model_name_or_path": "Qwen/Qwen3-1.7B",
        "temperature": 0.1,
        "remove_think_prefix": True,
        "max_tokens": 4096,
        "do_sample": False,
        "add_generation_prompt": True
    }
)

This comprehensive configuration system allows for flexible and extensible setup of the MemOS system with different backends and components.

Memtensor
© 2025 Memtensor, Inc. All rights reserved.