peal.sparse_dictionaries

Sparse dictionaries: concept bases over an encoder’s activation space.

A SparseDictionary (interfaces) is fitted on the activations of a feature extractor (the diffusion autoencoder’s semantic encoder, CLIP, DINO, …) and exposes its atoms through get_components so that DiDAE can sweep, rank and edit along them. Implementations: probe SAEs, BatchTopK, the MSAE (Matryoshka) and RA-SAE decompositions of published checkpoints, SpLiCE, plain and SAE-filtered SVD and the supervised orthogonal Procrustes dictionary. sparse_dictionary_factory.get_sparse_dictionary builds one from its config, activation_cache memoises extracted activations, sae_evaluation matches atoms to ground-truth attributes and utils holds shared plotting helpers.

Submodules

activation_cache

Optional on-disk cache for encoder activations.

batch_topk

BatchTopK sparse autoencoder as a PEAL sparse dictionary.

batch_topk_network

PEAL's own batch top-K sparse autoencoder, its trainer and an activation source.

interfaces

Base config and interface shared by every PEAL sparse dictionary.

msae_decomposition

Wrapper around the MSAE (Matryoshka Sparse Autoencoder) release for PEAL.

orthogonal_procrustes_dictionary

Supervised concept dictionary fitted by orthogonal Procrustes analysis.

probe_sparse_autoencoder

Sparse dictionary made of the weight rows of a pretrained linear probe.

ra_sae_decomposition

Pretrained RA-SAE (Relaxed Archetypal SAE) dictionaries of DINOv2 token space.

sae_evaluation

Ground-truth evaluation of sparse dictionaries (SAE / MSAE / SVD-filtered).

singular_value_decomposition

Truncated SVD (PCA) as the simplest PEAL sparse dictionary.

sparse_dictionary_factory

Factory that builds a SparseDictionary from a config, path or instance.

splice_decomposition

SpLICE concept dictionary over CLIP image embeddings.

svd_filtered_sae

SVD-prefiltered sparse autoencoders.

utils

Plotting helpers for evaluating sparse dictionaries against known attributes.