Skip to content
Edit this page

Methods at a glance

The methods muscari has parts for, side by side: what each one does, what speaks for it and what it costs. If sparse retrieval is new to you, read What is learned sparse retrieval? first.

Three kinds of statement appear on this page and are kept apart. "The source reports" is what a paper, a model card or released code says, on its own models and data. "Here" is what this project measured, always on a small scale: 2,000 training steps of 16 queries on Japanese encoders, one benchmark. Everything else describes how the method works. Nothing on this page ranks the methods; the sources do not agree on a ranking and the runs here are too small for one.

What the methods share, and where they differ

Every method that trains a retriever builds the vector the same way and changes one or two of the steps (Latent Terms, which trains none, sums where the others take a maximum):

tokens → encoder → a score per dictionary entry, per token
                 → keep some of them      ReLU | shift and limit | top k
                 → saturate               log(1 + x) | nothing
                 → maximum over tokens    one weight per dictionary entry
Question The answers in use
What is the dictionary? the tokenizer's vocabulary; the latents of an SAE of the encoder's last layer; the latents of an SAE of an inner layer of a language model
What makes the vector sparse before training? nothing; a division of the head's weights; a shift and a limit per token; the SAE's Top-K
What does retrieval training update? the encoder and its head; the encoder alone, with the SAE frozen; the encoder and the SAE's encoder; low-rank adapters; nothing at all
What does it learn from? in-batch contrast; a cross-encoder's scores; both
What bounds the cost? a regulariser (FLOPS, L1); a cap at inference; training under caps

Overview

Method Dictionary Sparse at the start through Retrieval training updates Recipe Run here
SPLADE vocabulary nothing encoder and head japanese-splade-yast, shizuku-vocab collapsed on modernbert-ja-30m
Rescaled head vocabulary division of the head's weights encoder and head rescaled-splade nearly empty vectors
SPARSEUP vocabulary, spellings merged shift, limit per token encoder and head sparseup-v1, sparseup-v2, sparseup-cpt trained; three seeds
Frozen SAE head SAE latents Top-K encoder the script's defaults trained; three seeds
SAE-SPLADE SAE latents Top-K, 8 per token encoder and SAE encoder sae-splade one run, on a poor SAE
SlideOn SAE latents on unit-length states Top-K, 32 per token encoder, SAE encoder, a factor per latent slideon trained; one run
SPLARE SAE latents of an inner layer of a language model the SAE's own rule low-rank adapters splare random models only
Latent Terms SAE latents of a frozen retriever Top-K nothing: there is no retrieval training none; muscari probe-sae reranking with five SAEs

The last column points into the measurements. Read their conditions before reading anything into it.

Heads on the vocabulary

SPLADE

How it works. The language-model head scores every vocabulary entry at every token; log(1 + ReLU) and a maximum over the tokens give the vector. A ranking loss and a sparsity regulariser are trained together (Formal et al., arXiv 2107.05720). Later versions changed the pooling from a sum to a maximum, and then the loss and the negatives.

What speaks for it.

  • It needs nothing but an encoder that kept its language-model head, and Sentence Transformers supports it as it is.
  • Its dimensions are word pieces, so a vector can be read without any tool.
  • It has the longest record: published models, recipes and index integrations assume this shape.

What it costs.

  • Nothing makes the vector sparse at the start. Where the head gives most of the vocabulary a positive score, training begins with dense vectors and a loss thousands of times its chance value. Jang et al. and the SPARSEUP authors report failures on ModernBERT; here, plain SPLADE pooling collapsed on modernbert-ja-30m, and the recipes that pool the logits without a shift ended with empty or nearly empty vectors.
  • The regulariser weight has to make up for that, and published values do not carry over: in the recipes here they range from 2e-5 to 0.06, depending on the loss and the encoder.
  • The output has the size of the vocabulary, and the vocabulary belongs to the tokenizer.

In muscari. --head mlm is Sentence Transformers' pooling unchanged, kept for comparison. The two Japanese recipes are SPLADE with a treatment for noise tokens such as punctuation: a penalty on their weights (japanese-splade-yast) or a mask on their logits (shizuku-vocab). The losses and the diagnostics apply to it as to every head.

Rescaled head

