mllm-shap

Shapley-value attributions for conversational language models. mllm-shap separates what you measure (estimand: Shapley or Banzhaf), how you sample coalitions (estimator) and how you score outputs (value function), and archives every run for reanalysis.

What an explanation shows

Which photo region, spoken word or typed word decided a model’s answer? Parts are removed, the answer re-scored; credit adds up to the total change.

Where in the picture?

“Is there a dog in this picture?” Qwen2.5-VL-3B says yes. Two of 36 cells, a walker and a small dog, carry most of it.

Image input
Which spoken word?

Does the speed of sound vary with frequency “at constant temperature”? Qwen2-Audio-7B says no; “constant” drives it.

Audio input
Which typed word?

A refund request: “yes”, “no.” and “laptop” push the answer; “opened it.” pulls against it.

Visualization

Start here

Getting started

Install, explain a first prompt, check the values add up.

Getting started
How a run works

Stages of a run, counters, archives and hooks.

How a run works
Theory

Cooperative games, Shapley axioms, estimands and when they diverge.

Shapley values and axioms
Applications

Business, compliance and operations use cases.

Business and compliance applications
API reference

Public modules, protocols and re-exported symbols.

API reference
Examples

Runnable notebooks, end to end: estimands, masking, runtime, exact and approximate estimation.

Examples
Citing

Citing mllm-shap and its methods.

Citing mllm-shap
Contributing

Setup, quality gates, pull requests.

Contributing to mllm-shap
Knowledge vault

Architecture, decisions, known issues and papers: an Obsidian vault in the repository.

https://github.com/Pawlo77/MLLM-SHAP/blob/main/knowledge/mllm-shap.md

How it compares

Latest PyPI releases, checked December 2026:

Package

Inputs

Methods

Models

Turns as players

mllm-shap

text, image, audio

10 estimators, 4 estimands, 14 value functions

Hugging Face, LM Studio, OpenAI-compatible APIs

built in

shap 0.54.1

text, image (captioning)

Partition, Permutation, Exact

Hugging Face, any callable

no

captum 0.9.0

text, image regions

5 perturbation (3 Shapley), gradient

Hugging Face, vLLM

by hand (templates)

inseq 0.7.1

text

4 perturbation, gradient

Hugging Face

no

interpreto 0.5.2

text

4 perturbation (1 Shapley), 7 gradient

Hugging Face

no

icx360 0.1.0

text

MExGen, CELL, Token Highlighter

Hugging Face, vLLM

no

context-cite 0.0.4

text context

sparse linear surrogate

Hugging Face

no

TokenSHAP 0.2.2

text

sampled with/without difference

Hugging Face, Ollama

no

lime 0.2.0.1 and ferret-xai 0.4.2 explain classifiers only.

Need

mllm-shap

Voice and vision

Credits spoken words and image regions; the only package above that takes audio (Audio input, Image input).

Chatbots

A system prompt, a turn or a passage in its own message is a player (Masking views).

Closed models

Needs only the model’s answers, plus logprobs for some value functions (Generative backends).

Audit trail

Every run is archived; text value functions rescore it without model calls (reanalyze()).

Checkable numbers

Results name their estimand (Estimands: Shapley vs Banzhaf); exact and mc give standard errors (Choosing an estimator).

Cost control

Exact, sampling and regression estimators behind one setting (Approximate estimation).

Quick install

pip install mllm-shap

Python 3.12 or newer; walkthrough: Getting started. Optional extras:

pip install "mllm-shap[transformers]"   # Hugging Face backend
pip install "mllm-shap[lmstudio]"       # LM Studio backend
pip install "mllm-shap[api]"            # OpenAI-compatible HTTP API
pip install "mllm-shap[viz]"            # matplotlib attribution charts
pip install "mllm-shap[proxy]"          # scikit-learn: the ProxySHAP estimator
pip install "mllm-shap[infill]"         # masked language model of the infill policy
pip install "mllm-shap[interactions]"   # shapiq: exact pairwise interactions
pip install "mllm-shap[audio]"          # audio decoding and alignment
pip install "mllm-shap[semantic]"       # sentence, BERTScore and NLI encoders
pip install "mllm-shap[audio-semantic]" # SpeechBERTScore encoder and recognizer
pip install "mllm-shap[image]"          # image players and fills

Extras and entry points: Extending mllm-shap.