How to Make an AI Assistant Give Source-Backed Answers

Written by

Emil Sorensen

Updated

Short answer

An AI assistant gives source-backed answers when every claim it makes can be traced to a specific passage in a specific document, and the user can click through to check. That requires five things working together: source URLs preserved through ingestion, retrieval that returns citable passages rather than blended context, explicit instruction at both the tool and prompt level, an "I don't know" path for questions the sources do not cover, and evaluation that scores whether the citations are real rather than just whether the answer sounds right.

Most teams do the first two and skip the last three. That is why so many assistants produce answers with links attached that do not support the sentences they are attached to.

What "source-backed" actually means

The phrase gets used loosely. Three different things are often described as source-backed, and they are not equivalent:

Level

What the user sees

What it guarantees

Source list

A list of documents consulted, usually at the end

The system read these. Nothing about whether the answer came from them.

Answer-level citation

One or more links attached to the whole answer

The answer is broadly related to these documents.

Claim-level citation

A citation attached to each claim, pointing at the passage that supports it

A specific sentence is backed by a specific passage the user can read.

Only the third is verifiable in the way users assume. If your assistant returns a paragraph with three factual claims and one link at the bottom, a reader who wants to check the second claim has to read the whole linked page and hope. That is a citation in appearance rather than in function.

Claim-level citation is the target. Everything below is about how to get there.

Why retrieval alone does not produce source-backed answers

A common assumption is that retrieval-augmented generation is inherently grounded, because the model is given real documents to work from. It is not. Retrieval changes what the model sees. It does not change what the model does with it.

Three things go wrong even in a well-built retrieval pipeline:

The model answers from training data anyway. Retrieved passages sit in the context window alongside everything the model already knows. If the passages are thin and the model has a confident prior, it will often blend the two, then cite the retrieved document for a claim that came from pretraining. This is the failure that faithfulness measures, and it is the hardest of the three to catch, because the answer is frequently correct. Correct and ungrounded is still ungrounded, and it fails the moment your product diverges from what the model learned.

Citations are generated as text, not as structure. If the model is asked to write citations into its output as markdown links, it is producing those links the same way it produces every other token, by prediction. It can produce a plausible URL that does not exist, or attach a real URL to the wrong sentence. Recent research on structured inline citation generation and on how attribution actually works inside RAG models treats this as an open problem rather than a solved one. This is the same class of failure that hallucination in AI assistants exhibits generally, applied to the citation layer specifically.

Retrieval succeeds and the model still has nothing to say. The pipeline returns the top five chunks whether or not any of them are relevant. If the knowledge base does not cover the question, the model receives five weakly related passages and, absent instruction to the contrary, writes an answer from them. The citations will be real. The answer will be wrong.

How to make an AI assistant cite its sources

1. Preserve source URLs through ingestion

This sounds trivial and is the most common place the chain breaks. Web-crawled content carries its URL naturally. Everything else does not. PDFs uploaded directly, files pulled from cloud storage, exported wiki pages, and ticket archives all arrive without a canonical address unless you attach one at ingestion time.

If a passage has no source URL, one of two things happens downstream: it gets cited with a fabricated link, or it gets used for context and cited as something else. Neither is acceptable. The rule is to set the source URL or file identifier for every ingested item at the point of ingestion, and to instruct the system that passages without a source URL may inform an answer but must never be cited. Kapa's guidance for hardware and semiconductor teams covers this case in detail, because PDF-heavy knowledge bases hit it hardest.

Keeping those URLs correct is an ongoing job rather than a one-off, since documents move and get replaced. How data ingestion works walks through why syncing only what changed is the hard part.

2. Retrieve at a granularity you can cite

You cannot cite more precisely than you retrieve. If your chunking strategy produces 4,000-token blocks spanning a whole documentation page, the best citation you can honestly offer is "somewhere on this page."

Chunking for citation means chunks that are self-contained enough to support a claim on their own and small enough that pointing at one is useful. It also means chunking differently by source type, because a Zendesk ticket, a Confluence page, and an API reference have different natural boundaries. A single chunking rule applied across all sources will produce good citations for one of them and poor citations for the rest.

Retrieval quality matters here for a reason that is easy to miss: accuracy in a documentation assistant is set by retrieval, not by the model. If the right passage is not in the retrieved set, no amount of prompting will produce a well-cited answer, because the evidence is not there to cite. Teams reaching for a better model when citations are poor are usually fixing the wrong layer. If that is where you are, 10 techniques for improving RAG accuracy is the more productive place to start.

