nlp-shap

Multimodal explainability for NLP and multimodal models based on Shapley-style cooperative game theory. The library separates what you measure (estimands), how you sample coalitions (estimators), and how you score outputs (value functions).

Getting started

Install nlp-shap and run your first Shapley vs Banzhaf comparison in a few lines of Python.

Getting started
User guide

Work with estimand aggregators, explain results, and run-archive manifests.

Using estimand aggregators
Theory

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

Shapley values and axioms
Applications

Business, compliance, and LLM operations use cases for attribution.

Business and compliance applications
API reference

Typed public modules, protocols, and re-exported symbols.

API reference
Examples

Runnable Jupyter notebooks with end-to-end walkthroughs (estimands, masking, runtime, exact and approximate estimation).

Examples
Release notes

Per-version changelog for published releases.

Release notes

Quick install

pip install nlp-shap

Requires Python 3.12. See Getting started for a full walkthrough.

Optional extras:

pip install "nlp-shap[transformers]"   # Hugging Face backend
pip install "nlp-shap[lmstudio]"       # LM Studio backend
pip install "nlp-shap[api]"             # OpenAI-compatible HTTP API
pip install "nlp-shap[viz]"             # matplotlib attribution charts

See Extending nlp-shap for the full extras and entry-point matrix.