How it works. Plain SPLADE, with the projection matrix of the language-model head divided by a constant before training (Jang et al., arXiv 2606.18811). The paper relates SPLADE's failure on some encoders to the length of that matrix's rows.

What speaks for it.

  • One number, applied once. The trained model is an ordinary SPLADE model with no extra module.
  • The source reports that ModernBERT goes from 0.127 to 0.405 nDCG@10 on BEIR-13 with a divisor of 8, under a contrastive loss alone.

What it costs.

  • The divisor differs per encoder (the paper tries 1, 2, 4, 8 and 16) and no rule is given; in the paper's own results a divisor that is too large ruins an encoder.
  • It does not make the start sparse. Here, on modernbert-ja-30m, whose rows are short to begin with, a fifth to a quarter of the vocabulary was still active per text after the division and training ended with six entries per query.
  • The source released no code.

In muscari. rescale_head, --head-divisor, the recipe rescaled-splade. --diagnose prints the row norm the paper refers to.

SPARSEUP

How it works. Three changes to SPLADE's pooling (Formal, Erbacher and Rulli, arXiv 2611.09680): a constant is subtracted from the logits before the ReLU, each token keeps only its largest few logits, and entries that differ in case or word-boundary marker are merged. The first version grafts a language-model head onto an encoder pre-trained for retrieval. The second adds contrastive pre-training of the sparse model itself, distillation from a cross-encoder and training under caps.

What speaks for it.

  • The vector is sparse at the first step, so training does not depend on the regulariser to get there. Here, the vocabulary recipes that trained on modernbert-ja-30m were the ones with the shift.
  • The dimensions stay word pieces.
  • The shift can be read off the data: --shift auto takes a quantile of the head's logits on your documents.
  • Training under caps is meant to keep accuracy when vectors are cut. In the single runs here, the second version scored 0.849 against the first version's 0.828 with both vectors capped at 64 weights, and about the same without a cap; a difference of that size between single runs is not established.
  • The source reports results above SPLADE-v3 on BEIR-13, and released the models of both versions together with a checkpoint that has only been pre-trained, as a starting point for others. All of them are English.

What it costs.

  • The shift belongs to the encoder: 15 for the paper's encoders, about 19 on modernbert-ja-30m and 9.8 on modernbert-ja-310m here. A value copied from elsewhere can leave the vector dense or empty.
  • The training code is not public, and the paper leaves out the batch size, the learning rate and the number of steps. The recipes fill those in and say so.
  • Merging spellings does nothing for a script without case and a tokenizer without boundary markers, Japanese among them.
  • The part the paper credits with the largest gain, pre-training the sparse model, took its authors about 3.5 days on four H100 GPUs. Nothing of that size has run here.
  • With vectors capped at 64 and 256 weights, the vocabulary head lost more than the SAE head on the 310M encoder here.

In muscari. VocabularyPooling and build_vocabulary_encoder (guide), graft_head, MatryoshkaCaps, three recipes.

Heads on an SAE

All of these need an SAE first: published, imported or trained. The 65,536-latent SAE this project publishes took 6.6 hours on one RTX 4090 for one billion tokens.

Frozen SAE head

How it works. A Top-K SAE is trained on the last hidden states of the encoder. Its encoder half then takes the place of the language-model head: each token keeps k latents, log(1 + x) and a maximum over the tokens give the vector. Retrieval training updates the transformer and leaves the SAE as it is. This is the setting the model card of Shizuku's SAE retriever describes, and the default of muscari's training script.

What speaks for it.

  • It is sparse by construction, from the first step and on any encoder. Here it trained stably where plain SPLADE pooling collapsed, with no shift to estimate.
  • The size of the dictionary is a choice, not a property of the tokenizer.
  • Before any retrieval training the model already ranks, and the SAE can be measured and inspected on its own: which latents are frequent, what each fires on, why two texts match.
  • One SAE serves every retriever trained on that encoder.
  • Here, on modernbert-ja-310m with a 65,536-latent SAE, it was level with the shifted vocabulary head without a cap and 0.016 nDCG@10 ahead with vectors capped at 64 and 256 weights (one seed), with about half the non-zero weights per document.

