- gradient_boosted — TreeSHAP (Lundberg, Erion, Lee 2018, Algorithm 2, path-dependent variant). Deterministic, O(T·L·D²).
- neural_cf — KernelSHAP (Lundberg, Lee 2017). Exact over the 2·embDim feature set when ≤ 12 features, deterministically sampled otherwise.
When SHAP fires
| Opt-in | Behavior |
|---|---|
llmExplanationsEnabled = false (default) | No SHAP computation. Zero /recommend latency impact. |
llmExplanationsEnabled = true | SHAP computed for every gradient_boosted + neural_cf candidate; persisted on scoringResults[i].shapValues. |
POST /decisions/:id/shap (always available) | On-demand SHAP for one offer with caller-supplied attributes. |
/api/v1/ai/explanations-settings endpoint:
On-demand SHAP: POST /decisions/:id/shap
For audit workflows where raw attributes live outside the trace (PII
minimization), supply them in the request body:
additivityResidual reports |rawMargin − baseline − Σ shapValues|
on every call. Non-zero residual indicates a malformed model and
should be treated as a warning.
Persisted SHAP (hot-path path)
When opted in,DecisionTrace.scoringResults[i] carries:
Probability-space approximation
SHAP values are in raw-margin (logit) space — the only space where the additivity identity holds. For probability-space effect size:shap_i but not additive in probability space.
UI surfaces both: raw φ for compliance, sigmoid-mapped delta for
human-readable display.
Neural CF SHAP (KernelSHAP)
Forneural_cf models, features are the 2·embDim user+item embedding
coordinates:
user.emb_0,user.emb_1, …,user.emb_{D−1}item.emb_0,item.emb_1, …,item.emb_{D−1}
2·embDim ≤ 12 (2^12 = 4096 coalitions); sampled
KernelSHAP with 512 default samples runs above that threshold. Seed
is exposed in the result for reproducibility.
See also: LLM Explanations | Fairness + Drift | Decision Traces API