3. Instruct at both the tool level and the prompt level

If you are building your own agent, citation behaviour has to be specified in two places, and they do different jobs.

The tool description tells the model what it is getting back. It should say that results include source URLs, and, importantly, that returned passages may be only weakly related or entirely unrelated to the query. That last clause is what primes the model to treat results skeptically rather than assuming everything returned is usable. Kapa's hosted MCP server ships this in its default tool description for exactly this reason.

The system prompt tells the model what to do with the results: cite the passage that supports each claim, do not cite passages that only provided background, do not cite anything without a source URL, and say so when the passages do not answer the question.

Teams building on a retrieval API or MCP server often write the second and skip the first, then wonder why the model is credulous about irrelevant chunks. Out-of-the-box products tend to have both configured already, which is why citation behaviour that feels automatic in a hosted widget has to be built deliberately when you assemble the same parts yourself. Kapa's guide to prompting for uncertainty and source citations sets out both halves with the default wording, and the same behaviour comes pre-wired in the Agent SDK if you would rather not specify it yourself.

4. Build the "I don't know" path deliberately

An assistant that cannot decline cannot be source-backed, because when the sources run out it has no option other than to invent. The refusal path is not a fallback, it is part of the grounding mechanism.

This is also where the economics of the feature show up. A confident wrong answer with a citation attached is worse than no answer, because the citation is doing active work to make the wrong answer credible. Users who click through once and find the source does not say what the assistant claimed will stop trusting the citations entirely, which removes the value of every correct one.

Treated well, refusals are not a loss. Each one marks a question your users asked that your documentation does not answer, which makes the refusal log a coverage-gap report. Kapa surfaces these as coverage gaps in its analytics for this reason: the "I don't know" is a signal about the documentation, not a failure of the assistant.

The related problem, an assistant that answers confidently when it should decline, is covered separately in how to reduce hallucinations in a documentation chatbot.

5. Evaluate citations separately from answers

Factuality and citation quality are different metrics and they come apart. An answer can be entirely correct with citations pointing at unrelated passages. An answer can be well-cited and wrong, if the source itself is outdated.

A serious evaluation setup scores at least four things:

  • Factuality: is the answer correct?

  • Faithfulness: did the answer come from the retrieved passages rather than the model's training data?

  • Citation accuracy: do the cited sources exist and are they the right ones?

  • Citation faithfulness: does each cited passage actually support the claim it is attached to?

Kapa runs offline evaluations against a curated test set scoring these dimensions before any change ships, alongside retrieval metrics such as NDCG@5 and NDCG@10, and monitors uncertainty rates and downvotes in production to catch drift.

One methodological caution worth borrowing: the widely used open-source evaluation frameworks have documented problems with inconsistent scoring, particularly when the same model both generates and judges an answer. They are a reasonable starting point and a poor place to stop. For a production system, expect to write evaluation logic specific to your own domain. Kapa's walkthrough of how to properly evaluate AI assistants for technical documentation covers the full method, and RAG best practices covers where evaluation sits in the wider pipeline.

How to test whether your assistant's citations are real

You can run this in an afternoon and it is more informative than most vendor demos.

Build a test set of roughly 100 real questions drawn from resolved support tickets, forum posts with accepted answers, and community channels. Sample randomly rather than picking questions you find interesting, because real traffic skews more toward beginners than your intuition suggests. Then, and this is the part most teams skip, deliberately include 15 to 20 questions whose answers are genuinely not in the sources. The full sourcing and sampling method is worth reading before you build the set, because a contaminated ground truth invalidates everything downstream.

Run the set and check three things by hand:

  1. For each cited link, does the page exist and does the specific passage support the specific claim?

  2. For the 15 to 20 unanswerable questions, did the system decline, or did it produce a confident answer with citations attached?

  3. For answers that are correct, is the correctness traceable to a retrieved passage, or could the model have known it anyway?

The third question is the one that separates a grounded system from a fluent one. Ask a question about a feature you renamed recently. A system answering from your sources will use the new name. A system answering from pretraining will use the old one, and may cite a page that uses the new one while doing it.

How kapa.ai approaches source-backed answers

Kapa.ai is an LLM-powered RAG platform purpose-built for technical documentation, and every answer it produces carries inline citations linking back to the source passage, so any claim can be checked where it came from.

