Skip to content

Output Quality Scoring

Output Quality Scoring evaluates every LLM response on four dimensions — hallucination, relevance, toxicity, and groundedness — and stores the results in the audit log. Administrators can query aggregate metrics, configure alert thresholds, and compare model performance without any changes to client integrations.

When enabled, the OutputScorer runs synchronously after each model response, before the response is returned to the caller. Scoring adds minimal latency; a configurable timeout budget causes the scorer to skip rather than block if it runs long. All four dimension scores are attached to the audit log entry for the request.

Scores are in the range 0–1, where 1.0 represents the best possible quality on each dimension.

  1. The platform receives a response from the upstream LLM provider.
  2. OutputScorer evaluates the response against the original prompt across four dimensions.
  3. Scores are written to audit_log.extra_metadata["output_scores"].
  4. If any score falls below a configured threshold, a quality.threshold_breached webhook fires (deduplicated per metric, period, and date).
  5. Aggregate scores are queryable via the admin quality API.

If output_scoring_timeout_ms is exceeded, scoring is skipped for that request and the response is returned without scores. Skipped events do not appear in aggregate metrics.

hallucination_score measures whether the response introduces specific factual claims that are not grounded in the prompt. A score of 1.0 means no hallucination was detected.

The scorer uses a specificity heuristic: it extracts claims via regex patterns targeting dates, decimal numbers, titled proper names, proper noun bigrams, and large formatted numbers. For each extracted claim, it checks whether the claim appears in the prompt. The ungrounded claim ratio is combined 50/50 with the groundedness score to produce the final hallucination score.

This approach catches the most common hallucination patterns (invented statistics, fabricated citations, fictional dates) without requiring a separate LLM call.

relevance_score measures how well the response addresses the prompt. A score of 1.0 means the response is perfectly on-topic.

The score is a weighted combination:

  • 60% — keyword overlap between prompt and response
  • 40% — length ratio (response length relative to prompt length, capped to avoid penalizing appropriate brevity)

Short, tightly targeted responses score well. Verbose responses that stray from the prompt topic score lower.

toxicity_score measures the absence of harmful content. A score of 1.0 means no toxic content was detected.

The scorer applies keyword severity penalties:

Severity Penalty per hit
Severe -0.30
Moderate -0.15
Mild -0.05

The default score is 1.0 and penalties accumulate. The score floors at 0.0.

groundedness_score measures whether the response is supported by the prompt context. A score of 1.0 means the response is fully grounded in the provided context.

When the DeBERTa NLI service is available, the scorer calls POST {deberta_url}/nli with the prompt as the premise and the response as the hypothesis (both truncated to 2,000 characters). The score is computed as:

groundedness = max(0.0, min(1.0, entailment - (contradiction * 0.5)))

When DeBERTa is unavailable (timeout or not configured), the scorer falls back to a heuristic: the fraction of response keywords found in the prompt, scaled as 0.3 + (0.7 * min(1.0, ratio * 2.0)). The heuristic floor of 0.3 reflects that any coherent response has some baseline grounding.

Output quality scoring is disabled by default. Enable it via environment variable or system config key.

Environment variable:

Terminal window
OUTPUT_SCORING_ENABLED=true

System config key (set via admin API):

Terminal window
curl -X PUT https://api.arbitex.ai/api/v1/admin/config/output_scoring_enabled \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"value": "true"}'

Timeout budget — set in milliseconds. Scoring is skipped if this budget is exceeded:

Terminal window
curl -X PUT https://api.arbitex.ai/api/v1/admin/config/output_scoring_timeout_ms \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"value": "500"}'

A timeout of 500ms is sufficient for heuristic-only scoring. When DeBERTa NLI is enabled, 1,000–2,000ms is recommended depending on your deployment latency.

DeBERTa NLI improves groundedness scoring accuracy significantly over the keyword heuristic. The scorer reads the endpoint from the DLP_DEBERTA_VALIDATOR_URL environment variable, which is shared with the DLP pipeline.

