Skip to content

LLM-Powered Regulatory Narrative Generation from Forensic Reports #118

Description

@Inkman007

Summary

Add a ForensicReport.to_regulatory_narrative() method that uses an LLM to generate a plain-English regulatory narrative from the structured forensic report data, suitable for SAR (Suspicious Activity Report) filings.

Motivation

Forensic reports contain SHAP values, causal attribution chains, and propagation paths that are inaccessible to non-technical compliance teams and regulators. An LLM-generated narrative translates these into precise, citation-grounded language.

Proposed Design

# detection/narrative_generator.py
class RegulatoryNarrativeGenerator:
    def __init__(self, model='claude-sonnet-4-6'): ...

    def generate(self, report: ForensicReport) -> str:
        prompt = self._build_prompt(report)
        return self._call_llm(prompt)

Narrative requirements:

  • Reference specific feature values (e.g. counterparty_concentration_ratio of 0.92 indicates...)
  • Cite causal chain hops by wallet address
  • Include propagated risk contributors if present
  • Output <= 500 words in regulatory English

Narrative cached to avoid redundant API calls for the same report.

Acceptance Criteria

  • Generated narrative references at least 3 specific feature values from the report
  • No hallucinated wallet addresses or scores (factually grounded)
  • ANTHROPIC_API_KEY added to .env.example and config.py
  • Unit test: mock LLM response, verify prompt contains report wallet and top SHAP features

References

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions