Context Precision
rag.context_precision
Measures how much of the retrieved material is actually relevant to the answer, rewarding relevant chunks that are ranked near the top.
Contract
| Field | Value |
|---|---|
version | 1.0.0 |
metric_type | pointwise |
scorer_contract | per_row |
direction | higher_is_better |
entrypoint | aip_metrics_rag.answered.context_precision |
target_kind | None |
Required columns
input_idpromptexpected_outputsut_responseretrieved_context
Accepted schemas
[
{
"name": "gdi_text_v1",
"task_types": [
"multi_turn_rag",
"single_turn_rag"
]
}
]
Methodology
- An LLM judge (Ragas LLMContextPrecisionWithReference) receives the question, the reference answer, and each retrieved chunk.
- The judge decides, per chunk, whether it was useful for producing the reference answer.
- Ragas computes the rank-weighted mean average precision over the retrieved order.
- The score is normalised to 0-1 (a NaN verdict is surfaced as an error).
Score semantics
Scores range 0-1. A high score means relevant chunks are concentrated at the top ranks with little noise; a low score means relevant chunks are buried among irrelevant ones. Higher is better.
Worked example
For retrieved chunks ranked [relevant, irrelevant, relevant], the judge marks them [1, 0, 1]; mean average precision ~ 0.83.
Configuration schema
{
"properties": {
"concurrency_limit": {
"default": 10,
"title": "Concurrency Limit",
"type": "integer",
"x-aip-param-role": "operational"
},
"inverted": {
"default": false,
"title": "Inverted",
"type": "boolean",
"x-aip-param-role": "scoring_metadata"
},
"lang": {
"default": "en",
"enum": [
"en",
"de",
"fr"
],
"title": "Lang",
"type": "string"
},
"max": {
"default": 1.0,
"title": "Max",
"type": "number",
"x-aip-param-role": "scoring_metadata"
},
"metric_name": {
"default": "context_precision",
"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"
},
"model": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": "gpt-4o",
"title": "Model"
},
"system_type": {
"const": "rag",
"default": "rag",
"title": "System Type",
"type": "string",
"x-aip-param-role": "judge_wiring"
},
"weight": {
"default": 1.0,
"title": "Weight",
"type": "number",
"x-aip-param-role": "scoring_metadata"
}
},
"title": "InitializationConfig",
"type": "object"
}
Execution
{
"emits_metric_family": false,
"function_name": null,
"max_concurrency": 8,
"processing_kind": "network",
"stream_batch_size": null,
"timeout_seconds": 900
}
Complete manifest
accepts:
- name: gdi_text_v1
task_types:
- multi_turn_rag
- single_turn_rag
config_schema:
properties:
concurrency_limit:
default: 10
title: Concurrency Limit
type: integer
x-aip-param-role: operational
inverted:
default: false
title: Inverted
type: boolean
x-aip-param-role: scoring_metadata
lang:
default: en
enum:
- en
- de
- fr
title: Lang
type: string
max:
default: 1.0
title: Max
type: number
x-aip-param-role: scoring_metadata
metric_name:
default: context_precision
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
model:
anyOf:
- type: string
- type: 'null'
default: gpt-4o
title: Model
system_type:
const: rag
default: rag
title: System Type
type: string
x-aip-param-role: judge_wiring
weight:
default: 1.0
title: Weight
type: number
x-aip-param-role: scoring_metadata
title: InitializationConfig
type: object
dependencies: []
description: How much of the retrieved material is actually relevant, with little
noise?
direction: higher_is_better
display_name: Context Precision
entrypoint: aip_metrics_rag.answered.context_precision
execution:
emits_metric_family: false
function_name: null
max_concurrency: 8
processing_kind: network
stream_batch_size: null
timeout_seconds: 900
kind: metric
manifest_version: '1'
max_prompt_slots: 0
metric_metadata:
methodology:
- An LLM judge (Ragas LLMContextPrecisionWithReference) receives the question, the
reference answer, and each retrieved chunk.
- The judge decides, per chunk, whether it was useful for producing the reference
answer.
- Ragas computes the rank-weighted mean average precision over the retrieved order.
- The score is normalised to 0-1 (a NaN verdict is surfaced as an error).
score_semantics: Scores range 0-1. A high score means relevant chunks are concentrated
at the top ranks with little noise; a low score means relevant chunks are buried
among irrelevant ones. Higher is better.
summary: Measures how much of the retrieved material is actually relevant to the
answer, rewarding relevant chunks that are ranked near the top.
worked_example: For retrieved chunks ranked [relevant, irrelevant, relevant], the
judge marks them [1, 0, 1]; mean average precision ~ 0.83.
metric_type: pointwise
name: rag.context_precision
partition_types: []
required_columns:
- input_id
- prompt
- expected_output
- sut_response
- retrieved_context
required_kinds: []
scorer_contract: per_row
target_kind: null
unsupported_trace_shapes: []
version: 1.0.0