API reference

mllm-shap exposes a small, typed public surface. Import the symbols below from mllm_shap; the module pages document every class and function where it is defined.

Public exports

The table is generated from mllm_shap.__all__ at build time, so it always lists what from mllm_shap import ... accepts.

Symbol

Summary

AbsSumNormalizer

Scale attributions by the sum of absolute values.

ApiBackend

Generate text through an OpenAI-compatible /chat/completions endpoint.

ArchiveCorruptError

Raised when a run archive or its manifest cannot be read or parsed.

ArchiveExistsError

Raised when a run archive already exists and on_exists is "error".

ArchiveIncompleteError

Raised when reanalyze meets an archive of a run that did not finish.

ArchiveNotFoundError

Raised when a run archive lacks its manifest or SQLite database.

AudioPart

Audio content of a message, held in memory or referenced by path.

BackendUnavailableError

Raised when a configured generative backend cannot be reached.

BanzhafAggregator

Aggregate coalition samples with uniform Banzhaf coalition weights.

BertScoreValue

Score v(S) = F_1 of greedy token matching against y_N.

BetaShapleyAggregator

Aggregate coalition samples with Beta Shapley weights.

CoalitionMask

Boolean presence mask aligned with a player set.

CoalitionProgress

Sync hooks notified as coalition jobs are planned and finished.

ComplementaryEstimator

Sample complementary coalition pairs and aggregate CC attributions.

ConfigError

Raised when configuration values are invalid or inconsistent.

ContrastiveValue

Score v(S) = \\log p(t \\mid x_S) - \\log p(f \\mid x_S).

ConversationSnapshot

Frozen conversation state used as the explainability input.

CooperativeGame

Player set and reference values for a characteristic function.

CosineEmbeddingValue

Cosine similarity between sentence embeddings of two answers.

DeletePolicy

Remove absent players from the rendered conversation.

DeletionCurve

Value of the coalition left after removing the top-k players, per k.

Estimand

Supported cooperative-game value formulations.

ExactEstimator

Enumerate all coalitions and delegate attribution to an estimand plugin.

ExplainConfig

Top-level explain pipeline configuration.

ExplainResult

Attribution output for a single explain run.

ExplainRunOutput

Explain pipeline output including scheduler metrics.

ExplainRunner

Run the explain pipeline for a conversation snapshot.

GenerationRecord

Concrete generation output consumed by built-in value functions.

HierarchicalRunOutput

Both games of a hierarchical run.

IdentityNormalizer

Return attributions unchanged.

ImageBoxPartitioner

Make each box category of the first image a player, plus the background.

ImageGridPartitioner

Cut every image into a grid of cells, one player each.

ImagePart

Image content of a message, held in memory or referenced by path.

InMemoryObservabilitySink

Collect span records in memory for tests and diagnostics.

InfillPolicy

Replace absent players with the fills of a masked language model.

JudgeGradeValue

Score v(S) = \\sum_g g\\,p(g) for a judge’s grade distribution.

KernelBanzhafEstimator

Sample uniform complementary pairs and fit the Banzhaf regression.

LabelMarginValue

Score v(S) = \\log p(t \\mid x_S) - \\log \\sum_{l \\ne t} p(l \\mid x_S).

LeaveOneOutEstimator

Attribute v(N) - v(N - {i}) to player i from n + 1 coalitions.

LeverageEstimator

Sample complementary pairs by leverage and solve the Kernel SHAP regression.

LimeEstimator

Sample random subsets and fit the LIME surrogate on their payoffs.

LmStudioBackend

Generate text through a local LM Studio API server.

LogprobValue

Deprecated name of SelfLogprobValue, kept for one minor version.

LogprobsUnavailableError

Raised when a value function needs token logprobs a generation lacks.

ManifestVersionError

Raised when a run manifest or archive uses an unsupported schema version.

Message

One message of a conversation: a role and ordered content parts.

MessagePartitioner

Partition a snapshot into one player per non-empty message.

MinMaxNormalizer

Min-max scale to [0, 1] then normalize to sum one.

MllmShapError

Root of every error raised on purpose by mllm-shap.

MockAudioBackend

Echo text words and answer one token per voiced run of every audio part.

MockBackend

Hash-based generative backend with no external model dependencies.

MockImageBackend

Echo text words and answer one token per visible coloured square of an image.

MonteCarloEstimator

Sample random coalitions and delegate attribution to an estimand plugin.

NeutralPolicy

Replace absent players with neutral fillers that preserve their width.

NeymanEstimator

Two-phase complementary estimator with Neyman coalition-size allocation.

NliLogOddsValue

Score the log-odds that the two answers entail each other.

ObservabilitySink

Protocol for recording explain pipeline stage spans.

PadPolicy

Replace absent players with a fixed mask placeholder.

PairwiseInteractions

Order-2 interaction values between the players of one run.

PermutationEstimator

Sample orderings, evaluate their prefixes and delegate to the estimand.

PlayerSet

Ordered explainability players aligned with coalition masks.

PlayerSpan

