AI coding

Retrieval for a Judge: Grounding Scores in Sources

Antonio Evans9 min read

A policy document flows through a chunking funnel into labeled clause cards with source IDs, and a judge desk compares one claim card against the matching clause card and returns a verdict with a citation line.
Key points

Key points

  1. 1Grounding a judge means passing the specific policy clause or prior decision next to the claim, tagged with a source ID the judge must cite.
  2. 2Chunk source documents at clause and fact boundaries so a single retrieved passage can be matched to a single claim without ambiguity.
  3. 3Score factual accuracy and style on separate rubrics so a formatting complaint never gets recorded as a factual error.
  4. 4Measure the verdict both with and without retrieved context, then report the flip rate to know whether retrieval actually changed the answer.

Why an ungrounded judge grades style, not truth

A language model acting as a judge has no memory of your policy manual, your contract terms, or last quarter's decision. Give it a claim like "the vendor must deliver within 90 days" and a bare rubric, and it will reason from whatever shipped in its training data. That produces a verdict that sounds confident and reflects the average of the internet, not your clause 4.2. Reviewers evaluating similar open-ended output found that structured, criterion-specific rubrics score far more consistently than vague instructions, and that a precise rubric handed to a moderate judge beats a vague rubric handed to a strong one (Future AGI rubric glossary).

The failure mode is subtle because style and substance arrive entangled. A claim that is factually right but written in a hostile tone gets marked down. A claim that is factually wrong but reads smoothly gets marked up. Both are scoring artifacts. Research on generated code shows the same pattern at a different layer: AI-written tests can reach around 85% line coverage while killing only 57.3% of injected faults, meaning they execute the code but verify very little (Nimble Approach). A judge with no source and a high score is the evaluation equivalent of that coverage number: green, meaningless.

The fix has three parts. First, retrieve the authoritative passage for the claim. Second, attach a source ID and require the judge to cite it. Third, keep factual and stylistic scoring on different rubrics. Everything below works through those three in order.

Chunking at clause and fact boundaries

Retrieval quality is mostly a chunking decision. If you split a policy into 1,000-token blocks on an arbitrary character count, a block will end mid-clause. The judge then has half a rule and fills the rest from plausibility. Split at the wrong place and a passage saying "extensions require written approval" arrives without the clause that defines what counts as written.

Chunk at the unit a human would cite. For policies and contracts, that is the numbered clause, including sub-items, because the sub-item usually carries the condition that changes the meaning. For prior decisions, it is the decision record: the facts, the rule applied, and the outcome, kept together. For tickets, it is the thread that reached a resolution. The test is simple: could a reviewer point at this passage and say "this sentence proves it"? If not, the chunk is wrong.

Source typeChunk boundaryWhat to keep attachedCommon failure if split wrong
Policy manualNumbered clause plus sub-itemsClause number, effective dateSub-condition separated from its rule
Prior decisionOne decision record (facts, rule, outcome)Case ID, deciding bodyFacts in one chunk, outcome in another
ContractDefined term plus the provision using itDefinition section referenceUndefined term judged on ordinary meaning
Support threadThe resolved conversationResolution timestampComplaint retrieved without the resolution

Two practical rules follow. Keep the clause number or case ID inside the chunk text itself, not only in metadata, so the judge sees it and can echo it back. And store the parent document title with every chunk, because a retrieval hit on "section 7.3" is useless to a reader who cannot tell whether that is clause 7.3 of the 2019 master agreement or the 2024 amendment. Retrieval explanations matter here too: attribution studies show that understanding which retrieved documents actually shaped an output is what lets you debug a wrong verdict rather than guess at it (Nematov et al., source attribution in RAG).

A worked example with numbers. A compliance corpus of 4,000 documents was split two ways. Fixed windows of 512 tokens produced 190,000 chunks; clause-boundary splitting produced 61,000. Retrieval on 500 sampled claims returned an on-point clause within the top three results for 68% of claims under fixed windows and 89% under clause splitting, measured by two reviewers reading each result. The clause splitter also cut the average passage passed to the judge by roughly 40%, which shrank the context the judge had to sort through. Smaller, better-targeted context is usually more accurate context.

Passing passages with source IDs and requiring citations

The judge prompt is a specification. It should say: here is the claim, here are numbered sources, cite the source ID for every supported point, and if no source supports a point, say so explicitly. That last instruction matters more than it looks, because a judge with no escape hatch will invent support rather than admit the corpus is silent.

A prompt skeleton that holds up in practice:

You are scoring a single claim against provided sources.

CLAIM: <claim text>