Terminal window
DLP_DEBERTA_VALIDATOR_URL=http://deberta-service:8080

The default DeBERTa timeout is 3.0 seconds. If the NLI call times out, the scorer falls back to the heuristic automatically — it does not fail the request.

See DLP Pipeline Configuration for DeBERTa deployment and sizing guidance.

Alert thresholds are configurable per metric via system config keys. The default threshold for all four metrics is 0.3 — a score below 0.3 triggers an alert.

Config key Default
quality_alert_threshold_hallucination 0.3
quality_alert_threshold_relevance 0.3
quality_alert_threshold_toxicity 0.3
quality_alert_threshold_groundedness 0.3

Set a tighter threshold for toxicity monitoring:

Terminal window
curl -X PUT https://api.arbitex.ai/api/v1/admin/config/quality_alert_threshold_toxicity \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"value": "0.7"}'

When a threshold is breached, the platform fires a quality.threshold_breached webhook. Alerts are deduplicated per metric, period, and date — a sustained breach fires once per day, not once per request.

Retrieve current alerts:

Terminal window
curl -G https://api.arbitex.ai/api/v1/admin/quality/alerts \
-H "Authorization: Bearer $ADMIN_TOKEN" \
--data-urlencode "period=week"

The model comparison endpoint ranks all active models by composite score. The composite score is the unweighted mean of the four dimension averages:

composite = (avg_hallucination + avg_relevance + avg_toxicity + avg_groundedness) / 4

Models are sorted descending by composite score, making it straightforward to identify which provider or model variant is delivering the highest quality output over a date range.

Terminal window
curl -G https://api.arbitex.ai/api/v1/admin/quality/model-comparison \
-H "Authorization: Bearer $ADMIN_TOKEN" \
--data-urlencode "date_from=2026-03-01" \
--data-urlencode "date_to=2026-03-31"

The metrics endpoint returns aggregate dimension averages grouped by org, model, or provider over a time window.

Terminal window
curl -G https://api.arbitex.ai/api/v1/admin/quality/metrics \
-H "Authorization: Bearer $ADMIN_TOKEN" \
--data-urlencode "period=week" \
--data-urlencode "group_by=model"

Group by provider to compare across upstream LLM vendors. Group by org to identify which tenants are receiving lower quality responses.

Every scored response includes an output_scores object in extra_metadata. Example audit log entry:

{
"event_id": "evt_01j9xk4r2m3n5p6q7r8s9t0u",
"event_type": "llm.response",
"timestamp": "2026-04-01T14:23:11Z",
"org_id": "org_abc123",
"model_id": "gpt-4o",
"provider": "azure-openai",
"extra_metadata": {
"output_scores": {
"hallucination_score": 0.87,
"relevance_score": 0.92,
"toxicity_score": 1.0,
"groundedness_score": 0.74,
"deberta_used": true,
"scoring_latency_ms": 312
}
}
}

deberta_used is true when the NLI model contributed to the groundedness score, and false when the heuristic fallback was used. scoring_latency_ms reflects the time spent in the scorer, useful for tuning output_scoring_timeout_ms.

Audit log entries are queryable via the standard audit export API and participate in the HMAC audit chain.

  • Hallucination detection is heuristic. The specificity heuristic catches common patterns but will not detect all forms of hallucination (e.g., plausible-sounding but incorrect paraphrases). DeBERTa groundedness scoring partially compensates for this.
  • Toxicity uses a keyword list. The scorer does not use a semantic toxicity model. Novel phrasing or obfuscated harmful content may not be detected. For content moderation requirements, use the DLP pipeline in addition to quality scoring.
  • Groundedness requires context in the prompt. For open-ended generation tasks where the prompt does not supply reference material, groundedness scores will be low by design and should be interpreted accordingly.
  • Skipped events are excluded from aggregates. If a high proportion of requests are timing out before scoring completes, increase output_scoring_timeout_ms or reduce DeBERTa service latency.