PaTz — Physics-Aware Transformer with eXplainability
● API Offlinepatz_env

SHAP Analysis

NOT IMPLEMENTED

SHAP (SHapley Additive exPlanations) is not currently implemented in the PaTz codebase. Integrated Gradients (Captum) serves as the primary attribution method.

⚠ SHAP not in codebase — using Integrated Gradients instead

The src/xai/ module implements Integrated Gradients (Captum) with a manual Riemann fallback, not SHAP or LIME. SHAP Kernel requires 200–2,000× more forward passes than IG and is infeasible on a 6 GB GPU for per-residue attribution across 354 GO terms. The existing IG implementation is equivalent for feature-attribution purposes in deep learning.

What SHAP Would Provide
Kernel SHAP

Model-agnostic. Background distribution samples → marginal Shapley contributions per residue. O(2^L) exact; O(n_samples × L) approx.

Deep SHAP

Backpropagation-based. DeepLIFT + Shapley. Faster than Kernel. Requires full autograd graph — incompatible with frozen ESM-2 feature extraction pipeline.

Global Feature Importance

SHAP summary plots: mean(|SHAP|) per residue position across all test proteins. Aggregates per-sample attributions.

Integrated Gradients — Current Implementation
MethodIntegrated Gradients (Captum)
FallbackRiemann approximation (50 steps)
BaselineZero embedding (uninformative)
Attribution shapeL × 1280 → L scalars (mean over dim)
UncertaintyMC Dropout N=20 passes → entropy H[p]
Output fileresults/xai_results.json
Scriptscripts/04_xai_pipeline.py
IG vs SHAP — Comparison for PaTz
CriterionIntegrated Gradients (✓ used)SHAP Kernel
Computational cost~50 forward/backward passes~500–5,000 forward passes
GPU memoryLow (gradient tape)High (coalitions × batch)
Axiomatic guaranteesCompleteness, Sensitivity, LinearityEfficiency, Symmetry, Dummy, Linearity
Handles residue lengthYes (per-residue dim-mean)Difficult (variable L)
Feasible on RTX 3050✓ Yes✗ Too slow / OOM
Literature precedentStandard for protein LMsMore common in tabular/NLP
→ View Integrated Gradients (IG)→ XAI Dashboard