Skip to main content

Configuring MemMachine

MemMachine has one primary file that is used for configuration, cfg.yml. Understanding Configuration Settings You can customize your application’s settings with two types of configuration: Global and Local.
  • Global Configuration acts as the default setting for all your applications. Think of it as your standard setup that everything uses unless told otherwise. This file should reside in your Project root directory.
  • Local Configuration is used when you need to make specific, one-time adjustments for a single session or task. This is best for situations where you have multiple agents, and wish to configure each agent differently. The file should reside in the root directory for each individual agent.
When a local configuration is present, it will take priority and override the global settings, so you can easily make temporary changes without affecting your main setup. The only exception to this is for plugin configurations, which always use the global settings. You can set up both types of configuration in the cfg.yml file using YAML syntax. Below, we will explore the various configuration options available to you.

Tailor MemMachine to Your Needs

Check out the following configuration options, an example of how to set, where to set, and a link to more information about the variable options.
Logging parameters manage the path and level of logging desired.
ParameterRequired?DefaultDescription
pathNo/tmp/memory_logSets the path and file name where logging will be kept.
levelNoinfoChoice between three levels: info, debug, or error
An example of these parameters in a config file would look like the following:
logging:
  path: /tmp/memory_log
  level: info #| debug | error
Parameters that pertain to Long-Term memory settings.
ParameterRequired?DefaultDescription
derivative_deriverNosentenceSets the method for deriving new, insightful information from a memory’s content (can choose identity or sentence).
metadata_derivative_formatNoN/AA template string for formatting derived metadata from memory content. Uses bracket notation to pull properties like user_metadata[source_timestamp] and isolation_properties[producer_id].
embedderNoN/AThe ID of the embedder model to use for generating vector embeddings for long-term memory.
rerankerNoN/AThe ID of the reranker to use for reordering search results to improve relevance.
vector_graph_storeNoN/AThe ID of the storage vendor to use for long-term memory and vector graph storage.
An example of these parameters in a config file would look like the following:
long_term_memory:
  derivative_deriver: sentence
  metadata_prefix: "[$timestamp] $producer_id: "
  embedder: my_embedder_id
  reranker: my_reranker_id
  vector_graph_store: my_storage_id
Parameters that pertain to Profile memory settings.
ParameterRequired?DefaultDescription
llm_modelYestestmodelThe language model for profile extraction.
embedding_modelYesN/AThe model for generating vector embeddings for profile memory.
databaseYesprofile_storageConnection to the profile database. Passing this default allows you to establish all other variables within that subsection.
promptYesprofile_prompt.The system prompts to be used for profile memory.
profile_memory:
  llm_model: testmodel
  embedding_model: my_embedder_id
  database: profile_storage
  prompt: profile_prompt
There is only one parameter for SessionDB, which is the connection URI.
ParameterRequired?DefaultDescription
uriYessqlitetest.dbA configuration dictionary containing the database connection URI. If this field is blank, MemMachine will create an SQLitetest.db.
An example of these parameters in a config file would look like the following:
SessionDB:
  uri: sqlitetest.db