Concretely, kapa.ai handles the five layers above as follows. Source URLs are set per data source at ingestion across 50+ source types, including PDFs and cloud storage files that arrive without one, and passages lacking a source URL can inform an answer but are not cited. Chunking is tuned per source type rather than applied uniformly, so ticket content, wiki pages, and API references are each split at sensible boundaries. Citation and uncertainty behaviour is built into the hosted integrations and the Agent SDK, and is specified in the default tool description and prompt for teams building on the Retrieval API or hosted MCP server. Uncertain questions produce an explicit "I don't know" and surface in the dashboard as coverage gaps. And the evaluation suite, developed across 200+ production deployments, scores factuality, faithfulness, citation accuracy and citation faithfulness against test cases drawn from real production failures.

The dashboard also shows every source that retrieval considered for a given conversation, with the ones the answer actually drew on marked as referenced. That distinction, between what was retrieved and what was used, is what makes a citation problem diagnosable rather than mysterious. Kapa's guide to troubleshooting and improving answers walks through using it to separate a missing-content problem from a retrieval problem from an interpretation problem.

For teams adding retrieval to an agent they already run rather than deploying a widget, Kapa for Agents covers the same grounding behaviour exposed as a single tool call.

Should you build this or buy it?

The honest answer depends on whether grounded retrieval is your product or your infrastructure.

The individual pieces above are all buildable. What makes them expensive is that citation quality only holds if all five hold simultaneously and stay holding as your documentation, your models, and your source systems change. Each model upgrade is a regression risk for citation faithfulness specifically, because citation behaviour is prompt-sensitive in ways that factuality is not. Without an evaluation suite you can run on every change, you will not know when it breaks. You will find out from users.

If retrieval is core to what you sell, build it and invest in the evaluation harness first. If it is infrastructure supporting a product that is about something else, the calculation usually favours a platform where the evaluation work is already amortised across many deployments. Should you build or buy an AI knowledge assistant works through the cost side of that decision, and keeping a RAG knowledge base in sync with changing docs covers the maintenance half that tends to be underestimated.

Frequently Asked Questions

Frequently Asked Questions

How do I make an AI assistant provide source-backed answers?

Preserve source URLs through ingestion, chunk your content so retrieved passages are small enough to cite meaningfully, instruct the model to cite the specific passage supporting each claim in both the tool description and the system prompt, give it an explicit path to say "I don't know", and evaluate citation faithfulness separately from answer correctness. All five have to hold together; citation quality fails at whichever one is weakest.

Why does my RAG system cite sources that do not support the answer?

Usually because citations are being generated as text rather than derived from the retrieval step, so the model predicts a plausible-looking link the same way it predicts any other token. It can also happen when the model answers from its training data and attaches a retrieved source afterward. Measuring citation faithfulness, meaning whether each cited passage actually supports the claim attached to it, is how you detect this.

What is the difference between factuality and faithfulness in RAG evaluation?

Factuality asks whether the answer is correct. Faithfulness asks whether the answer came from the retrieved sources rather than the model's own training data. An answer can be factual and unfaithful, which is a real risk because it works until your product diverges from what the model learned in pretraining.

Does retrieval-augmented generation prevent hallucinations on its own?

No. Retrieval changes what the model can see, not what it does with what it sees. Without explicit instruction and an uncertainty path, a RAG system handed irrelevant passages will still produce a confident answer, and will attach the irrelevant passages to it as citations.

How do I test whether an AI assistant's citations are trustworthy?

Build a test set of around 100 real user questions and deliberately include 15 to 20 whose answers are not in the sources. Check by hand that each cited page exists and that the specific passage supports the specific claim, and check that the unanswerable questions produce a refusal rather than a cited invention. Also ask about something you renamed recently, since an assistant answering from pretraining will use the old name.

Does kapa.ai cite sources on every answer?

Yes. Kapa.ai attaches inline citations linking to the source passage on every answer, and its dashboard shows every source retrieval considered alongside the ones the answer drew on. When the knowledge base does not cover a question, kapa.ai says it does not know and logs the question as a coverage gap rather than producing an uncited or weakly cited answer.

TRUSTED BY 200+ INDUSTRY-LEADING ENTERPRISES WITH COMPLEX PRODUCTS
  • Silicon Labs
    Ask anything...
  • Logitech
    Ask anything...
  • n8n
    Ask anything...
  • monday.com
    Ask anything...

Turn technical documentation into customer-facing AI assistants