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).
Install nlp-shap and run your first Shapley vs Banzhaf comparison in
a few lines of Python.
Work with estimand aggregators, explain results, and run-archive manifests.
Shapley axioms, cooperative games, estimands, and when they diverge.
Business, compliance, and LLM operations use cases for attribution.
Typed public modules, protocols, and re-exported symbols.
Runnable Jupyter notebooks with end-to-end walkthroughs (estimands, masking, runtime, exact and approximate estimation).
Per-version changelog for published releases.
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.