Citation generation

Also known as: source attribution · answer attribution

On this page 7

Citation generation is the process by which a language model system attaches references to the source passages that support the statements in its generated answer, so that a reader can verify each claim. In the retrieval & knowledge branch of artificial intelligence, it is the final, user-facing step of retrieval-augmented generation (RAG), and it is also called source attribution or answer attribution.

A citation is useful only when it is both correct and sufficient: the cited passage must actually exist in the retrieved context, and it must genuinely support the claim it is attached to. Producing citations that look plausible is easy; producing citations that hold up under checking is the real engineering problem.

How citation generation works in a RAG pipeline

A typical pipeline assigns an identifier to every retrieved chunk, places the chunks in the prompt with those identifiers, and instructs the model to cite identifiers inline after each claim. The application then resolves identifiers into readable references, such as a document title, page number or highlighted span, and renders them as footnotes or links.

The process has several distinct stages, and errors at any stage surface as bad citations. The table below lists the stages and the most common failure at each.

StagePurposeTypical failure
RetrievalFind passages relevant to the questionSupporting evidence never retrieved
Chunk labelingGive each passage a stable identifierIdentifiers lost after reranking or truncation
Grounded generationWrite claims tied to identifiersClaim cites the wrong passage
VerificationCheck that each citation supports its claimSkipped for latency reasons
RenderingShow sources to the readerLink points to a whole document, not the span
Stages of citation generation and typical failures

The verification stage is where mature systems differ most. A natural language inference (NLI) model or a second language model call can judge whether the cited text entails the claim, and unsupported sentences can then be removed, rewritten or flagged.

Approaches to attributing answers

There are four broad approaches, which differ in when attribution happens relative to generation. Many production systems combine two of them, for example inline citation followed by post-hoc verification.

ApproachHow it worksStrengthWeakness
Prompted inline citationModel writes numbered source markers while answeringSimple, no extra modelMarkers can be fabricated or misplaced
Post-hoc attributionClaims are matched to passages after generationWorks with any generatorMay find no support for a claim
Quote-first generationModel extracts exact quotes, then answers from themHigh precision, easy to verifyLonger outputs, higher latency
Fine-tuned attributionModel is trained on cited answersConsistent citation behaviorNeeds labeled training data
Main approaches to citation generation

Some model APIs now provide native citation features that return character offsets into the supplied documents. These reduce identifier fabrication because the model points to exact spans of the input rather than writing free-form references.

Measuring citation quality

Citation quality is measured with citation recall and citation precision, terms that adapt familiar retrieval metrics to attribution. Recall asks whether every claim that needs support has a citation that supports it; precision asks whether every citation actually contributes support to its claim.

MetricQuestion it answersTypical method
Citation recallIs every claim supported by its citations?NLI entailment over claim and cited text
Citation precisionIs each citation actually relevant?Remove citation and test whether support remains
FaithfulnessDoes the answer stay within the context?Claim-level checking against retrieved passages
Answer correctnessIs the answer factually right?Comparison with reference answers
Metrics used to evaluate citations

These metrics measure different things. An answer can have perfect citation precision and still be wrong if the retrieved source itself is outdated or incorrect, which is why citation evaluation belongs inside broader RAG evaluation rather than replacing it.

Citation generation is closely tied to grounding, but the two are not identical. Grounding constrains what the model says to the supplied evidence, while citation generation makes that relationship visible to the reader. A grounded answer without citations cannot be checked easily, and a cited answer that is not grounded is misleading.

It also differs from search grounding, in which a model queries a web search engine and cites results, and from bibliographic citation formatting, which concerns styles such as APA rather than evidence linking. Methods such as Self-RAG add a learned critique step that judges whether retrieved passages support each output segment, which directly improves citation reliability.

Citation generation also interacts with chunking and reranking. Very small chunks give precise citations but may split the evidence a claim needs across several passages, while very large chunks keep evidence together but make each citation harder to verify by eye. Chunks of a few hundred words, combined with span highlighting, are a common compromise in practice.

Finally, multi-hop questions pose a particular challenge. When an answer combines facts from two documents, a single sentence may need two separate citations, and the model must avoid presenting an inference that neither source states on its own as if one source supported it directly.

Design practices and common pitfalls

Reliable citations depend more on pipeline design than on prompt wording alone. The following practices address the failure modes seen most often in deployed assistants.

  • Use short, stable chunk identifiers and keep them unchanged through reranking and context assembly.
  • Cite at sentence or claim level, not once per paragraph, so that each statement can be traced.
  • Validate every identifier against the retrieved set and drop markers that point nowhere.
  • Link to the exact span or page, because a citation to a 200-page manual is barely verifiable.
  • Allow the model to say the sources do not answer instead of forcing a cited guess.

The most serious pitfall is citation laundering, where a correct-looking reference lends false authority to an unsupported claim. Readers tend to trust cited text more, so a wrong citation can be more harmful than no citation at all.

In simple terms

When an AI assistant answers from a set of documents, citation generation adds small markers. Each marker shows which document backs up which sentence. A reader can click it and check the original text.

It works like footnotes in a good report. The footnote is only helpful if the page it points to really says what the sentence claims. Good systems check this before showing the answer.

A practical example

An insurance company deploys an internal assistant that answers employee questions about claims-handling policies. The policy library holds about 4,000 documents, split into chunks of roughly 300 words. Each chunk carries an identifier that combines the document name, section number and page.

When an adjuster asks how long a customer has to report water damage, the assistant retrieves eight chunks, writes a three-sentence answer and cites the policy section after each sentence. A verification step uses an entailment model to check every claim against its cited chunk and removes one sentence that the sources do not support. The adjuster sees the answer with page-level links into the policy text, confirms the 30-day reporting window in seconds, and the compliance team gains an auditable trail showing which document informed each decision.