Evaluation

Grounding

Tying model outputs to verifiable sources. Usually retrieved documents or tool results.

Last updated: October 17, 2026

What Is Grounding?

Grounding means the model's answer comes from a specific, traceable source rather than its training data. The cleanest pattern is to pass retrieved documents or tool results as context, instruct the model to answer only from them, and require it to cite which source supports each claim. Grounded outputs can be verified after the fact. Ungrounded outputs cannot. Providers now build parts of this in. Anthropic Citations returns the exact passages that support each claim from documents you supply, and Gemini offers grounding with Google Search, where the model draws on web results and cites its sources.

A citation shows where a claim came from, not that the claim is right. Anthropic states that citations contain valid pointers to the documents you provided, but a model can still attach a real passage to a sentence it does not support. So grounding needs two checks: the cited source exists, which is mechanical, and the source supports the claim, which needs a judge model or human spot check. Ground on sources you trust, because a wrong, stale or hostile page (see indirect prompt injection) yields a wrong answer with a citation attached.

Code Example

python
import re

sources = {1: "Refunds are available within 30 days of delivery."}
numbered = "\n".join(f"[{n}] {text}" for n, text in sources.items())
prompt = f"Answer only from these sources and cite them as [n].\n{numbered}\nQuestion: ..."

model_answer = "You have 30 days from delivery [1]."  # mocked model output
cited = {int(n) for n in re.findall(r"\[(\d+)\]", model_answer)}
print(cited <= set(sources))  # True: every citation points at a real source

Number the sources, demand [n] citations, then check that each one points at a real source. The model answer is mocked. This proves the source exists, not that it supports the claim.

When Should You Use Grounding?

Required for any answer that could be wrong with consequences: legal, medical, financial, policy and pricing. Pair it with RAG so sources come from your own indexed data, and test with questions the sources cannot answer. Grounding lowers hallucination on the topics your sources cover. It does not remove it, and it does not help outside the indexed material.

Common Questions

What is the difference between grounding and RAG?

RAG is a technique that retrieves relevant text. Grounding is the goal of tying an answer to a source. RAG is the most common way to supply sources, but tool results, uploaded documents and web search can ground an answer too.

Sources

Related Terms

Building with Grounding?

I've shipped this pattern in real production systems. If you want a second pair of eyes on your architecture, that's what I do.