Skip to main content

Regulatory Metric

The Regulatory metric evaluates whether AI assistant responses comply with a regulatory corpus (e.g., company policies, legal frameworks, compliance documents). It accumulates per-interaction compliance scores and emits one session-level result. The interactions list preserves per-QA verdicts for auditing.

Overview

  • Compliance Score: Weighted mean of per-interaction scores across the session (0.0–1.0)
  • Verdict: Session-level COMPLIANT, NON_COMPLIANT, or IRRELEVANT — derived directly from the aggregated score for consistency
  • Per-interaction detail: Each QA pair’s verdict, chunks, and insight accessible via interactions
  • Bayesian mode: Bootstrapped credible interval around the session compliance score

How It Works

How the Verdict Is Determined

The session verdict is always derived from the session compliance_score — they always agree.
By default, the metric uses Qwen3-Embedding for semantic retrieval and Qwen3-Reranker for contradiction detection via the QwenEmbedder and QwenReranker implementations. You can swap these for any custom Embedder or Reranker implementation.

Installation

Basic Usage

Parameters

Required Parameters

Optional Parameters

Statistical Modes

Returns the weighted mean of per-interaction compliance scores. CI fields are None.

Interaction Weights

Each Batch can carry an optional weight to control its contribution to the session aggregate:

Output Schema

RegulatoryMetric

RegulatoryInteraction

RegulatoryChunk

Corpus Connectors

LocalCorpusConnector

LakeFSCorpusConnector

Complete Example

Regulatory Corpus Format

Create markdown files in your corpus directory:

Interpretation

Compliance Scores

Model Options

Threshold Tuning

Controls which chunks are retrieved based on semantic similarity.
  • Lower (0.2): Retrieves more chunks, may include less relevant ones
  • Higher (0.5): Stricter, only highly relevant chunks
Lower this if you’re getting too many IRRELEVANT verdicts.
Controls how the reranker classifies chunks as SUPPORTS or CONTRADICTS.
  • Lower (0.4): Stricter — more chunks classified as contradicting
  • Higher (0.8): Lenient — only clear contradictions flagged
Lower this for stricter compliance checking.
Minimum session compliance score to emit a COMPLIANT verdict.
  • Lower (0.3): Lenient — sessions pass with fewer supporting chunks
  • Higher (0.7): Strict — requires clear majority of supporting evidence
Raise this for high-stakes regulatory environments.

Troubleshooting

Lower similarity_threshold to 0.2 or verify the corpus covers the topics being discussed.
Raise contradiction_threshold to 0.7 or 0.8 and review whether the corpus is balanced (not just prohibitions).
This should not happen with the current implementation — verdict is always derived from compliance_score. If you see a discrepancy, file a bug report.
Use smaller models (0.6B), reduce batch_size to 16 or 8, or fall back to CPU.

Use Cases

Financial Compliance

Verify responses comply with banking regulations, KYC requirements, and financial advice rules

Healthcare HIPAA

Ensure patient data handling follows HIPAA guidelines

Call Center Policies

Check responses against company policies and consumer protection laws

Legal Compliance

Validate AI-generated legal content against jurisdiction-specific regulations

Next Steps

Statistical Modes

Frequentist vs Bayesian — when each matters

Context Metric

Evaluate response alignment with system context

AWS Lambda

Deploy Regulatory as a serverless function