When a support bot says you have 30 days to return something, is it quoting the returns policy or making it up? Reading the answer won’t tell you: invented answers sound exactly like real ones. The fix is to make the model show its sources. Number the passages you give it, ask it to mark each sentence with the one it used, like [2], and every claim comes with a place to check it, by a person in one click or by your code automatically. Here a real model cites its sources for 20 questions, and you check every citation. A citation tells you where to check, not that the answer is right.
Number the sources, ask for [n]#
This builds on the RAG explainer: Hearth, a made-up smart-home company, has a help centre of 50 articles, and a search finds the ones closest to each customer question. This time the four best matches go into the prompt numbered [1] to [4], with one extra instruction: “After each sentence, cite the article you used in square brackets, like [2].” The model is Qwen3-1.7B, small enough to run on a laptop.
A citation is only useful if something checks it, so we wrote the simplest checker there is. It splits the answer at its [n] markers and asks three questions of each piece: does the source exist, is it the article that really answers the question, and does every number in the piece appear in the source it cites? The last one needs no answer key, so it can run on every reply in production.
The model took to citing easily. All 20 answers cite a source, every source they cite exists, and whenever the article with the answer was among the four, the model cited it: 19 times out of 19. It was looser about the rule itself. “After each sentence” held in 12 of the 20 answers. Most of the others put one citation at the end of two or three sentences, and in the returns answer the one piece that matters, “you have 30 days”, is the piece left without a citation.
Predict first
Now reverse the order of the four sources, so the article with the answer moves from [1] to [4]. What does the model cite?
Right source, wrong answer#
So the citations point at the right places. That’s not the same as the answers being right, and this is the part that’s easy to miss.
Predict first
With the best match first, 19 answers cite the article with the answer. How many of those 19 answers are right?
Read the six. One customer already owns a Hearth plug and asks what fitting costs: the answer says £75, citing the installation article, which does say £75, followed by “or £45 if you already have a Hearth product”. Another asks whether keeping camera clips costs money: the answer says yes, citing the camera article, which says you can save them to a microSD card for free. Asked whether a three-year-old gift card still works, the model cites the article that says gift cards last two years, and concludes that it does. Each citation is accurate. Each answer is wrong. Citations make checking possible; they don’t do the checking.
The numbers check catches one of the six: the gift card, because “three years” appears in the answer and not in the article. It can’t catch the others, because their mistakes aren’t numbers the source lacks: £75 is in the installation article, and “yes, you have to pay” is a misreading, not a figure. And the question with no right article among the sources, about an expired card, passes the check too: its answer cites a real article about cancelling, and the numbers in it are all there. A citation can only point at what the search found.
One more pattern, worth knowing about but too small to lean on: with the sources reversed, 15 answers were right instead of 13. Putting the best match last, nearest the question, helped this model a little on these 20 questions; on yours it may not.
Stronger checks#
The numbers check is cheap and catches a real class of mistake. For more, combine it with these:
- Ask for quotes, and check them word for word. Have the model copy the exact sentence it relied on from the source, in quotation marks, then check in code that the quote really is in that source. A made-up quote fails instantly.
- Ask a second model. For each sentence and its source, ask “Does this source support this sentence? Answer yes or no.” That’s an LLM judge; it catches misreadings like the camera clips, and it makes mistakes of its own, so measure it on examples you’ve checked by hand.
- Treat a missing citation as a warning. A sentence with no source is the most likely place for an invention. Flag it, or ask the model to try again.
- Show the sources to people. Turn each [n] into a link that opens the passage, as the figures here do. A customer who can check in one click often will.
In code#
The checker from the figures in plain Python, no libraries needed, on three of the model’s real answers and their sources (shortened to the articles they cite):
import re
WORDS = {"one": "1", "two": "2", "three": "3", "four": "4", "five": "5", "ten": "10", "fifteen": "15", "twenty": "20", "thirty": "30"}
def numbers(text):
"""Every number in the text, with number words as digits: 'three years' -> '3'."""
found = re.findall(r"\b(?:" + "|".join(WORDS) + r")\b|\d+(?:\.\d+)?", text, re.I)
return {WORDS.get(n.lower(), n) for n in found}
def check_citations(answer, sources):
"""Split the answer at its [n] markers and check each cited piece against its sources."""
pieces = re.findall(r"(.*?)((?:\s*\[\d+\])+)", answer, re.S)
for text, marks in pieces:
ids = [int(n) for n in re.findall(r"\d+", marks)]
if any(i not in sources for i in ids):
print(f" {marks.strip()}: no such source")
continue
missing = numbers(text) - numbers(" ".join(sources[i] for i in ids))
if not numbers(text):
verdict = "no numbers to check"
else:
verdict = f"not in the source: {', '.join(sorted(missing))}" if missing else "every number is in the source"
print(f" {text.strip()!r} {marks.strip()}: {verdict}")
rest = answer[sum(len(t) + len(m) for t, m in pieces):].strip(" .,")
if rest:
print(f" {rest!r}: no citation")
gift = {1: "Gift cards. Hearth gift cards come in values from £10 to £200 and can be spent on any product or on Hearth Plus. "
"They're valid for two years and can't be exchanged for cash."}
returns = {2: "Returns. You can send back any Hearth product within 30 days of delivery for a full refund, as long as it's "
"undamaged and in its original box."}
camera = {2: "C1 indoor camera. The C1 records 2K video and has night vision up to 8 metres. It alerts you when it hears a "
"smoke alarm or a baby crying. Clips are saved for 30 days with Hearth Plus, or you can save them to a microSD card for free."}
# Three real answers from Qwen3-1.7B, each checked against the sources it was given
check_citations("You can still use the gift card three years after receiving it, as Hearth gift cards are valid for two years [1].", gift)
check_citations("You can send back your order [2], and you have 30 days from the date of delivery to do so.", returns)
check_citations("Yes, you have to pay to keep camera clips. If you have Hearth Plus, your clips are saved for 30 days. "
"If you don't have Hearth Plus, your clips are deleted 30 days after the last recording [2].", camera)
# 'You can still use the gift card three years after receiving it, as Hearth gift cards are valid for two years' [1]: not in the source: 3
# 'You can send back your order' [2]: no numbers to check
# 'and you have 30 days from the date of delivery to do so': no citation
# "Yes, you have to pay to keep camera clips. If you have Hearth Plus, your clips are saved for 30 days. If you don't have Hearth Plus, your clips are deleted 30 days after the last recording" [2]: every number is in the sourceThe first answer is caught, the second has its key claim left uncited, and the third passes every check while telling the customer they must pay to keep clips they could keep on a microSD card for free. That’s why the last line of defence is still a person who can see the sources.
What to remember
- Number the passages in the prompt and ask the model to cite them as [n], so every claim comes with a place to check it.
- Here the model cited the right article every time it had one, and still gave 6 wrong answers with accurate-looking citations.
- Check citations automatically (numbers, quotes, a second model) and show the sources to people: a citation is where checking starts.