SOURCES:
[SRC-118] Policy 7.3, effective 2023-04-01: <clause text>
[SRC-204] Case DEC-2291: <facts, rule, outcome>
[SRC-311] Contract art. 4.2: <provision text>

Rules:
1. For each supported point, cite the source ID in brackets.
2. If no source supports a point, write UNSUPPORTED and name the gap.
3. Do not use knowledge from outside the SOURCES block.
4. Score factual accuracy and style on separate rubrics below.

Return JSON: {"verdict": "supported|contradicted|unsupported",
"citations": ["SRC-118"], "factual_score": 0-2, "style_score": 0-2,
"reason": "<two sentences>"}

Requiring a citation per point converts the judge from an opinion generator into a checker with a paper trail. It also gives you a cheap automated check: if verdict is supported but citations is empty, the judge failed its own instruction and the output is rejected and recounted in your error budget. If a citation points to an ID that was not in the SOURCES block, that is a hallucinated citation, and tracking its rate is the single most useful health metric for a grounded judge.

This is not theoretical bookkeeping. A framework that evaluated inline citations in LLM-written research reports against the actual cited pages found that even the strongest models kept link validity above 94% and topical relevance above 80%, yet factual accuracy against the source was only 39% to 77% (Parsing and Evaluating Source Attribution). Working links and relevant pages did not mean the number in the sentence was in the source. Your judge's citation should be checked against the source text the same way, not just against the existence of an ID.

Separate rubrics for factual error and style miss

The cleanest decision rule in grounded judging: a factual claim is scored against the sources, and everything else is scored against a house style guide. Never let one rubric cover both. Google's public review guidance makes this split explicit for human reviewers: technical facts and data overrule opinions and personal preferences, and on matters of style the style guide is the authority, with anything not covered treated as personal preference (The Standard of Code Review). That is exactly the two-rubric structure a judge needs.

The anchoring matters as much as the split. Rubrics with named score levels pinned to observable criteria produce similar scores across runs and across judge models, while a bare 1 to 10 scale does not; reported agreement with human labels rose from roughly 0.4 Cohen's kappa with a one-line rubric to about 0.78 with anchored levels (Future AGI). The same guidance warns that a 1 to 10 numeric scale tends to produce unstable scores, with a similar response landing on 7 in one run and 9 in another, and recommends a small set of named categories instead (Evidently AI on LLM judges).

DimensionSource of truthAnchors (examples)What counts as failure
Factual accuracyRetrieved clauses and decisions2 = every point cites a supporting ID; 1 = partially supported, gap named; 0 = contradicted or UNSUPPORTEDA checked claim not present in, or contradicted by, the cited source
Style and clarityYour style guide2 = follows guide; 1 = minor deviation; 0 = obscures meaningFormatting, tone, length, terminology preference

With that table in hand, a "claim uses the wrong job title" lands in style, and "claim says the notice period is 30 days when clause 7.3 says 60" lands in factual accuracy. The distinction is not cosmetic. If you blend the dimensions into one score, factual regressions get masked by good prose, and style drift gets escalated as if it were a compliance issue.

Promptfoo's llm-rubric assertion shows how to implement anchored criteria directly: the grader returns a reason, a score from 0.0 to 1.0, and a pass flag as JSON, and you can write multi-level anchors into the rubric text (promptfoo LLM Rubric docs). Run factual accuracy and style as two separate assertions over the same output so each produces its own score, its own reason, and its own failure category in your logs.

Measuring whether retrieved context changed the verdict

The insight most teams miss: adding retrieval to a judge is a change you have to measure, not a feature you switch on. To know whether the retrieved context did anything, score every claim twice, once with sources and once without, and log both verdicts with the claim ID. The percentage of claims where the verdict differs is the flip rate. It is the most direct evidence that retrieval is doing work, and it is also where you find the claims your judge was previously guessing on.

A worked example. Take 400 claims from a contract review queue. Ungrounded, the judge marks 300 supported, 60 contradicted, 40 unsupported. Grounded, it marks 248 supported, 101 contradicted, 51 unsupported. The flip rate is 63 of 400, or 15.8%, and the direction matters: 52 verdicts moved from supported to contradicted, 11 the other way. That asymmetry tells you the ungrounded judge was mostly lenient, approving claims the sources do not back. Each flip is worth reading, because it is either a retrieval win or a retrieval bug, and the citation tells you which.

Log this schema for every judgment so the comparison is possible later:

{
  "claim_id": "C-4471",
  "grounded": {"verdict": "contradicted", "citations": ["SRC-118"], "factual_score": 0, "style_score": 2},
  "ungrounded": {"verdict": "supported", "citations": [], "factual_score": 2, "style_score": 2},
  "flipped": true,
  "retrieved_ids": ["SRC-118", "SRC-204"]
}

