DEV Community

Devanshu Biswas
Devanshu Biswas

Posted on

Grounding and citations: making LLM answers you can actually verify

An LLM will hand you a smooth, confident paragraph and never once tell you which parts it made up. Fluency is not truth. The fix is grounding: force the answer onto retrieved evidence, attach a citation to every claim, and then check that the citations actually hold. Here it is, live and interactive.

📎 Play with the grounding + citations demo: https://dev48v.infy.uk/ai/days/day26-grounding.html

Fluent is not the same as true

A language model is trained to produce the most plausible next token, not the most correct statement. So "The Eiffel Tower is made entirely of stainless steel and draws 50 million visitors a year" reads perfectly and is completely unsupported. If you already knew the facts you'd catch it. If you didn't, you'd ship it. That gap is where grounding earns its keep.

Grounding: answer only from the evidence

Grounding means the answer is generated conditioned on a specific set of retrieved passages, with a hard instruction to use nothing else. Retrieval (that's RAG) fetches the passages; grounding is the discipline of staying inside them. If a fact isn't in the sources you handed the model, a grounded answer shouldn't state it. That single rule dramatically shrinks the model's room to invent.

Citations: a checkable link from claim to source

A citation attaches a marker like [2] to a sentence, pointing at the exact source it came from. That turns an answer from a monolith you must trust wholesale into a list of statements you can audit one at a time. It also gives an automated verifier something concrete to line up: this sentence, against that snippet.

The prompt is where you make it happen:

Answer using ONLY the numbered sources below.
- End every sentence with the source id(s) it comes from, e.g. [2].
- Use no outside knowledge. Do not guess.
- If the sources don't cover it, say:
  "I don't have enough information in the provided sources."
Enter fullscreen mode Exit fullscreen mode

Requiring the exact span id matters. "According to the sources" is decoration; [2] is checkable.

Don't trust the model's own [n] — verify it

A model can cite the wrong source, or cite one that doesn't actually support the claim. So verify independently. The cheap proxy is lexical overlap: tokenize the claim, tokenize its cited source, and measure how many content words they share. A supported sentence reuses the evidence's words; an invented one has almost nothing in common with any snippet.

overlap = shared_content_words / content_words_in_claim
supported = overlap >= 0.45
Enter fullscreen mode Exit fullscreen mode

Run that on the Eiffel Tower example and the three real claims score around 1.0 against their sources, while the stainless-steel invention scores near zero and gets caught. The demo does exactly this in your browser, then drops the unsupported claim from the grounded answer. The stronger version swaps overlap for an NLI "entailment" model that asks "does this source entail this claim?", which survives paraphrase and handles negation.

Faithfulness vs relevance — you need both

These are two different axes. Faithfulness asks: does the answer stay true to the sources, with no claim beyond what they support? Relevance asks: does it actually answer the question? An answer can be faithful but off-topic, or bang-on relevant but full of fabrication. Grounding targets faithfulness. You still have to check relevance separately.

Abstaining is a feature

Grounding's quiet superpower is the ability to say "I don't know." If no source supports a claim, drop it. If nothing at all is supported, refuse: "I don't have enough information in the provided sources." That feels like failure and is the opposite. A calibrated refusal beats a confident fabrication every time, especially anywhere the stakes are real.

Measure it

To improve grounding you have to score it. Two numbers to watch: citation precision (of the citations given, how many actually support their claim) and citation recall (of the claims that needed a source, how many got a correct one). Add a faithfulness rate and track all three on a labelled set, so a change that "sounds nicer" but quietly adds hallucinations gets flagged instead of shipped.

The honest limits

Grounding reduces hallucination and makes answers auditable. It does not guarantee truth. Overlap checks can be fooled by copied words or defeated by paraphrase; NLI models make mistakes; a citation can be plausible yet wrong; and if the sources themselves are outdated or false, you get grounded garbage. Grounding ties the answer to the sources, not to reality. For high-stakes work, keep a human in the loop.

The full walkthrough has a LOOK tab (toggle two scripted questions and watch the invented claim get caught), an UNDERSTAND tab with ten steps, and a BUILD tab with the retrieve → cite → verify → abstain pipeline in code:

👉 https://dev48v.infy.uk/ai/days/day26-grounding.html

Tomorrow: Day 27 — RLHF.

Top comments (0)