Semantic Consistency
llm.semantic_consistency
Measures whether the system reaches the same conclusion or stance when its query is paraphrased, compared against its original answer.
Contract
| Field | Value |
|---|---|
version | 1.0.0 |
metric_type | pointwise |
scorer_contract | per_row |
direction | higher_is_better |
entrypoint | aip_metrics_llm.unanswered.semantic_consistency |
target_kind | None |
Required columns
input_idpromptsut_response
Accepted schemas
[
{
"name": "gdi_text_v1",
"task_types": [
"multi_turn_llm",
"multi_turn_rag",
"single_turn_llm",
"single_turn_rag"
]
}
]
Methodology
- Build a paraphrased variant of the row's query by substituting it into a randomly chosen reframing template (casual, formal, third-person, restated, ...) that wraps the question in a different register without altering its substance.
- Sample responses_per_query - 1 independent SUT responses to that paraphrase variant; the row's existing sut_response is reused as the base response rather than resampled, so cost stays linear in responses_per_query.
- A judge LLM compares the base response against each paraphrase response and labels their agreement on core conclusion or stance as Consistent, Slightly Inconsistent, or Contradictory, with a 0-1 score.
- Average the scores of the successfully judged comparisons; one whose judge call fails is excluded, and the metric only errors out if every comparison failed.
Score semantics
Scores range 0-1, the mean agreement between the base response and each paraphrased-query response on their core conclusion or stance. A high score means the system reaches the same conclusion regardless of how the question is worded; a low score means paraphrasing flips its stance. Higher is better.
Worked example
A row's query is reframed via a paraphrase template into a differently-worded variant; with responses_per_query=3, 2 fresh responses to that variant are each compared against the row's existing response (2 comparisons) — 1 judged Consistent (0.95) and 1 judged Slightly Inconsistent (0.7) -> mean = 0.825.
Configuration schema
{
"properties": {
"concurrency_limit": {
"default": 5,
"description": "Maximum SUT and judge calls in flight at once for this metric. A slot is held per attempt, so a backing-off retry does not occupy one while it waits.",
"maximum": 64,
"minimum": 1,
"title": "Concurrency Limit",
"type": "integer",
"x-aip-param-role": "operational"
},
"inverted": {
"default": false,
"title": "Inverted",
"type": "boolean",
"x-aip-param-role": "scoring_metadata"
},
"max": {
"default": 1.0,
"title": "Max",
"type": "number",
"x-aip-param-role": "scoring_metadata"
},
"metric_name": {
"default": "semantic_consistency",
"title": "Metric Name",
"type": "string",
"x-aip-param-role": "scoring_metadata"
},
"min": {
"default": 0.0,
"title": "Min",
"type": "number",
"x-aip-param-role": "scoring_metadata"
},
"n_judge_retries": {
"default": 2,
"description": "Retries for a single judge call before that comparison is counted as failed. Defaults above 0: a transient judge failure would otherwise silently shrink the denominator the score is averaged over, which is the failure mode this budget exists to prevent.",
"maximum": 5,
"minimum": 0,
"title": "N Judge Retries",
"type": "integer"
},
"n_sut_retries": {
"default": 2,
"description": "Retries for a single SUT call before it is treated as a hard failure that errors the whole row. Defaults above 0: this family fans out responses_per_query SUT calls per row, so a single transient call failure would otherwise lose the row entirely.",
"maximum": 5,
"minimum": 0,
"title": "N Sut Retries",
"type": "integer"
},
"responses_per_query": {
"default": 3,
"description": "Total responses compared for a row, counting the row's existing sut_response as the base. The metric samples responses_per_query - 1 fresh responses to the paraphrase variant and judges each one against that base response, so cost stays linear in this value.",
"maximum": 8,
"minimum": 2,
"title": "Responses Per Query",
"type": "integer"
},
"sut_temperature": {
"default": 0.7,
"description": "Sampling temperature for the SUT calls that answer the paraphrase variant. Above 0 so repeated samples can differ; the judge is always called at temperature 0.",
"maximum": 2.0,
"minimum": 0.0,
"title": "Sut Temperature",
"type": "number"
},
"timeout_seconds": {
"default": 60.0,
"description": "Per-call timeout in seconds, applied to each individual SUT and judge request.",
"exclusiveMinimum": 0,
"title": "Timeout Seconds",
"type": "number",
"x-aip-param-role": "operational"
},
"weight": {
"default": 1.0,
"title": "Weight",
"type": "number",
"x-aip-param-role": "scoring_metadata"
}
},
"title": "SemanticConsistencyConfig",
"type": "object"
}
Execution
{
"emits_metric_family": false,
"function_name": null,
"max_concurrency": 8,
"processing_kind": "network",
"stream_batch_size": 5000,
"timeout_seconds": 21600
}
Complete manifest
accepts:
- name: gdi_text_v1
task_types:
- multi_turn_llm
- multi_turn_rag
- single_turn_llm
- single_turn_rag
config_schema:
properties:
concurrency_limit:
default: 5
description: Maximum SUT and judge calls in flight at once for this metric.
A slot is held per attempt, so a backing-off retry does not occupy one while
it waits.
maximum: 64
minimum: 1
title: Concurrency Limit
type: integer
x-aip-param-role: operational
inverted:
default: false
title: Inverted
type: boolean
x-aip-param-role: scoring_metadata
max:
default: 1.0
title: Max
type: number
x-aip-param-role: scoring_metadata
metric_name:
default: semantic_consistency
title: Metric Name
type: string
x-aip-param-role: scoring_metadata
min:
default: 0.0
title: Min
type: number
x-aip-param-role: scoring_metadata
n_judge_retries:
default: 2
description: 'Retries for a single judge call before that comparison is counted
as failed. Defaults above 0: a transient judge failure would otherwise silently
shrink the denominator the score is averaged over, which is the failure mode
this budget exists to prevent.'
maximum: 5
minimum: 0
title: N Judge Retries
type: integer
n_sut_retries:
default: 2
description: 'Retries for a single SUT call before it is treated as a hard failure
that errors the whole row. Defaults above 0: this family fans out responses_per_query
SUT calls per row, so a single transient call failure would otherwise lose
the row entirely.'
maximum: 5
minimum: 0
title: N Sut Retries
type: integer
responses_per_query:
default: 3
description: Total responses compared for a row, counting the row's existing
sut_response as the base. The metric samples responses_per_query - 1 fresh
responses to the paraphrase variant and judges each one against that base
response, so cost stays linear in this value.
maximum: 8
minimum: 2
title: Responses Per Query
type: integer
sut_temperature:
default: 0.7
description: Sampling temperature for the SUT calls that answer the paraphrase
variant. Above 0 so repeated samples can differ; the judge is always called
at temperature 0.
maximum: 2.0
minimum: 0.0
title: Sut Temperature
type: number
timeout_seconds:
default: 60.0
description: Per-call timeout in seconds, applied to each individual SUT and
judge request.
exclusiveMinimum: 0
title: Timeout Seconds
type: number
x-aip-param-role: operational
weight:
default: 1.0
title: Weight
type: number
x-aip-param-role: scoring_metadata
title: SemanticConsistencyConfig
type: object
dependencies: []
description: Does the system reach the same conclusion or stance when its query is
paraphrased, compared against its original answer?
direction: higher_is_better
display_name: Semantic Consistency
entrypoint: aip_metrics_llm.unanswered.semantic_consistency
execution:
emits_metric_family: false
function_name: null
max_concurrency: 8
processing_kind: network
stream_batch_size: 5000
timeout_seconds: 21600
kind: metric
manifest_version: '1'
max_prompt_slots: 0
metric_metadata:
methodology:
- Build a paraphrased variant of the row's query by substituting it into a randomly
chosen reframing template (casual, formal, third-person, restated, ...) that wraps
the question in a different register without altering its substance.
- Sample responses_per_query - 1 independent SUT responses to that paraphrase variant;
the row's existing sut_response is reused as the base response rather than resampled,
so cost stays linear in responses_per_query.
- A judge LLM compares the base response against each paraphrase response and labels
their agreement on core conclusion or stance as Consistent, Slightly Inconsistent,
or Contradictory, with a 0-1 score.
- Average the scores of the successfully judged comparisons; one whose judge call
fails is excluded, and the metric only errors out if every comparison failed.
score_semantics: Scores range 0-1, the mean agreement between the base response
and each paraphrased-query response on their core conclusion or stance. A high
score means the system reaches the same conclusion regardless of how the question
is worded; a low score means paraphrasing flips its stance. Higher is better.
summary: Measures whether the system reaches the same conclusion or stance when
its query is paraphrased, compared against its original answer.
worked_example: A row's query is reframed via a paraphrase template into a differently-worded
variant; with responses_per_query=3, 2 fresh responses to that variant are each
compared against the row's existing response (2 comparisons) — 1 judged Consistent
(0.95) and 1 judged Slightly Inconsistent (0.7) -> mean = 0.825.
metric_type: pointwise
name: llm.semantic_consistency
partition_types: []
required_columns:
- input_id
- prompt
- sut_response
required_kinds: []
scorer_contract: per_row
target_kind: null
unsupported_trace_shapes: []
version: 1.0.0