Examples

Runnable Jupyter notebooks from examples/, rendered with their stored outputs. Install with pip install mllm-shap (or make install in a clone). make notebooks re-executes them all; make kernel registers the project environment as the mllm-shap (uv) kernel. Each row links to the rendered notebook and its source; the catalog is also in examples/README.md.

Notebooks

Notebook

What it demonstrates

Extras

Source

Explain a conversation with ExplainRunner

ExplainRunner end to end: snapshot JSON, player spans, YAML config and its guards, the efficiency check, to_dict(), every estimator and estimand, progress, spans and logging

none

GitHub

Run archives and reanalyze

Archives and on_exists; reanalyze() reproducing explain and rescoring with every value function and normalizer; archive errors and strict=True

none

GitHub

Command line: mllm-shap

Every subcommand, JSON and PNG output, exit codes 0, 2 and 3

[viz]

GitHub

Plugins: registry, context and options

default_registry(), PluginContext, plugin_options validation, a custom backend and value function, conflicts and entry points

none

GitHub

Shapley vs Banzhaf on toy cooperative games

Shapley and Banzhaf on majority and additive games; result labels and the RunManifest wire format

none

GitHub

Coalition masking and absence policies

Token partition, absence policies, MaskedSnapshot, MaskCodec, MaskSpace, image players

none

GitHub

Runtime archive, deduplication, and async scheduling

Archives, dedup keys, the hot store and InferenceScheduler metrics

none

GitHub

Exact estimation with estimand plugins

ExactEstimator over all \(2^n\) coalitions, estimand delegation and budget guards

none

GitHub

Estimator comparison: error at matched budgets

mc, complementary, neyman_cc, leverage, kernel_banzhaf and proxy against exact Shapley and Banzhaf on five games, budgets 2n to 32n

[viz], [proxy]

GitHub

Semivalues, new estimators and honest uncertainty

Beta Shapley, weighted Banzhaf, permutation and lime; explanation.stderr coverage, budget.stop and mllm-shap plan

none

GitHub

Replay archived coalitions and read the cost of a run

Replaying any estimator, budget and seed from an exact archive with no model calls; misses, fallback, perf counters, batch_size

none

GitHub

Faithfulness checks, margins and pairwise interactions

removal_metrics(), circularity, flip and restore sizes, label_margin and pairwise k-SII from explain_interactions()

[interactions]

GitHub

Attribution visualization

Real-model attributions of a prompt, a multi-speaker conversation and a spoken sentence, in every renderer, HTML view and plot_audio_segments()

[viz], [transformers], [audio]

GitHub

End-to-end text explainability on real backends

One refund question on the LM Studio, transformers (KV cache, dtype, revision) and HTTP API presets of config/; LM Studio skipped when no server runs

[lmstudio], [transformers], [api], [viz]

GitHub

Audio alignment with SGPA

SpectrogramGuidedAligner on a recorded sentence: segments, refined boundaries, weights, guards, a custom CtcModel

[audio], [transformers]

GitHub

Audio runs on the mock backend

MockAudioBackend on a synthesised clip: tokens per voiced run, a silenced word, an explanation, the decode guard

(core)

GitHub

Explaining a spoken sentence with an audio language model

Granite Speech through transformers; sgpa_segments attributes its answer to spoken words; the lmstudio refusal

[audio], [transformers]

GitHub

Which spoken word decided the answer?

Qwen2-Audio-7B on spoken yes-no questions; which word decided each answer, one against the reference

[audio], [transformers], [viz]

GitHub

Which part of the photo decided the answer?

Qwen2.5-VL-3B on yes-no questions about six photos; image_grid and image_boxes show which regions carry each answer

[transformers], [image], [viz]

GitHub