Citations and Abstention in RAG: What a Citation Proves, and When the Right Answer Is "It's Not in the Documents"
In a small simulation, 6 of 7 wrong answers carried a neat citation. A floor at 0.30 makes the bot refuse "Who founded the company?" (top score 0.13), but a made-up code ERR-4141 scores 0.39 and gets a wrong, cited answer until an evidence check refuses it. Plus format, registry and support checks, and a human-labelled set with slices.
What you will learn
- Explain why a neat citation shows which page was used, not that the answer is right
- Make a RAG bot refuse with a similarity floor plus an evidence check
- Separate three citation checks: format, registry and support
- Measure citations and refusals with a human-labelled golden set, a holdout and slices
Before you start
- The RAG Pipeline Explained
- RAG Prompt Assembly and Citations
The interview version: your assistant answers from PDFs with page numbers, and a user finds a cited page that doesn't back up the claim. What do you do? Most people say "we validate the citations with a pattern check". That checks the wrong thing.
A strong answer has two halves. A citation must be well formed, point to a real, current source, and that page must support the claim. And when nothing in the documents supports an answer, the right move is to abstain: refuse. Numbers here come from a small simulation, with synthetic pages and a simulated writer, so no model wrote anything.
Neat and wrong
We set up seven failures and got seven wrong answers. Six of the seven carried a citation, and each one was neat. Two of them:
Q: What is the refund policy? (simulated)
A: Refund policy, version 1. Customers may ask for a refund within 30 days of purchase. [refunds-v1 p.3]
Q: Who founded the company? (simulated)
A: To claim a warranty repair, send the order number and a photo of the fault to the repair desk. [warranty p.6]
The first page exists, and it's been replaced: version 2 says 14 days. The second quotes a warranty page with nothing about any founder. A citation tells you which page was used. It doesn't tell you that page was the right one.
When it isn't there: a floor
Sometimes the correct answer is "it's not in the documents". For "Who founded the company?", the top similarity is only 0.13, because no page says. So add a floor: below it, the bot says I can't find that in the documents. In this small set the floor is 0.30, and that value suits this set only.
Now ask about ERR-4141, a code that doesn't exist. Similarity is 0.39, above the floor, because ERR-4147 looks almost the same:
Q: What does ERR-4141 mean? (simulated, floor only)
A: Error ERR-4147 means the export job ran out of disk space. Free some space and retry. [errors p.12]
Well formed, real and current, and wrong.
The evidence check
The fix is an evidence check: the exact code in the question has to appear in the pages we retrieved. ERR-4141 doesn't, so the bot refuses:
absent-code: What does ERR-4141 mean? (simulated)
before: abstention ['E6', 'E3']
after : ok []
I can't find that in the documents.
Watch the other side, too. A strict floor refuses good questions. Set yours on your own labelled questions, and treat a wrong refusal as a failure just like a wrong answer.
Three checks on a citation
Back to the citation itself. A legal brief puts a footnote on every claim. A junior checks the footnote is written correctly; that's useful, and that's all it tells you. So the lawyer opens the book: does the case exist, and is it current? Then she reads the page: does it say what the brief claims?
- Format. A pattern check confirms it looks like a document and a page. That's all a regex can ever prove.
- Registry. A list of every document, its versions and its pages. Does this page exist, and is it current? This is the check that catches the old version 1.
- Support. Split the answer into claims, and ask of each one: does this page say this? It's the hard one.
How to number blocks and build a checker for missing and unsupported citations is covered step by step in RAG Prompt Assembly and Citations. No registry or claim-level checker ran in this simulation.
Who checks the checker
Measure all of this with a golden set: questions with known answers, labelled by people. For each question, the right page, the claims that page supports, or that it should refuse.
- Why humans? A model used as a judge can score a plausible wrong answer as correct. Check the judge against human labels before you trust it. No judge model ran here, so there's no judge number.
- Keep a holdout. If you set the floor on the same questions you score on, the result flatters you.
- Slice it. For illustration: answerable, not in the documents, exact codes, old versions. A good average can hide a bot that never refuses.
For building that set, see Building a Golden Dataset.
The follow-ups
- Your regex check passes. Are the citations right? Not necessarily. It proves the format, never the support.
- How does it refuse when the score looks fine? A floor plus an evidence check, because a near match can pass the floor.
- Can a model grade your citations? Yes, once you've checked it against human labels, on questions it didn't tune on.
| Level | What it sounds like |
|---|---|
| Weak | "We show citations, so it's grounded." |
| Okay | Checks format and source, and adds a similarity floor. |
| Strong | Checks support claim by claim, uses human labels, and treats a refusal as a correct result. |
Recap
| Idea | Remember |
|---|---|
| Citations | Show which page was used, not that it's right (6 of 7 wrong answers were cited, simulated) |
| Three checks | Format, registry, support; only support says it's true |
| Refusal | A floor (0.30 here, this set only) plus an evidence check |
| Measurement | Human labels, a holdout, and slices that include "should refuse" |
Try it yourself
Next time a chatbot gives you a citation, open the page and check whether it really says that. Then ask it something you know isn't in its documents, and see whether it refuses.
Related course on Udemy
Machine Learning Engineer: From First Model to ML Engineer
Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)Related posts
The RAG Pipeline Explained: 7 Stages From Documents to a Cited Answer
Ingest, chunk, embed, store, retrieve, rerank and generate, in one Python file. Follow one question through a 26-chunk employee handbook to an answer that cites its source.
Similarity Search: Finding the Closest Vectors with NumPy and NearestNeighbors
Ask one question of a whole collection of vectors: which items are closest to this one? Normalise, score every row with one matrix multiply, keep the top k or everything above a threshold, and check it with NearestNeighbors.
Why RAG Exists: The Problem It Solves, Compared With Pasting Everything and Fine-Tuning
A smart model has never read your company's files, and they change every month. Three ways to give it the facts: paste everything, fine-tune, or retrieve only the right pieces. Follow a refund-policy question through all three and see why RAG wins when documents change.
Real Embedding Models: an Open Model or a Provider API, Then Search, Duplicates and Recommendations
Swap a toy embedder for a model that learned. Two roads (all-MiniLM-L6-v2 on your machine, or OpenAI's API with your key), three sizes (384, 1,536 and 3,072 numbers), one rule, and three use cases built on the same rank function, with real scores.