Command line

Command-line interface: mllm-shap explain|reanalyze|plugins|config.

Exit codes: 0 success, 2 invalid configuration, snapshot, archive or arguments, 3 backend unavailable (missing extra, unreachable server).

@domain core @see [[knowledge/architecture/core]] @tested-by [[tests/test_cli.py]]

mllm_shap.cli.EXIT_OK: Final[int] = 0

The command succeeded.

mllm_shap.cli.EXIT_INVALID: Final[int] = 2

Invalid arguments, configuration, snapshot or archive (argparse uses 2 too).

mllm_shap.cli.EXIT_BACKEND_UNAVAILABLE: Final[int] = 3

The configured backend cannot be built or reached.

mllm_shap.cli.LOG_LEVELS: Final[tuple[str, ...]] = ('debug', 'info', 'warning', 'error')

Values accepted by --log-level (case-insensitive).

mllm_shap.cli.RENDERERS: Final[tuple[str, ...]] = ('token_text', 'token_bar')

Built-in renderer names accepted by explain --render.

mllm_shap.cli.EXAMPLE_CONFIG: Final[str] = '# mllm-shap explain configuration. Validate with: mllm-shap config --check FILE\nbackend:\n  kind: mock                # mock | api | lmstudio | transformers (or a plugin)\n  model_id: mock            # model name passed to the backend\n  # api_host: http://localhost:1234/v1   # api backend only\n  timeout_s: 120.0          # per-request timeout of remote backends\n  max_retries: 3            # retries after transient backend failures\n  options: {}               # backend-specific settings (LM Studio: see docs)\n\ngeneration:\n  max_new_tokens: 32        # tokens generated per coalition\n  temperature: 0.0          # 0.0 makes generations deterministic (enables dedup)\n  top_k: 1\n  compute_embeddings: false # set automatically for embedding value functions\n\nexplanation:\n  estimand: shapley         # shapley | banzhaf\n  estimator: exact          # exact | mc | complementary | neyman_cc\n  value_fn: tfidf_cosine    # tfidf_cosine | embedding_cosine | logprob | ...\n  normalizer: identity      # identity | abs_sum | power_shift | min_max\n  players: tokens           # tokens | messages (one player per message)\n  absence_policy: delete    # delete | pad | neutral\n  budget:\n    fraction: 1.0           # share of the 2^n coalitions; exact needs 1.0\n    # evaluations: 2000     # or an absolute count instead of fraction (not exact)\n  include_minimal_masks: false\n  max_inflight: 2           # concurrent backend calls\n  max_players: 24           # refuse runs planning more than 2^max_players coalitions\n  seed: 0\n  archive:\n    path: ./runs/{run_id}   # "" disables the archive (reanalyze needs one)\n    flush_every: 50\n    on_exists: error        # error | overwrite\n  dedup:\n    enabled: auto           # auto | on | off\n  kv_cache:\n    enabled: false          # prefix KV reuse (transformers backend)\n    max_entries: 8\n  plugin_options: {}        # per-plugin settings keyed by <group>/<name> or name\n'

Commented YAML skeleton printed by mllm-shap config --example.

mllm_shap.cli.main(argv: Sequence[str] | None = None) → int[source]

Run the command line and return its exit code.