Unified configuration for Mnemosyne LLM and embedding settings.
Holds default model configuration for LLM and embedding calls, plus per-step overrides that merge on top of defaults. Configuration is validated at load time using Zoi schemas to catch misconfiguration early.
Fields
:session(map/0) - Required. Session auto-commit and timeout configuration The default value is%{auto_commit: true, flush_timeout_ms: 120000, session_timeout_ms: 600000}.:overrides(map/0) - Required. Per-step LLM overrides keyed by pipeline step atom The default value is%{}.:embedding(map/0) - Required. Default embedding model configuration for vector generation:backend(map/0) - Graph backend configuration:llm(map/0) - Required. Default LLM configuration applied to all pipeline steps:value_function(map/0) - Required. Value function module and per-node-type scoring parameters The default value is%{module: Mnemosyne.ValueFunction.Default, params: %{tag: %{k: 5, threshold: 0.9, lambda: 0.01, top_k: 10, base_floor: 0.3, beta: 1.0}, source: %{k: 5, threshold: 0.0, lambda: 0.01, top_k: 50, base_floor: 0.3, beta: 1.0}, semantic: %{k: 5, threshold: 0.0, lambda: 0.01, top_k: 20, base_floor: 0.3, beta: 1.0}, procedural: %{k: 5, threshold: 0.8, lambda: 0.01, top_k: 10, base_floor: 0.3, beta: 1.0}, episodic: %{k: 5, threshold: 0.0, lambda: 0.01, top_k: 30, base_floor: 0.3, beta: 1.0}, subgoal: %{k: 5, threshold: 0.75, lambda: 0.01, top_k: 10, base_floor: 0.3, beta: 1.0}, intent: %{k: 5, threshold: 0.7, lambda: 0.01, top_k: 10, base_floor: 0.3, beta: 1.0}}}.:episodic_validation(map/0) - Required. The default value isnil.:intent_merge_threshold(float/0) - Required. The default value is0.8.:intent_identity_threshold(float/0) - Required. The default value is0.95.:refinement_threshold(float/0) - Required. The default value is0.6.:refinement_budget(integer/0) - Required. The default value is1.:plateau_delta(float/0) - Required. The default value is0.05.:trace_verbosity(:summary|:detailed) - Required. The default value is:summary.:extraction_profile(term/0) - Required. The default value isnil.
Override Resolution
When a pipeline step (e.g. :structuring, :retrieval) has an entry in
:overrides, the override's :model replaces the default and its :opts
are deep-merged with the base LLM opts. This lets you use a cheaper model
for simple extraction steps while keeping a powerful model for reasoning.
Examples
Minimal configuration with defaults:
config = %Mnemosyne.Config{
llm: %{model: "gpt-4o", opts: %{}},
embedding: %{model: "text-embedding-3-small", opts: %{}}
}With per-step overrides:
config = %Mnemosyne.Config{
llm: %{model: "gpt-4o", opts: %{temperature: 0.7}},
embedding: %{model: "text-embedding-3-small", opts: %{}},
overrides: %{
structuring: %{model: "gpt-4o-mini"},
retrieval: %{opts: %{temperature: 0.0}}
}
}Loading from application environment:
# In config/config.exs
config :mnemosyne, :config,
llm: %{model: "gpt-4o", opts: %{temperature: 0.7}},
embedding: %{model: "text-embedding-3-small", opts: %{}}
# At runtime
{:ok, config} = Mnemosyne.Config.from_env()
Summary
Functions
Returns embedding keyword opts from the config as a flat keyword list.
Loads and validates config from the :mnemosyne application environment.
Returns LLM keyword opts for a pipeline step, merging overrides with base opts.
Returns the LLM model and opts for the given pipeline step, applying any overrides.
Returns the embedding model and opts from the config.
Returns the overlay text for a given pipeline step, or nil if no profile or overlay exists.
Returns the value function params for a given node type.
Types
@type t() :: %Mnemosyne.Config{ backend: nil | %{module: atom(), opts: map()}, embedding: %{opts: map(), model: binary()}, episodic_validation: nil | map(), extraction_profile: nil | any(), intent_identity_threshold: float(), intent_merge_threshold: float(), llm: %{opts: map(), model: binary()}, overrides: %{ optional(atom()) => %{ optional(:opts) => map(), optional(:model) => binary() } }, plateau_delta: float(), refinement_budget: integer(), refinement_threshold: float(), session: %{ auto_commit: boolean(), flush_timeout_ms: integer() | :infinity, session_timeout_ms: integer() | :infinity }, trace_verbosity: :summary | :detailed, value_function: %{ module: atom(), params: %{ optional(atom()) => %{ k: integer(), threshold: float(), lambda: float(), top_k: integer(), base_floor: float(), beta: float() } } } }
Functions
Returns embedding keyword opts from the config as a flat keyword list.
Returns an empty list when config is nil, allowing callers to work
without configuration.
@spec from_env() :: {:ok, t()} | {:error, Mnemosyne.Errors.Invalid.ConfigError.t()}
Loads and validates config from the :mnemosyne application environment.
Reads the :config key under the :mnemosyne application and validates it
against the Zoi schema. Returns {:error, ConfigError} when the key is
missing or the data fails validation.
Examples
# When configured:
{:ok, %Mnemosyne.Config{}} = Mnemosyne.Config.from_env()
# When missing:
{:error, %Mnemosyne.Errors.Invalid.ConfigError{reason: :no_config}} = Mnemosyne.Config.from_env()
Returns LLM keyword opts for a pipeline step, merging overrides with base opts.
Resolves the model and opts for the given step, then flattens the result
into a keyword list suitable for passing directly to an LLM adapter call.
The base_opts (typically pipeline-specific options like prompt messages)
are appended after the resolved config options.
Returns base_opts unchanged when config is nil, allowing callers to
work without configuration.
Returns the LLM model and opts for the given pipeline step, applying any overrides.
Looks up the step atom in config.overrides. If an override exists, its
:model replaces the base model (when present) and its :opts are merged
on top of the base opts. When no override exists, the base LLM config is
returned as-is.
Examples
iex> config = %Mnemosyne.Config{
...> llm: %{model: "gpt-4o", opts: %{temperature: 0.7}},
...> embedding: %{model: "e5-base-v2", opts: %{}},
...> overrides: %{structuring: %{model: "gpt-4o-mini"}}
...> }
iex> Mnemosyne.Config.resolve(config, :structuring)
%{model: "gpt-4o-mini", opts: %{temperature: 0.7}}
iex> Mnemosyne.Config.resolve(config, :retrieval)
%{model: "gpt-4o", opts: %{temperature: 0.7}}
Returns the embedding model and opts from the config.
Unlike resolve/2, embeddings have no per-step overrides since the same
embedding model must be used consistently across the entire knowledge graph
to keep vector spaces comparable.
Returns the overlay text for a given pipeline step, or nil if no profile or overlay exists.
Returns the value function params for a given node type.
Looks up the type in config.value_function.params and merges with
per-type defaults. Returns safe defaults for unknown types.