Recipes¶
A recipe is a file of options for examples/train_retriever that copies the published settings of one method. Every line names the setting of the source it copies; a line marked "ours" is a choice the source does not make. A recipe states where its values come from. It does not promise a good model: the values were chosen for the sources' encoders, data and teachers, and published values for the same quantity differ by orders of magnitude between sources. Measure before you trust one; --diagnose reports the quantities these settings act on.
Run a recipe by naming its file with @ and adding what is yours. Options given after the file override it:
python examples/train_retriever @examples/train_retriever/recipes/slideon.args \
--sae runs/sae --out runs/retriever \
--dataset your/dataset \
--query-column query --positive-column positive --negative-column negatives \
--positive-score-column positive_score --negative-score-column negative_scores \
--max-steps 2000 --regularizer-warmup 0.3
The scores must be a teacher's logits; --teacher-probabilities converts scores between 0 and 1. A file may hold several options per line, and # starts a comment.
| Recipe | Source | Read from | Measured in this project |
|---|---|---|---|
slideon.args |
LightOn, SlideOn | code and training config at commit cf7c2bd of lightonai/slideon-mslideon |
one small run |
sae-splade.args |
Zong et al., SAE-SPLADE, arXiv 2604.21511v2 | the paper (Section 4.1) and the code at commit 2056602 of yzong12138/sae_splade |
one small run |
sparseup-v1.args |
Formal, Erbacher and Rulli, SPARSEUP, arXiv 2611.09680v2 | the paper (Sections 2 and 3.1) and the code of the released model | one small run |
sparseup-v2.args |
the same paper | Sections 4.2 and 4.3 | one small run |
sparseup-cpt.args |
the same paper | Section 4.1 | nothing |
rescaled-splade.args |
Jang et al., arXiv 2606.18811 | the paper (Sections 3.2 and 4.1); no code was released | one small run |
japanese-splade-yast.args |
hotchpotch, YAST and japanese-splade-base-v1 | configuration and trainer at commit 5401c6c of hotchpotch/yast |
one small run |
shizuku-vocab.args |
mahiyama, splade-ja-310m | the model card; the training code is not public | one small run |
splare.args |
Formal and Louis, SPLARE, arXiv 2603.13277v1 | the paper; no code was released | nothing |
"Read" means read: none of these code bases was run here. Each recipe is trained for three steps on a randomly initialised two-layer BERT by the automated tests, which shows that the options fit together and nothing about quality.
SlideOn¶
An SAE on unit-length token states is trained first, then the encoder and the SAE's encoder half are trained together for retrieval.
What the recipe copies: 32 latents kept per token, no log on the activations, a trained factor per latent, a contrastive loss at temperature 0.02 and the KL divergence to a teacher on the same scores with weight 1, both averaged over six pairs of caps (queries 32, 64, 128; documents 512, 1024), the load-balance term at 0.01, FLOPS at 0.01 on both sides rising quadratically over the first 3,000 steps, and the optimiser settings.
What differs:
- The source pools the tokens of the prompt and leaves a list of punctuation tokens out of documents. Here the prompt's tokens are left out and no token list is applied.
- The source builds its global batch of 128 from batches of 4 on several devices. Here it is 4 with 32 accumulation steps on one device. In both, a query's in-batch negatives come from its own batch of 4.
- The warmup of the regulariser is a share of the steps here.
0.1222is 3,000 of the source's 24,544 steps; change it with--max-steps. - The number of hard negatives per query comes from the source's dataset; 7 is this recipe's choice.
- SlideOn starts from LightOn's own retrieval encoder, whose token states pass through a projection. The recipe uses the final hidden states of whatever encoder you give it.
The SAE of the source: 32,768 latents, k 32, AuxK with 1,024 latents and coefficient 1/16, batches of 4,096 tokens, learning rate 3e-4 with 5% warmup and cosine decay, three passes over the tokens, a latent counted as dead after 2,500 steps, unit-length inputs, bfloat16. With muscari:
muscari train-sae --model YOUR_ENCODER --dataset ... --columns ... --out runs/sae \
--normalize-inputs --num-latents 32768 --k 32 --aux-k 1024 --aux-coef 0.0625 \
--batch-tokens 4096 --lr 3e-4 --warmup-frac 0.05 --dead-after-tokens 10240000 --amp \
--total-tokens THREE_PASSES_OVER_YOUR_TOKENS
The source initialises the decoder from token states of its data; muscari starts from random unit vectors. muscari's SAE is trained on content tokens only, while the recipe's head pools the special tokens as the source does; leave --pool-special-tokens out to keep the two consistent.
SAE-SPLADE¶
A Top-K SAE on the final hidden states replaces the language-model head of SPLADE. The model is trained on a teacher's scores alone, without in-batch negatives.
What the recipe copies: 8 latents kept per token (the paper also reports 4 and 16), log(1 + x) on the pooled activations, the KL divergence with weight 1 plus MarginMSE with weight 0.05, FLOPS at 0.04 for documents and 0.06 for queries rising over the first 6,000 steps, learning rate 2e-5 with 10,000 warmup steps, batches of 32 queries with 8 hard negatives, 240,000 steps.
What differs or is not settled by the sources:
- The paper does not say whether the SAE's encoder is trained in the retrieval stage. In the code the optimiser covers every parameter and none is frozen, so the recipe trains it.
- The paper's queries are cut at 32 tokens and its documents at 256. The script has one limit.
- The source uses 16-bit floats; the recipe uses bfloat16. Add
--no-bf16for 32-bit floats. - The paper names its data as the ColBERTv2 distillation set and does not name the teacher. The config's
nwayis 8; whether that counts the positive was not checked. - The shape of the regulariser's warmup was not checked. Here it is quadratic.
The SAE of the source: 65,536 latents, k 8, trained on the tokens of the 8.8 million MS MARCO documents, documents only, for 160,000 steps of 768 documents with learning rate 5e-5, Adam epsilon 6e-10, 10,000 warmup steps, weight decay 0.01 and an auxiliary loss with coefficient 1/16 over 512 latents, without input normalisation. With muscari:
muscari train-sae --model distilbert/distilbert-base-uncased \
--dataset ... --columns ... --out runs/sae \
--num-latents 65536 --k 8 --aux-k 512 --aux-coef 0.0625 \
--lr 5e-5 --adam-eps 6e-10 --warmup-frac 0.0625
muscari counts a batch in tokens and has no weight decay for the SAE; set --batch-tokens and --total-tokens for your data. As above, muscari's SAE is trained on content tokens only.
The paper's Table 4 is worth reading before choosing this head: the language-model head of SPLADE with the same limit of 8 entries per token reaches nearly the same effectiveness and cost as the SAE head on its benchmarks. In muscari that is --head vocab --fan-out 8.
SPARSEUP¶
A vocabulary head on a modern encoder, made sparse at the start of training by three changes to SPLADE's pooling: a shift subtracted from the logits, a limit on the logits kept per position, and the merging of entries that differ in case or word-boundary marker.
What sparseup-v1.args copies: the shift at the 99.9th percentile of the head's logits (the paper's encoders give 15), 12 logits per position, folding, InfoNCE at temperature 6, FLOPS at 1e-3 on both sides, seven hard negatives.
What the paper does not state: batch size, learning rate, number of steps, precision, the schedule of the regulariser, and which tokens are pooled. The released model pools every attended token except the prompt's, which the file follows. Everything else is the script's default.
The source does not start from a masked-language model. It takes a contrastively pre-trained encoder and grafts ModernBERT's head onto it:
The grafted head has never seen that encoder's hidden states, so estimate the shift on the grafted model (--shift auto does) and look at --diagnose before training.
sparseup-v2.args adds two of the three additions of the paper's second version: the KL divergence to a cross-encoder (the paper names mxbai-rerank-large-v2 and does not give the weight) and training under the caps 16/64, 32/128, 64/256 and none, weighted 0.05, 0.08, 0.1 and 0.8. The third, contrastive pre-training of the sparse model on hundreds of millions of pairs with batches of 16,000, is a stage of its own that the paper reports at about 3.5 days on four H100 GPUs.
For a script without case and a tokenizer whose entries carry no boundary marker, folding merges nothing.
Pre-training the sparse model¶
sparseup-cpt.args is that third addition as far as the paper describes it: the same contrastive objective as fine-tuning, on weakly supervised pairs without hard negatives, with batches of 16,000 pairs that GradCache makes fit in memory, starting from the masked-language model. The paper reports about 3 points of nDCG@10 on BEIR-13 over the model without this stage when a quarter of the data is used. Temperature, regulariser, number of steps and whether the shift and the fan-out are active are not stated; the file fills them with the values of fine-tuning and says so line by line.
Two limits of the script matter at this scale. It reads the rows it will use into memory before training (--max-steps times --batch-size), and it runs on one device. A batch of 16,384 in pieces of 64 is 256 forward passes without gradients and 256 with them per step. The result is a model directory; the fine-tuning recipes take it as --model.
No other pre-training method needs support of its own here: an encoder that was pre-trained elsewhere for retrieval (the paper compares against one) is just another --model, with a head grafted on if it was saved without one.
Rescaled SPLADE¶
Plain SPLADE with the head's projection matrix divided by a constant before training. The paper reports that encoders whose projection rows are long fail with a standard recipe and recover with the division: ModernBERT goes from 0.127 to 0.405 nDCG@10 on BEIR-13 with a divisor of 8.
What the recipe copies: the division, the contrastive loss at temperature 1, FLOPS at 5e-2 for queries and 3e-3 for documents rising quadratically over the first third, learning rate 1e-4 with 10% warmup and linear decay, batches of 64 per GPU, length 256, one hard negative, bfloat16.
What differs: the source trains on eight GPUs with 64 queries on each, and does not say whether negatives are shared between them. The divisor is the recipe's guess for a ModernBERT-like head; the paper tries 1, 2, 4, 8 and 16 per encoder and gives no rule. --diagnose prints the mean row norm that the paper relates to the failure. The paper does not say whether the bias is divided; here it is not. With tied weights the input embeddings are divided too, as in the paper.
Japanese SPLADE (YAST)¶
The first of hotchpotch's Japanese SPLADE models. A query is scored against its own positive and seven hard negatives, and the loss is the cross-entropy against the scores of two rerankers, averaged and used as soft labels.
What the recipe copies: that loss, L1 on queries (0.0025) and on documents (0.001) rising quadratically over the first 10% of the steps, the penalty on noise tokens with weight 1, learning rate 2e-5 with cosine decay, batches of 4 with 8 accumulation steps, length 512, bfloat16.
What differs:
- The source lists its 319 noise tokens by hand for the vocabulary of
tohoku-nlp/bert-base-japanese-v3, small kana and iteration marks among them. Here noise tokens are found by form (punctuation, symbols, special tokens); add others with--noise-extra. - The source's data loader keeps, by default, only positives that the rerankers score at 0.7 or more and negatives at 0.3 or less. The script does not filter rows by score.
- The later models of the same author change the recipe: the second version uses FLOPS for documents, larger weights (0.35 and 0.15), a KL term next to the cross-entropy, and Adafactor.
Shizuku vocabulary model¶
Stage 1 of the six stages on the model card: plain SPLADE pooling on sbintuitions/modernbert-ja-310m, trained with the contrastive loss and FLOPS, with noise tokens masked out of the logits.
What the recipe copies: learning rate 1.5e-5 with 10% warmup, batches of 64 encoded in pieces of 32, FLOPS at 2e-5 for queries and 1.5e-4 for documents rising quadratically over 40% of the steps, length 512, 200,000 triplets for one epoch, bfloat16, and the mask.
What differs or is not on the card: the temperature of the loss is not stated (the default of the library is assumed). The card adds words of its corpus to the mask by hand and, from the second stage on, words found in evaluation output. After training the card writes the mask into the head's bias, so that the model loads as a plain SPLADE model:
The later stages lower the learning rate (5e-6 down to 5e-7) and the regulariser weights and train on other amounts of data; each starts from the best checkpoint of the stage before.
SPLARE¶
A published SAE of an inner layer of a decoder language model supplies the dimensions. The SAE stays frozen; the language model, cut after that layer and given bidirectional attention, is trained through low-rank adapters to match the scores of a cross-encoder.
What the recipe copies: log(1 + ReLU) of the SAE's latents with a maximum over all positions, bidirectional attention, adapters of rank 64, the KL divergence to the teacher with a temperature of 80 on the model's scores only (the paper's value for Llama Scope; 50 for Gemma Scope, 10 for a vocabulary head, found by a grid search), FLOPS at 1e-4 on both sides, 8 negatives, learning rate 5e-5 with 1% warmup, length 128. The paper prunes the vectors at inference to 40 entries for queries and 400 for documents; evaluate with --caps 40/400.
What differs or is not in the paper:
- Before retrieval training the paper adapts the model to bidirectional attention with masked next-token prediction, 20% of the tokens for 10,000 steps. The recipe file does not include that stage.
examples/adapt_bidirectional.pyruns it and saves a model that the recipe takes as--model; its learning rate, batch size and adapter settings are not from the paper (the adapter settings are LLM2Vec's). - The alpha, the dropout and the target modules of the adapters are not stated. Here alpha equals the rank, dropout is 0, and the targets are peft's defaults for the architecture, or
--lora-targets. - The paper reports a batch of 128 "with gradient accumulation"; the split into 16 times 8 is the recipe's.
- The paper does not say whether the SAE's own activation rule is applied or whether its decoder bias is subtracted. Here the head keeps the SAE's own number of latents per token (
--sae-kchanges it) and uses the encoder exactly as the SAE's card computes it. - The temperature was tuned for its models and SAEs. The paper notes that an unsuitable one can make training diverge;
--diagnoseshows the teacher's scores and the model's at the start.
The paper uses Llama-3.1-8B with Llama Scope at layer 26. The parts here do not depend on the model. An example with a smaller pair, Qwen3-1.7B-Base and the Qwen-Scope SAEs (arXiv 2605.11887; its Table 1 lists the repositories, one file per layer):
pip install peft # or the llm extra
# layerN.sae.pt holds the SAE of the output of block N: --layer N+1
muscari import-sae --weights layer13.sae.pt --layout qwen-scope --layer 14 --k 50 \
--base-model Qwen/Qwen3-1.7B-Base --max-seq-length 512 --out runs/qwen-scope-13
# optional, the paper's first stage: adapt the model to bidirectional attention
python examples/adapt_bidirectional.py --model Qwen/Qwen3-1.7B-Base \
--data-files corpus.txt \
--lora-targets q_proj k_proj v_proj o_proj --out runs/qwen3-bidirectional
python examples/train_retriever @examples/train_retriever/recipes/splare.args \
--sae runs/qwen-scope-13 \
--model runs/qwen3-bidirectional \
--lora-targets q_proj k_proj v_proj o_proj --out runs/splare \
--data-files train.jsonl \
--query-column query --positive-column positive --negative-column negatives \
--positive-score-column positive_score --negative-score-column negative_scores
Which layer to take is not something the paper settles for other models (it uses layer 26 of 32, and layer 6 for a smaller variant); block 13 above is a placeholder. The Qwen-Scope files are pickled dictionaries of tensors, read with torch.load(weights_only=True). Their cards carry terms of use and some of the repositories a licence of their own, not Apache-2.0: read them before training or publishing a model built on one.
Qwen3.5-2B-Base has Qwen-Scope SAEs too, but three of every four of its blocks are linear-attention blocks (Gated DeltaNet), which read a text from left to right whatever mask they are given. Bidirectional attention then reaches only the remaining blocks, so the paper's setting cannot be copied; --no-bidirectional after the recipe file trains it as a left-to-right model, which is a different method from the paper's and has not been tried here. Loaded with the generic model class it comes with its vision tower, which the head ignores.