What it costs.

  • The SAE has to be good enough. Here, a small one (8,192 latents, 30 million tokens) on modernbert-ja-30m was 0.08 nDCG@10 behind the vocabulary head on the test queries.
  • A latent has no name. Reading a match takes shared_latents or inspect-sae, and the latents of the published SAE have not been labelled.
  • Some latents are active in most texts and behave like stop words: 72 of 65,536 were active in more than half of the documents of one benchmark here.
  • The SAE belongs to one encoder and one layer, and the head should run in float32: bfloat16 autocast lowered it clearly in one comparison here.

In muscari. muscari train-sae, SAEPooling, build_sparse_encoder (guide).

SAE-SPLADE

How it works. As above, but the SAE's encoder is trained along with the transformer in the retrieval stage, each token keeps 8 latents (the paper also reports 4 and 16), and the model learns from a teacher's scores alone (Zong et al., arXiv 2604.21511).

What speaks for it.

  • The source reports the effectiveness of its own SPLADE baseline at about half the FLOPS, on DistilBERT.
  • The number of latents per token is a single, direct setting for the size of the vectors.

What it costs.

  • The same paper's ablation gives the language-model head a limit of 8 entries per token and finds nearly the same effectiveness and cost. What the SAE adds over a limit per token is therefore open.
  • It depends on the SAE and on the scale of the teacher's scores. Here, on an SAE that left half of the variance unexplained, the run ended below the untrained model, with the MarginMSE term seven times the KL term at the start.
  • The source's encoders are DistilBERT and BERT; whether the SAE's encoder is trained is stated by its code, not its text.

In muscari. trainable=True and k=8 on SAEPooling, --margin-mse-weight, the recipe sae-splade.

SlideOn

How it works. LightOn's SAE retriever (code): the SAE is trained on token states scaled to unit length, each token keeps 32 latents, the activations are pooled without a logarithm and multiplied by a trained factor per latent. Training combines a contrastive loss and distillation under several caps, with a term that keeps the latents evenly used.

What speaks for it.

  • Its code, its training configuration and its weights are all public, so the recipe copies code and not a description.
  • It trained here on an encoder it was not written for.
  • It is trained for capped vectors: in the run here the vectors capped at 64 and 256 weights scored higher than the uncapped ones.

What it costs.

  • Its vectors are large: 479 non-zero weights per query and 1,283 per document in the run here, against 66 and 274 for sparseup-v1 under the same conditions.
  • It has the most parts to set: the temperatures of two losses, a regulariser and its warm-up, a load-balance weight and the caps.
  • The source starts from LightOn's own retrieval encoder, whose token states pass through a projection. The recipe takes the hidden states of whatever encoder you give it.

In muscari. train-sae --normalize-inputs, saturation="none", latent_gate=True, LoadBalancedSpladeLoss, MatryoshkaCaps, the recipe slideon.

SPLARE

How it works. The dictionary is a published SAE of an inner layer of a decoder language model. The model is cut after that layer, given bidirectional attention and trained through low-rank adapters to match a cross-encoder's scores; the SAE stays frozen (Formal and Louis, arXiv 2603.13277).

What speaks for it.

  • No SAE has to be trained: language models come with published ones (Llama Scope, Gemma Scope, Qwen-Scope).
  • The latents are not the word pieces of one language. The source reports gains over a vocabulary head on the same language model for multilingual retrieval, and about the same results in English.
  • The vectors are sized by a cap at inference (40 weights for a query, 400 for a document) and not by tuning a regulariser.

What it costs.

  • A language model of several billion parameters runs for every query.
  • The source reports results below the vocabulary head on code retrieval and, when trained on English data only, on chemistry.
  • The distillation temperature was found by a grid search per model and SAE (80 and 50 for its two SAEs, 10 for a vocabulary head), and the paper notes that a wrong one can make training diverge.
  • No code was released, and this project found no released weights. Published SAEs carry their own terms of use.

In muscari. muscari import-sae, DecoderTransformer, --bidirectional, --lora-rank, examples/adapt_bidirectional.py, the recipe splare (guide). These parts have run on randomly initialised models only.

Without retrieval training

Latent Terms

How it works. A Top-K SAE is trained on the token states of a frozen retriever, and its latents are used as the terms of an ordinary BM25 index (Clavié, Lee, Shakir and Kato, arXiv 2605.29384). The activations of a text's tokens are summed per latent and passed through a square root; a document's weights take the place of term frequencies, and BM25 supplies the rest: IDF, saturation and length normalisation. No retrieval model is trained.

