Skip to content
Edit this page

Differences from the sources

The topk trainer follows Gao et al. for its mechanics and the model card of the SAE behind the Shizuku models for its defaults. This page lists where it departs from each.

Gao et al.

The paper was read in its arXiv v1 HTML form (Sections 2.1 to 2.4, Appendices A and B), and the reference implementation in sparse_autoencoder/train.py.

Aspect Gao et al. topk trainer
Input preprocessing subtract the mean over dimensions, scale each activation to unit norm none by default. --normalize-inputs scales each activation to unit norm and leaves the mean to b_dec; the retrieval head then scales its token states the same way
Learning rate constant 5% warmup, cosine decay (SAE model card of Shizuku)
Weight averaging EMA, 0.999 none
Adam epsilon 6.25e-10 PyTorch default 1e-8, configurable
aux_k typically 512, a power of two near half the width 256 (model card; also the default of the reference code)
aux_coef 1/32 1/32
Dead threshold 10 million tokens 10 million tokens
Dead bookkeeping (reference code) in steps, pre-activation above 1e-3 in tokens, activation above 0
Main loss scale (reference code) MSE times a fixed inverse variance from a sample MSE over the variance of each batch
Encoder rescaling at initialisation applied; the paper's ablation reports no effect or a weak negative effect applied
Batch size 131,072 tokens 8,192 tokens (model card)
Scale-out sharded over GPUs with custom kernels one device

Running with the settings of the Shizuku SAE card

The model card of the SAE used by Shizuku states the following, and the defaults of the topk trainer match all of it:

  • the final-layer last_hidden_state of a frozen sbintuitions/modernbert-ja-310m;
  • 65,536 latents, Top-K with k = 16, AuxK with 256 latents and coefficient 1/32;
  • Adam with betas 0.9 and 0.999 at 5e-4, warmup over the first 5% and cosine decay;
  • batches of 8,192 tokens, a maximum length of 1,024 and one billion training tokens;
  • deduplicated queries and documents, with 5% held out;
  • the tensor names, shapes and the folding of the decoder bias in the saved file.
muscari train-sae \
  --trainer topk \
  --model sbintuitions/modernbert-ja-310m \
  --data-files corpus.jsonl \
  --columns query document \
  --out runs/modernbert-ja-310m-sae

Three things the card describes are outside this command:

  • The data. The card lists about 846 million tokens (70.1% documents, 14.9% queries, 14.9% Wikipedia articles) from mqa-ja, auto-wiki-qa, Japanese Wikipedia, mmarco-ja and smaller sets, some of them not public, with items that overlap certain evaluation sets removed. muscari ships no recipe for this corpus.
  • The model revision. The card names revision 77675fc; pass the full commit hash with --revision.
  • The evaluation. The card reports an FVU of 0.155 on 2 million held-out document tokens, an MLM loss recovery of 0.944 and no feature unused over the last 10 million training tokens. muscari reports all three in its own form; the MLM loss recovery comes from eval-sae --mlm-texts, whose masking rate and texts are muscari's choice because the card states neither.

Everything the card does not state (initialisation, the dead-latent threshold, shuffling, the loss normalisation, input normalisation, the training library) is muscari's own choice, mostly following Gao et al. The result is therefore a run with a published recipe, not a reproduction of that SAE. The saved tensors have the same layout as the card's file; loading one as the other has not been tried.