Skip to content
Edit this page

Python API

The reference is generated from the docstrings. Each docstring states what the object is responsible for, the shapes it takes and returns, when it fails, and where its defaults come from.

Package What it holds Extra
muscari.data columns and prompts, deduplication, the held-out split, loading rows
muscari.encoding EncoderActivationSource: content-token states of a frozen encoder, streamed or collected
muscari.sae TopKSAE, the two trainers, the on-disk format, loading from a directory or the Hub saelens for the second trainer
muscari.analysis per-text and per-latent statistics, the loss recovered, the reranking probe, BM25 over latents
muscari.heads SAEPooling, VocabularyPooling, separate query and document encoders, the language-model head, decoder models retrieval
muscari.training losses, schedules and caps retrieval
muscari.evaluation reranking, retrieval, comparisons of runs, diagnostics retrieval

The names most often needed for SAE work are also importable from muscari itself:

from muscari import (
    EncoderActivationSource,
    TextColumn,
    TopKTrainer,
    TopKTrainerConfig,
    load_sae,
)

One vocabulary of names

Name Meaning Follows
prompt, prompts, prompt_name the text prepended to an input, and named prompts Sentence Transformers
query, document the two sides of retrieval Sentence Transformers (encode_query, encode_document)
kind what kind of text a text is, for statistics: its prompt, or a label this project
max_seq_length truncation length in tokens Sentence Transformers
include_prompt whether the prompt's tokens are pooled; off by default Sentence Transformers (Pooling)
model_name_or_path a Hub id or a local directory Sentence Transformers, Transformers
num_latents, k, d_in dictionary size, active latents per token, width of the activations Gao et al.