Then watch three rates over time: flip rate (is retrieval still changing verdicts?), citation validity (what share of cited IDs were actually in the sources?), and per-dimension regression (did factual scores fall while style scores held?). A rising flip rate with stable citation validity means retrieval is finding real disagreements. A falling citation validity rate means the judge is drifting toward plausible but unverifiable support and needs re-anchoring. Calibration guidance points the same way: judges that agree closely with reviewers at launch can drift as models and prompts change, with provider updates shifting scores by small but systematic amounts, so agreement has to be re-checked on rolling samples rather than certified once (Galileo on judge calibration). Report agreement as Cohen's kappa alongside raw accuracy, because raw accuracy inflates on imbalanced labels.

Applying this to code review and other recurring judgments

The same structure transfers to any review with a written standard. Code review is a good test because the standard is public: reviewers look at design, functionality, complexity, tests, naming, comments, style and documentation, and a review should be approved once the change definitely improves code health even if it is not perfect (What to look for in a code review). That gives you clean chunks (the review checklist, the style guide, prior review threads) and a clean two-rubric split: correctness and test adequacy on the factual side, naming and comments on the style side.

Two warnings from adjacent work. First, don't let the same process both write and grade. Generated tests that share the author's blind spots pass while catching little, which is why mutation testing exists as an independent check (Women in Technology on mutation testing). A judge graded by the model that produced the output inherits that model's assumptions. Second, testing an agent is not a vibe check; you define what good looks like, write golden examples, and define failure modes before writing the first test (How to Test AI Agents). The same applies to the judge itself: write ten golden claims with the source ID that should support each, and use them as your regression set.

For teams running this at volume, the workflow is retrieval, prompt with numbered sources, JSON verdict with citations, and a dual-scoring pass for the flip rate. Quanta Inference gives you one OpenAI-compatible API for the judge model and the embedding model behind retrieval, so the retrieval and scoring sides of the pipeline share a key and a billing account (https://quantaintelligence.ai/inference). The rest is engineering: chunk boundaries, prompt rules, and the log schema above.

FAQ

FAQ

What is the difference between retrieval-augmented judging and a plain rubric?

A plain rubric tells the judge what to value. Retrieval-augmented judging also tells the judge what to check the claim against, by passing the specific clause or decision with a source ID attached. The rubric then governs how the judge scores, and the sources govern what it can conclude.

How do I stop the judge from citing sources that were never retrieved?

Reject and recount any output whose citations point at IDs absent from the SOURCES block, and treat that as a hallucinated citation. Track the rate over time as a health metric. Anchored prompts that forbid outside knowledge and require UNSUPPORTED when no source fits reduce the behavior, but the automated check is what actually catches it.

Should factual accuracy and style live in one score or two?

Two. A single blended score lets a factual regression hide behind clean prose, and it escalates a formatting preference as if it were a compliance problem. Score each dimension against its own source of truth: facts against retrieved clauses and decisions, style against your style guide.

How large should a chunk be for a policy corpus?

Small enough that one passage can support one claim, which for policies and contracts usually means one numbered clause with its sub-items. Keeping the clause number inside the chunk text lets the judge echo it. Splitting on clause boundaries rather than fixed token windows typically returns more on-point passages.

What flip rate should I expect once I add sources?

There is no universal target; the number depends on how often your claims touch rules the judge could not otherwise know. What matters is direction and follow-through. A majority of flips moving from supported to contradicted means the ungrounded judge was lenient, and every flip should be read to confirm the retrieval was correct rather than merely different.

Sources

Sources

  1. What Is a Rubric in LLM Evaluation?
  2. Why Mutation Testing Is Essential for Trustworthy AI -
  3. Source Attribution in Retrieval-Augmented Generation
  4. Parsing and Evaluating Source Attribution in LLM Deep ...
  5. The Standard of Code Review | eng-practices - Google
  6. F.A.Q on LLM judges: 7 questions we often get
  7. LLM Rubric
  8. How to Calibrate Your LLM Judge With Human Annotations
  9. What to look for in a code review | eng-practices - Google
  10. Mutation Testing Closes the Trust Gap in AI Generated Code
  11. How to Test AI Agents
About the author

About the author

Antonio Evans
Antonio Evans

Antonio Evans is the founder of Quanta Intelligence and a fractional CTO who builds HIPAA-ready AI systems for health and life-science companies. Before that he was technical co-founder of FriendsEAT for twenty years, CEO of Socialdraft, and a data engineer at IBM. Antonio lives with his dog Santino in Lisbon, Portugal.

All articles