Overview
Yggdrasil explanations are template-generated, not LLM-generated. Every violation includes:- Policy Excerpt: The exact clause from the regulatory document
- Evidence Grid: Matched field values from your data
- Condition Summary: Human-readable breakdown of what matched
- ✅ Deterministic: Same violation → same explanation
- ✅ Audit-ready: No hallucinations or inconsistencies
- ✅ Fast: No API latency for explanation generation
Implementation
Explanations are generated byexplainability.ts using string templates:
Explanation Components
1. Policy Excerpt
Every rule includes the exact text from the regulatory document:rules table and displayed in the violation detail.
2. Evidence Grid
The evidence object contains all relevant field values from the matched record:3. Condition Summary
For condition-based rules (GDPR, SOC2), the engine generates a human-readable summary:Single-Transaction Explanations
Prebuilt Rule Templates
For well-known rules (AML, FinCEN), the engine uses hardcoded templates:CTR Threshold
Balance Mismatch
Generic Condition-Based Explanation
For custom PDF-extracted rules, the engine uses the condition summarizer:Windowed Explanations
Windowed rules (aggregations, velocity) generate context-aware explanations:Structuring Pattern Example
Description Field Format
Thedescription field in the rules table can be:
- Plain text: Used directly
- JSON with historical context:
text field.
Why Templates, Not LLMs?
Determinism
Template:Speed
| Method | Latency |
|---|---|
| Template | <1ms |
| LLM (Gemini) | 200-800ms |
No Hallucinations
Templates only use:- Rule metadata (stored in DB)
- Record fields (from CSV)
- Hardcoded policy references
- Fake policy section numbers
- Incorrect thresholds
- Misleading explanations
Cost
Templates are free. LLM calls cost money per violation.Evidence Drawer
The violation detail page displays:- Policy Excerpt (top)
- Evidence Grid (structured data)
- Explanation (formatted text)
Extending Templates
To add a new rule template:- Edit
explainability.ts - Add a new case to the
switchstatement:
- Fallback: If no template exists, the generic condition summarizer is used.
Next Steps
Confidence Scoring
Learn how violations are ranked
Bayesian Feedback
How user reviews improve explanations