Skip to content
Edit this page

Command line

muscari --help lists the commands; muscari <command> --help lists every option of one. A command is imported only when it is used, so the SAE commands run with the base install and the retriever commands need the retrieval extra.

Command What it does Guide
muscari train-sae streams texts through a frozen encoder, trains an SAE on the token activations, exports it and evaluates it on held-out texts Train an SAE
muscari eval-sae measures an exported SAE on any texts; with --mlm-texts, the masked-language-model loss recovered Evaluate and inspect
muscari inspect-sae lists, for every latent, how often it fires, where in a text and on which tokens Evaluate and inspect
muscari probe-sae reranks a reranking dataset with the frozen encoder and the SAE, with nothing trained Evaluate and inspect
muscari import-sae wraps the weights of a Top-K SAE trained elsewhere in muscari's format Use an SAE trained elsewhere
muscari eval-retriever reranks and retrieves with any SparseEncoder, at several caps on the vector size Evaluate a retriever
muscari compare-runs compares two sets of evaluation results on the same queries, with intervals over runs and queries Evaluate a retriever
muscari graft-head saves a masked-language model with the encoder of one checkpoint and the head of another Build a retriever on the vocabulary

Options that recur

The same names mean the same thing in every command, in the Python API and in the saved files. They follow Sentence Transformers where it has a name for the thing.

Option Meaning
--model a Hugging Face Hub id or a local directory
--sae a local directory or a Hub repository with sae.safetensors and sae_config.json
--columns name[:label][=prompt] a dataset column to read, the prompt the encoder expects for its texts, and optionally a label for the kind of text
--query-prompt, --document-prompt the text prepended to queries and to documents
--query-column, --document-column the columns of a reranking dataset
--max-seq-length truncation length in tokens, special tokens included
--include-prompt also use the tokens of the prompt, which are left out by default
--caps QUERY/DOCUMENT keep that many of the largest weights of a query and of a document vector; full keeps all
--seed, --device, --out the seed, the device (auto, cpu, cuda, mps) and where the result goes

Kinds of text

Statistics are reported per kind of text, for example separately for queries and documents. A column's kind is its prompt, or its label if it has one:

# an encoder with prompts: the prompt tells the kinds apart
--columns "anc=検索クエリ: " "pos=検索文書: "

# an encoder without prompts: label the columns instead
--columns "anc:query=" "pos:document="