Sub topic 10
Writing a Grounded Answer and Attaching Citations
Assume you understand basic web crawling, HTTP requests, and the role of a large language model. This chapter focuses on the final stage of an answer engine: turning retrieved passages into an answer and linking each claim to supporting sources.
What “grounded” means
A grounded answer is an answer whose factual claims come from retrieved source material. The model does not rely only on its general training. It receives passages, documents, or search results as context and uses them to compose a response.
The system usually keeps information about each passage, such as its URL, title, and position in the source page. That information is called provenance. Provenance lets the system connect a sentence in the answer to the page or passage that supports it.
A citation is useful only when the cited page supports the claim beside it. Linking to a related page is not enough. For example, a page about API key security may be relevant to a claim about key rotation, but it does not support a specific rotation interval unless it states one.
The answer pipeline
A simplified pipeline looks like this:
The engine first extracts passages that match the user's question. It then gives the model those passages together with source metadata. The model drafts an answer that combines the evidence.
A citation layer may attach links while the answer is generated or afterward. The exact method differs between products. In either case, the intended relationship is:
- A claim appears in the answer.
- One or more retrieved passages support that claim.
- A citation appears close enough for the reader to identify the source.
A single citation can support several sentences when the source clearly covers all of them. Separate citations are safer when claims come from different pages or when only part of a sentence is supported.
Keep claims within the evidence
Grounding does not require copying a source word for word. It requires preserving the source's meaning and limits.
Consider this source passage:
API keys should be rotated after suspected exposure. Store replacement
keys before revoking the old key so dependent services can be updated
without an outage.A grounded answer could say:
After suspected exposure, prepare a replacement key before revoking the old one. This helps dependent services switch without an outage. [Source]An ungrounded answer would add a detail that the passage does not contain:
Rotate the key every 30 days and keep both keys active for 24 hours. [Source]The citation does not support either time period. The model may know that such practices exist, but that knowledge did not come from the cited passage.
| Claim type | Evidence needed | Safe citation practice |
|---|---|---|
| Definition | A source that defines the term | Cite the definition directly |
| Number or date | A source stating the exact value | Place the citation next to the value |
| Recommendation | A source that makes the recommendation | Identify whose recommendation it is |
| Comparison | Evidence about each side | Use multiple citations when needed |
What makes a citation trustworthy
Answer engines commonly weigh several signals when selecting sources and citations:
- The passage directly answers the question.
- The page has identifiable authorship and an appropriate publication or update date.
- The source is consistent with other reliable sources.
- The passage contains a complete explanation rather than a fragment.
- The page is accessible and can be retrieved again.
- The source matches the scope of the claim.
A citation can still vary between runs. Query rewriting may produce different searches, ranking may change, and several pages may support the same claim. Therefore, citation visibility is an outcome to measure, not a result that a site can guarantee.
A practical review method
When reviewing an answer, mark each factual statement and ask:
- Which retrieved passage supports this statement?
- Does the passage support the whole statement?
- Is the citation close to the statement?
- Does the answer distinguish sourced facts from inference?
- Is the source current enough for the topic?
If no passage supports a claim, the system should remove it, qualify it as an inference, or search for better evidence.
Exercise
A retrieved page says that a product supports CSV export. Can a grounded answer cite that page to claim that exports include UTF-8 encoding and preserve formulas?
Show answer
No. The page supports CSV export only. The answer needs evidence for UTF-8 encoding and formula preservation, or it must omit those details.