Sae.load_from_hub method as follows:Sae.load_many:load_many is guaranteed to be naturally sorted by the name of the hook point. For the common case where the hook points are named embed_tokens, layers.0, ..., layers.n, this means that the SAEs will be sorted by layer number. We can then gather the SAE activations for a model forward pass as follows:EleutherAI/SmolLM2-135M-10B dataset for training, but you can use any dataset from the HuggingFace Hub, or any local dataset in HuggingFace format (the string is passed to load_dataset from the datasets library).TrainConfig class. You can see them by running python -m sparsify --help.finetune argument.h.0.ln_1) but also allow Unix pattern matching syntax, including wildcards and character sets. For example, to train SAEs on the output of every attention module and the inner activations of every MLP in GPT-2, you can use the following code:expansion_factor option is used to select the appropriate number of latents for each hookpoint based on the width of that hookpoint's output. The default learning rate for each hookpoint is then set using an inverse square root scaling law based on the number of latents. If you manually set the number of latents or the learning rate, it will be applied to all hookpoints.torchrun command. By default we use the Distributed Data Parallel method, which means that the weights of each SAE are replicated on every GPU.--distribute_modules flag, which allocates the SAEs for different layers to different GPUs. Currently, we require that the number of GPUs evenly divides the number of layers you're training SAEs for.bitsandbytes. This command requires no more than 48GB of memory per GPU on an 8 GPU node.pip install eai-sparsifypip install -e .[dev] from the sparsify directory.bash python -m sparsify gpt2 --hookpoints "h.*.attn" "h.*.mlp.act" --k_decay_steps 10_000bash python -m sparsify gpt2 --hookpoints "h.*.attn" "h.*.mlp.act" --activation groupmaxbash python -m sparsify gpt2 --hookpoints "h.*.attn" "h.*.mlp.act" --loss_fn cebash python -m sparsify gpt2 --hookpoints "h.*.attn" "h.*.mlp.act" --loss_fn klPosted Sep 9, 2025
Developed a library for training k-sparse autoencoders on HuggingFace models.
0
0
Mar 1, 2025 - Sep 3, 2025

EleutherAI