﻿# Ragas ID-based precision: document and chunk identities must share a namespace

Use Ragas ID-based retrieval precision only after aligning reference and retrieved identities, including chunk granularity, corpus revisions and duplicate handling.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-ragas-id-context-precision-document-chunk-namespace/
Language: en

## Declare the retrieval unit

An application may retrieve chunks while an evaluation labels whole documents. Comparing their identifiers directly can make correct retrieval appear wrong. Ragas [ID-based context precision](https://docs.ragas.io/en/stable/concepts/metrics/available_metrics/context_precision/) compares retrieved and reference identities instead of analyzing content. Define the unit first: document, versioned passage or another declared object. A convenient common-looking string format does not establish that both lists refer to the same granularity or the same corpus snapshot.

## Align namespaces before computing the score

The [evaluation-sample contract](https://docs.ragas.io/en/stable/concepts/components/eval_sample/) separates fields used by different measurements. Build an explicit mapping if reference labels and runtime retrieval originate in different systems. Retain original identifiers alongside the mapped values so mismatches remain auditable. Avoid mapping every chunk from a relevant document to a single positive identifier without considering whether the task labels all of that document's contents as useful; such collapsing can reward irrelevant passages from an otherwise relevant source.

## Inspect what the formula omits

The documented ID-based rule measures how many retrieved identities belong to the reference set relative to the retrieved population. Unlike semantic judgments, it does not read the passage. A matched ID can point to stale or changed text if identity is reused across corpus versions. It also does not establish whether the answer used the evidence correctly. Treat those as separate checks instead of describing a high identity-match score as proof of grounded generation.

## Keep duplicate policy and revisions explicit

The [dataset guide](https://docs.ragas.io/en/stable/concepts/datasets/) provides experiment context. Inspect how the installed metric handles repeated IDs and how the application deduplicates retrieved results before scoring. Preserve the preprocessed and observed lists when that distinction matters. Version the reference labels with the corpus. A re-chunking operation can invalidate the identity contract even if the source documents and user questions remain unchanged, so regenerate or deliberately migrate labels rather than silently reusing them.

## Test mapping failures deliberately

Use diagnostic cases with a relevant document's wrong chunk, a changed corpus revision and a repeated retrieval result. Check that the reported value follows the declared unit and policy. The guides to [unjudged retrieval labels](/journal/beir-qrels-unjudged-retrieval-evaluation/) and [context lineage](/journal/fg2-deepeval-conversation-turn-retrieval-context-lineage/) provide related controls. Report this metric as agreement with labeled retrieval identities, allowing semantic relevance, label completeness and downstream answer correctness to remain independently reviewable.