What speaks for it.

  • The only training is the SAE's. The encoder stays as it is, so one forward pass of a dense retriever you already serve gives its embedding and its terms.
  • The index is a BM25 index, with the statistics a search engine keeps anyway.
  • The source reports rankings near those of the retriever the terms come from: above it for one retriever, level for another, below a late-interaction model.
  • Here, on SAEs of the ruri-v3 retrievers, BM25 over the summed activations ranked 0.04 to 0.06 nDCG@10 above the maximum-pooled vectors with IDF, without anything trained. The gain came from the length normalisation.

What it costs.

  • It needs an encoder that was trained for retrieval. The source reports far lower results for an untuned BERT, and here the SAEs of the two modernbert-ja encoders, which are not retrievers, ranked clearly lower than those of the ruri-v3 encoders (0.42 and 0.45 against 0.56 to 0.62).
  • Here it stayed below the dense ranking of the same retriever on all three ruri-v3 encoders, for example 0.577 against 0.584 on ruri-v3-30m and 0.617 against 0.680 on ruri-v3-310m.
  • The paper's IDF is negative for a latent that is active in more than half of the documents, which a word rarely is and a latent can be. On one SAE here that put BM25 0.11 below the ranking it should improve; muscari defaults to an IDF that is never negative.
  • The score is not a dot product: it needs the statistics of the collection, and the paper does not define the length of a document. Here it is the sum of the document's weights.

In muscari. A scoring, not a head. muscari probe-sae reports it as sparse.bm25 next to the maximum-pooled rankings, with the options --bm25-k1, --bm25-b, --bm25-transform and --bm25-idf (guide); LatentTermBM25 in muscari.analysis is the class behind it. It reranks the candidates of a benchmark. muscari builds no BM25 index of latents and has no SparseEncoder module for it; the trained heads above start from the maximum, not from BM25.

Options that apply to every head

Option What it does Where it comes from Seen here
Scale of the contrastive loss, --loss-scale multiplies the scores before the softmax SPARSEUP trains with a temperature of 6 mattered more than any other setting tried: 0.2 instead of 1 raised both heads
Distillation: KL, MarginMSE, soft labels learns from a cross-encoder's scores, alone or next to the contrastive loss SPLADE's later versions, SAE-SPLADE, SlideOn, YAST +0.015 on the test queries for the SAE head; for the vocabulary head a gain under caps only
Caps, and training under them (MatryoshkaCaps) keeps the largest weights of each vector; trains several sizes at once SPARSEUP's second version, SlideOn see the two recipes above
A smaller encoder for queries documents through a large encoder, queries through a small one Lassance and Clinchant one small run: with a vocabulary head 0.05 nDCG@10 lower and a fifth of the CPU time per query; the SAE variant did not converge
Noise tokens, merged spellings keeps punctuation and the like out of the vectors YAST, Shizuku, SPARSEUP part of the recipes that use them
Masked latents removes chosen SAE latents from the vectors this project without training: FLOPS from 35 to 18 with 72 latents masked, nDCG@10 from 0.470 to 0.481; with a trained retriever: FLOPS from 6.1 to 3.6 with 101 masked, nDCG@10 unchanged
Probability threshold (experimental) thresholds a token's probabilities instead of its logits this project ahead of the shift on the 30M encoder, behind it on the 310M one
Capacity (experimental) limits the share of texts an entry may appear in this project about half the FLOPS at the same accuracy on the 30M encoder

Where to start

These are starting points drawn from the small runs above, not recommendations with evidence behind them at scale.

  • An encoder with its language-model head, and no SAE. Start with the shifted vocabulary head: examples/train_vocabulary_head.py, or the recipe sparseup-v1. It needs the least preparation and its vectors can be read as words.
  • An encoder that has a published SAE, or the budget to train one. Try the frozen SAE head next to it, in float32. Look at the SAE first with probe-sae: it shows how the untrained model ranks and which latents are too frequent.
  • Vectors that must be small. Train under caps, with either head, and compare at the cap you will serve: in the runs here the gap between the two heads was not the same with and without a cap.
  • A decoder language model. The SPLARE parts are in place and unmeasured.
  • In every case, run --diagnose before training. It shows the density of the vectors and the size of the loss at the start, which is where each failure on this page was visible before the first update.