- Regulator — formal, compliance-grade prose with full factor detail. Writes to the AuditLog for DSAR / regulator use.
- Agent — structured JSON for internal tooling (call-center consoles, troubleshooting UIs). Machine-readable.
- Customer — one or two plain-language sentences you can show to the end customer in-product.
Narratives are generated on-demand against persisted decision traces.
They never run during a
/recommend call, so LLM latency or availability
cannot affect live decisioning.When to use each mode
Pick the mode that matches the downstream consumer. The same trace can be
explained in all three modes and the results are cached independently.
How to enable it
LLM explanations are off by default for every tenant. Enable them inSettings > AI explanations, or via the API:
tenantSettings.aiAnalyzerSettings.llmExplanationsEnabled. While disabled,
the narrative endpoint returns 403:
End-to-end flow
PII redaction
Before any outbound LLM call, the input context runs through a PII-redaction pass:- Customer identifiers, email addresses, phone numbers, and free-text address
fields are replaced with a
[redacted]marker — matched by both field-name patterns (email/phone/ssn/dob/account_number/address/…) and value-shape heuristics (looks-like-email/phone/credit-card/SSN). - Only offer IDs, feature contributions, scores, policy reasons, and experiment assignment remain in the prompt.
- The prompt explicitly notes “customer attributes redacted before LLM call; features reflected via topFactors on each offer” so the model does not invent missing attributes.
Caching
The
inputsHash component guarantees that if the underlying trace is
re-scored or updated, the next request will generate a fresh narrative.
Audit log for regulator mode
Every successfulmode = "regulator" call produces an audit-log row:
Worked example — one trace, three views
Given a trace whereoffer_premium_card was selected with score 0.89, and
offer_gold_plus came second with 0.71, the three modes produce:
Regulator
Agent
Customer
Exact SHAP for gradient_boosted models
The narrative endpoint produces prose explanations. For numerical, mathematically-grounded per-feature attributions ongradient_boosted models, KaireonAI also exposes an exact TreeSHAP
endpoint:
shapValues plus baseline equals rawMargin
exactly — the additivity invariant is verified per-call and reported as
additivityResidual.
Use this when:
- A regulator demands a defensible per-feature breakdown for an audit (EU AI Act Art. 13 / 22, GDPR Art. 15).
- You want to feed numerical attributions into a downstream dashboard, CSV export, or your own NLG layer.
- The cheap path-heuristic
explanationsfield onDecisionTrace.scoringResultsis not exact enough — TreeSHAP is the consistent, axiomatically-grounded alternative.
/shap with /narrative for regulator exports: the SHAP numbers
are the math, the narrative is the prose. Both flow through the same
per-tenant llmExplanationsEnabled opt-in. See the
Decision Traces API
for full request/response and audit-log details.
Rate limits
- 20 requests / minute / tenant on the narrative endpoint.
- 30 requests / minute / tenant on the SHAP endpoint.
- Exceeding returns
429 TOO_MANY_REQUESTS. Retry after the bucket refills (the limiter is a sliding 60-second window).
In-app usage
Open any row in Studio > Decision Traces and click Explain. The dialog has tabs for all three modes, a regenerate button that setsnoCache: true, and a metadata footer showing the model used, cache status,
and token counts.
See also: Decision Traces API |
Security Model |
AI Configuration