peal.sparse_dictionaries.interfaces.SparseDictionaryConfig

class peal.sparse_dictionaries.interfaces.SparseDictionaryConfig[source]

Bases: BaseModel

Common configuration fields of every sparse dictionary.

Concrete dictionaries subclass this and override sparse_dictionaries_type so that get_sparse_dictionary can resolve the class from a yaml file.

Parameters:
  • n_components (int or None) – Number of dictionary components (columns of the component matrix). Some dictionaries set this themselves after fitting.

  • dict_size (int or None) – Size of the learned dictionary for SAE-style dictionaries; treated as a synonym of n_components by several implementations.

  • sparse_dictionaries_type (str) – Registry key of the concrete dictionary class.

  • category (str) – Fixed to "sparse_dictionaries"; used when resolving default paths.

  • base_path (str or None) – Where fitted weights, plots and logs of this dictionary live.

  • name (str or None) – Where fitted weights, plots and logs of this dictionary live.

  • run_name (str or None) – Where fitted weights, plots and logs of this dictionary live.

  • weights_path (str or None) – Explicit path of the fitted weights; overrides base_path/name.

  • act_size (int) – Dimensionality of the encoder activations the dictionary is fitted on.

  • visualizations_per_component (int) – How many top-activating samples to render per component.

  • weights_name (str) – File name of the weights inside base_path.

  • batch_size (int) – Batch size used when the dictionary itself iterates over data.

  • component_strings (list or None) – Optional human-readable names for the components.

  • data (DataConfig, dict, str or None) – The data the dictionary is fitted on (config object, dict or yaml path).

  • fitted_on_encoder (str or None) – Identity of the encoder whose activations the dictionary was fitted on; see the attribute docstring below.

Methods

Attributes

n_components: int | None = None
dict_size: int | None = None
sparse_dictionaries_type: str
category: str = 'sparse_dictionaries'
base_path: str | None = None
name: str | None = None
run_name: str | None = None
weights_path: str | None = None
act_size: int = 512
visualizations_per_component: int = 100
weights_name: str = 'weights.npz'
batch_size: int = 16
component_strings: list | None = None
data: DataConfig | dict | str | None = None
fitted_on_encoder: str | None = None

Which encoder’s activations this dictionary was fitted on, stamped at fit time. Consumers that edit in the generator’s z_sem space (DiDAE) must refuse a dictionary fitted somewhere else: an OpenCLIP dictionary and a diffusion autoencoder’s z_sem are both 768-d, so nothing about the shapes catches the mismatch and the edits would simply be meaningless.