Regulated software does not just need “good enough” AI. It needs behaviour that is provable, auditable, and constrained.
Decision-focused models, formal verification for AI-generated code, and more durable approaches to context are promising—but can feel abstract. The fastest way to make them concrete is to run a focused experiment in your own environment.
| Same input Representative cases |
→ | Standard LLM Flexible generation |
→ | Measure Accuracy · auditability · cost |
| Constrained / verified Explicit rules and checks |
Objective
Compare two implementations of the same decision task:
- Implementation A: Standard LLM approach — such as GPT-5, Claude Sonnet 4.5, or your current provider.
- Implementation B: Constrained or verified approach — using a rules engine and/or formal invariants.
Measure accuracy and error modes, auditability, latency, cost, and the effort needed to change logic when policy changes. Use the result to decide where additional rigor is worth the investment.
Scope and Setup — Week 1
1. Choose a workflow
Select one high-value, rules-heavy workflow, for example:
- transaction monitoring and fraud flagging
- access provisioning or privilege escalation
- clinical triage or decision support
- eligibility checks for benefits and services
The workflow should meet three conditions:
- The logic is substantially rule-based and documented in policies or standard operating procedures.
- The decision affects customers, safety, or regulatory reporting.
- Historical cases are available, or synthetic cases can be reviewed by a domain and compliance expert.
2. Define success metrics
- Accuracy and error modes: false positives and false negatives against a human or policy baseline.
- Audit time per decision: how long it takes to reconstruct the rationale.
- p95 latency: under representative load.
- Cost per decision: including inference and infrastructure.
- Change effort: time required to update logic after a policy change.
3. Build an evaluation harness
Prepare 200–500 cases with known outcomes. Prefer historical decisions; otherwise use synthetic cases labelled by a domain or compliance expert.
Build a script that feeds each case into the service, records the decision, confidence, reason codes, explanation and latency, then compares results with the expected outcome. Reuse exactly this harness for both implementations.
Implementation A: Standard LLM Approach — Weeks 2–3
Tools: GPT-5, Claude Sonnet 4.5, or your existing model provider; LangChain, LlamaIndex, or direct API calls; and your normal database and observability stack.
1. Prompt design
Encode policies and rules in the system prompt with a small number of representative examples. Require a structured response and use the provider’s structured-output or JSON mode where available.
{
"decision": "FLAG" | "ALLOW",
"confidence": 0–1,
"reason_codes": ["RULE_03", "SANCTIONS_HIT"],
"explanation": "..."
}
2. Integration and evaluation
Wrap the model call in a function or microservice. For every request, log the input, raw model output, parsed response, latency and model version. Run the evaluation set and record all defined metrics.
Capture concrete failures such as invented rules, inconsistent reason codes and explanations that are difficult to audit.
This is the baseline.
Implementation B: Constrained or Verified Approach — Weeks 3–5
Choose the path that best matches the workflow.
Option 1: Decision model or rules engine
Best for workflows that are primarily explicit business rules.
Tools: Drools, Open Policy Agent (OPA), or a custom decision service. An LLM may still be used for feature extraction, such as parsing free-text notes, but not for the final decision.
- Translate each policy or standard operating procedure into explicit rules, with rule IDs that map to approved documentation—for example RULE_03 or SANCTIONS_HIT.
- Define a structured input interface, such as risk score, amount and country, and return the same output schema used by the LLM version.
- Run the identical evaluation data set and collect identical metrics. Compare error modes, audit time and change effort with the LLM baseline.
Option 2: LLM plus formal invariants
Best for code-heavy workflows where generated or modified code must comply with safety, security or regulatory constraints.
Tools: a language or framework with strong static or formal verification capabilities, plus CI checks that enforce specifications before merge.
- Specify non-negotiable invariants, such as “No PII is logged in plain text”, “Access decisions always include an approved reason code”, or “A positive decision cannot be returned without a sanctions check”.
- Allow the LLM to generate implementation code only within the approved interface and library boundaries.
- Run compiler, verifier and CI checks before merging. Measure implementation and update time, defects caught by verification rather than tests, and effort to produce audit artefacts.
Analysis and Organizational Pattern — Week 6
Create a stakeholder-ready comparison using your actual results:
| Metric | LLM-only | Constrained / verified |
|---|---|---|
| Accuracy | ||
| False positive rate | ||
| Audit time per case | ||
| p95 latency | ||
| Cost per decision | ||
| Change effort |
Document where the LLM drifted from policy, where constrained logic became overly rigid, and which implementation gave auditors the clearest evidence. Then turn the findings into an engineering and AI-governance pattern:
- Use free-form LLMs for exploration, prototyping, documentation, summarisation and non-critical user experience.
- Use constrained or verified approaches for decisions affecting customers, safety, money, regulated reporting, PII or access control.
Why This Matters
The goal is not to replace LLMs everywhere. It is to use them where their flexibility creates value, and to introduce explicit constraints where a decision must be explainable, reproducible and defensible.
A small, controlled experiment produces evidence that engineering, risk and compliance teams can use together: fewer vendor claims, clearer failure modes and a practical basis for AI architecture decisions.
In a regulated domain, the key question is not “Which LLM is smartest?” It is: “Which stack lets us demonstrate that the system behaves as required?”