Where one player sits in the conversation it was partitioned from.

PluginConflictError

Raised when a plugin name is registered twice without replace=True.

PluginContext

Inputs a plugin factory receives when the registry builds a plugin.

PluginGroup

Entry-point groups registered in packaging metadata.

PluginLoadError

Raised when a packaging entry point cannot be imported.

PluginNotFoundError

Raised when no plugin is registered under the requested group and name.

PluginRegistry

Register and resolve pipeline plugins by group and name.

PowerShiftNormalizer

Shift to non-negative values, apply a power, then scale to sum one.

ProxyEstimator

Leverage-sampled coalitions, a tree proxy, and a residual correction.

ReanalyzeMismatchError

Raised when reanalyze settings disagree with the archived run.

ReferenceWerValue

Score 1 - min(1, WER) of a coalition’s answer against a reference.

RemovalMetrics

Removal metrics of one ranking, read off one set of scored coalitions.

ReplayBackend

Serve archived coalition generations; compute misses with a fallback.

ReplayMissError

Raised when the replay backend is asked for a coalition no archive holds.

Role

Participant role attached to a message or token.

RunManifest

Top-level metadata persisted alongside a run archive.

SelfLogprobValue

Score a coalition by the model’s confidence in its own generation.

SemaScoreValue

Score a transcript by aligned segments weighted by their importance.

SentencePartitioner

Partition a snapshot into sentences, never crossing a blank line.

SgpaSegmentPartitioner

Make each spellable word of every audio message’s transcript a player.

ShapleyAggregator

Aggregate coalition samples with Shapley coalition weights.

SpeechBertScoreValue

Score v(S) as the SpeechBERTScore precision of the spoken answer.

TextPart

Text content of a message.

TfIdfCosineValue

Score generations with cosine similarity of frozen TF-IDF vectors.

TfJsdValue

Score v(S) = -\\sum_t \\mathrm{JSD}(P_N(\\cdot) \\Vert P_S(\\cdot)).

TfLogprobValue

Score \(v(S) = \\frac1\\ell\\sum_t \\log p(y_{N,t} \\mid y_{N,<t}, x_S)\).

TokenBarRenderer

Render attributions as a SHAP-style horizontal bar chart.

TokenPartitioner

Partition a snapshot into whitespace-delimited text tokens.

TokenTextRenderer

Render attributions as inline colored tokens.

TranscribedValue

Score spoken answers by transcribing them and applying a text value function.

TransformersTextBackend

Generate text with a local Hugging Face language model.

Turn

One conversational turn composed of ordered messages.

UniformSegmentPartitioner

Cut every audio message into equal-duration segments, one player each.

WeightedBanzhafAggregator

Aggregate coalition samples with weighted Banzhaf weights.

compute_removal_metrics

Return the removal metrics of a ranking from a coalition payoff function.

configure_logging

Configure the mllm_shap loggers from TOML or with one stderr handler.

default_registry

Return a registry with the built-in plugins and third-party entry points.

deletion_curve

Score snapshot with its k highest-attributed players removed at once.

display_attribution_html

Display colored token HTML when IPython is available.

explain_config_from_yaml

Parse YAML text into a validated ExplainConfig.

explain_config_to_yaml

Serialize a config to YAML with stable key ordering within sections.

explain_interactions

Score every coalition of snapshot and return its pairwise interactions.

image_removal_metrics

Score removal metrics of image players against area-matched random regions.

parse_manifest

Parse a JSON manifest payload into a run manifest.

removal_metrics

Score the removal metrics of attributions under config.

render_attribution

Render output attributions with a registered renderer plugin.

render_attribution_html

Return an HTML fragment for inline token coloring in Jupyter.

Modules

Package-level objects

Shapley-value attributions for conversational language models.

@domain core @see [[knowledge/architecture/core]]

mllm_shap.configure_logging(config_path: Path | str | None = None, level: int | str | None = None, json: bool = False) → Path | None[source]

Configure the mllm_shap loggers from TOML or with one stderr handler.

Without level and json the [tool.logging] section of a TOML file is applied. With either of them and no config_path, the package logger gets a single stderr handler instead (replacing earlier handlers) and stops propagating to the root logger (propagate=False), so records are not printed twice by a root handler; configure_logging(level="INFO") shows the pipeline’s stage events.

Parameters:
  • config_path – TOML file to read. Defaults to MLLM_SHAP_LOGGING_CONFIG or the nearest pyproject.toml above the working directory.

  • level – Level of the mllm_shap logger ("INFO", logging.DEBUG…); overrides the TOML level when both are given. Defaults to INFO for the stderr handler.

  • json – Emit one JSON object per record (time, level, logger, message) instead of plain lines. Only for the stderr handler.

Returns:

The TOML file that was read, or None when none was (a NullHandler is installed when neither a file nor level/json was given).

Raises:

ValueError – If json is combined with config_path; the TOML file defines its own formatters.

mllm_shap.__version__: str

Installed package version, read from the distribution metadata (0.0.0+unknown when the package is not installed).