The model parameters are used to establish the LLM model to be used with MemMachine.
The ‘another_model_id` can be any unique identifier you choose. Just be sure you use that unique identifier when referencing the model elsewhere in your configuration. Example holds AWS Bedrock required configuration information
ParameterRequired?DefaultDescription
testmodelYestestmodelThis is the default configuration ID for MemMachine using openai.
model_vendorYes’openai’The vendor of the model (e.g., openai, amazon-bedrock).
modelYes”gpt-4o-mini”The name of the model to use (e.g., gpt-4o-mini).
api_keyYesN/AOnly required if using openai, required if using default set up
another_model_idNoanother_model_idUnique identifier for another model configuration.
An example of these parameters in a config file would look like the following:
Model:
  testmodel:
    model_vendor: openai
    model: "gpt-4o-mini"
    api_key: <YOUR_API_KEY>
  another_model_id:
Parameters that pertain to Storage settings.The Storage database that can be chosen for our Memory to use. You need to set parameters for both my_storage_id and profile_storage to use different databases for long-term memory and profile memory respectively.
Only the Neo4j graph database is supported at this time for Storage (Episodic Memory) and POSTGRESS for Profile Memory.
ParameterRequired?DefaultDescription
<ID>.vendor_nameYesneo4jThe name of the database vendor to use (e.g., neo4j).
<ID>.hostYeslocalhostThe hostname or IP address of the database server.
<ID>.portYes7687The port number for the database connection.
<ID>.userYesN/AThe username for database authentication.
<ID>.passwordYesN/AThe password for database authentication.
profile_storageYesN/AThe configuration for the profile database using Postgres.
<ID>.vendor_nameYespostgresThe name of the database vendor to use for profile storage.
<ID>.hostYeslocalhostThe hostname or IP address of the profile database server.
<ID>.portYes5432The port number for the profile database connection.
<ID>.userYespostgresThe username for profile database authentication.
<ID>.db_nameYespostgresThe name of the profile database.
<ID>.passwordYesN/AThe password for profile database authentication.
storage:
  my_storage_id:
    vendor_name: neo4j
    host: localhost
    port: 7687
    user: neo4j
    password: <YOUR_PASSWORD_HERE>

  profile_storage:
    vendor_name: postgres
    host: localhost
    port: 5432
    user: postgres
    db_name: postgres
    password: <YOUR_PASSWORD_HERE>
ParameterRequired?DefaultDescription
model_nameNoN/AThe ID of the model to use for session memory.
message_capacityNo500The maximum number of messages to store in session memory.
max_message_lengthNo16000The maximum length of a message in session memory.
max_token_numNo8000The maximum number of tokens to store in session memory.
An example of these parameters in a config file would look like the following:
sessionMemory:
  model_name: testmodel
  message_capacity: 500
  max_message_length: 16000
  max_token_num: 8000
The Embedder model that we choose to use.
aws_embedder_id parameters are only required for AWS Bedrock embedding models. The default, my_embedder_id, is set up for OpenAI embedding models.
ParameterRequired?DefaultDescription
my_ebedder_idNoN/ATag for your default embedder. Use if using OpenAI.
<ID>.nameNoopenaiThe vendor name of your embedder.
<ID>.model_nameNo”text-embedding-3-small”The model type of your embedder. Should be by the vendor designated in name.
<ID>.api_keyNoN/AYour API Key for use with OpenAI
An example of these parameters in a config file would look like the following:
embedder:
  my_embedder_id:
    name: openai
    config:
      model_name: "text-embedding-3-small"
      api_key: <YOUR_API_KEY>
Parameters to set for the chosen Reranker.
aws_reranker_id parameters are only required for AWS Bedrock reranking models. If you choose to use AWS Bedrock for your reranker, be sure to list it under your reranker_ids and define it appropriately.
The ce_ranker_id is for use only on systems that have GPUs
ParameterRequired?DefaultDescription
my_reranker_idYesN/AThis tag defines the rerankers you wish to use.
<ID>.typeYesN/AThe type of reranker to use (e.g., rrf-hybrid, identity, bm25, cross-encoder, amazon-bedrock).
<ID>.reranker_idsYesN/AA list of reranker IDs to be used in the hybrid reranker.
id_ranker_idNoN/AAn identity reranker configuration.
bm_ranker_idNoN/AA BM25 reranker configuration.
ce_ranker_idNo”cross-encoder”A cross-encoder reranker configuration.
<ID>.model_nameNoN/AThe model name for the cross-encoder reranker.
aws_reranker_idNoN/ATag should you choose to use AWS Bedrock for your Reranker.
<ID>.regionNoN/AThe AWS region for the Bedrock reranker (e.g., us-west-2).
<ID>.aws_access_key_idNoN/AThe AWS access key ID for Bedrock authentication.
<ID>.aws_secret_access_keyNoN/AThe AWS secret access key for Bedrock authentication.
<ID>.model_idNoN/AThe Bedrock model ID to use for reranking.
An example of these parameters in a config file would look like the following:
reranker:
  my_reranker_id:
    type: "rrf-hybrid"
    reranker_ids:
      - id_ranker_id
      - bm_ranker_id
      - ce_ranker_id
  id_ranker_id:
    type: "identity"
  bm_ranker_id:
    type: "bm25"
  ce_ranker_id:
    type: "cross-encoder"
    model_name: "cross-encoder/qnli-electra-base"
  aws_reranker_id:
    type: "amazon-bedrock"
    region: "us-west-2"
    aws_access_key_id: <AWS_ACCESS_KEY_ID>
    aws_secret_access_key: <AWS_SECRET_ACCESS_KEY>
    model_id: "amazon.rerank-v1:0"