Grounding and saying “I don't know”
Pasting a document into a prompt does not make the answer come from it. Watch a school bot invent a fee rule with the circular right in front of it, then see three prompt lines that fix it. Quotes first, answer second, and permission to say it is not there.
10 minFree
- Build the prompt
- Generate
- Check the quotes
- Result
Press Play to watch it run, or step through with ← →. Then switch to Practice and run it yourself.
You are a helpful assistant for Greenfield School.
Here is the latest circular:
{{CIRCULAR}}
Answer the parent's question.
Parent's question: {{QUESTION}}What came back
Nothing yet. Press Play.
Background: the idea in plain words
You already know that a model can state false things in a confident voice. The lesson Hallucinations and grounding showed why, and showed the cure in outline: give the model the real document. This lesson is about the part you write yourself. Which words in the prompt make the model actually stay inside the document?
Here is the problem. Many people paste a document into the prompt, add "answer the question", and believe the job is done. It is not. The model has read about thousands of schools, shops and hotels in its training. When your document is silent on a question, that general knowledge is still there, and it sounds just as sure. The document is in the prompt, but nothing tells the model that the document is the limit.
Grounding means tying the answer to a source you supplied. In prompt writing it comes down to three instructions:
- Only this source. Tell the model to use the supplied document and not its general knowledge.
- Quotes first. Ask the model to copy the exact sentences that answer the question before it writes the answer. A quote is a word-for-word copy.
- Permission to say "I don't know". Tell the model exactly what to say when the document does not contain the answer. Choosing not to answer is called abstaining.
The running example is a school in Pune. Parents ask the school app about a fee circular (a notice the school sends home). The circular has four points: the fee, the last date, how to pay and the late fee. One parent asks whether the fee can be paid in two instalments. The circular does not say.
With the weak prompt, the model says yes and even suggests dates. With the fixed prompt, the same model writes "No relevant quotes found" and sends the parent to the school office. And when another parent asks something the circular does cover, the same fixed prompt answers and points to the exact lines.
Press Play to watch the weak prompt fail. Then switch Try it to the grounded prompt with the same question, and then to the third scenario, where the answer is in the circular.
What to notice
- A document in the prompt is not a rule. The weak prompt contained the whole circular and the model still invented an instalment plan. Nothing told it the circular was the only allowed source.
- The order does the work. The model writes from left to right and reads what it has already written. With the exact sentences on the page first, the answer is built on them. With the answer first, quotes are only decoration.
- "I don't know" needs permission and a script. A model told only to "answer" will avoid saying it cannot. Give it the exact sentence to use and a next step for the person, such as the school office.
- Exact quotes can be checked by plain code. If the quote must be word for word, your code can search the document for it. A quote that is not found means the model changed or invented it.
- A good grounded prompt still answers. The third scenario uses the same prompt and gets a full answer with line numbers. If your bot abstains on questions the document does cover, the rules are too strict or the document is hard to read.
Go deeperThree techniques from the official guides
| Technique | What you write in the prompt | What it costs |
|---|---|---|
| Restrict the source | "Use only the circular above. Do not use general knowledge." | The model will also refuse things it knows correctly |
| Quotes before the answer | "First copy the exact sentences in <quotes> tags. Then answer using only those quotes." | Extra output tokens, so a slower and slightly dearer reply |
| Permission to abstain | "If the circular does not answer the question, say: ..." | Some questions go to a person instead of being answered |
| Check after writing | "For each claim, find a supporting quote. If you cannot find one, remove the claim." | A longer reply, or a second request |
Anthropic's guide on reducing hallucinations lists the first three as basic strategies and the fourth as a way to make a reply auditable (easy for someone to check). It recommends the quotes-first step especially for long documents, where the model has much more text to get lost in. Its example prompt even gives the model a line to write when nothing matches: "No relevant quotes found."
Google's prompting guide gives a system instruction for strictly grounded answers with the same two ideas. The model is limited to the supplied context, and if the exact answer is not written there, it must say the information is not available. OpenAI's guide describes adding your own documents to the prompt as a way to constrain the model's response to a specific set of resources.
So the three vendors agree on the method. The wording differs, and so does how strongly each model follows it. Test the abstention on your own model (see Testing prompts with evals).
Go deeperHow strict should you be?
Strictness is a choice, not a default.
Strict: only the document
Right for fee rules, policies, prices, medical or legal text. A wrong answer costs more than no answer. Expect more "the document does not say" replies, and plan a handoff to a person.
Loose: document plus general knowledge
Right for a homework helper or a brainstorming tool. Ask the model to mark which parts come from the document and which do not, so the reader can tell them apart.
Two mistakes are common. The first is a strict rule with no handoff: the bot says "I cannot help" and the person is stuck. The second is asking for quotes after the answer. By then the answer is already written, and the model will look for sentences that seem to support it.
Reduces, does not remove Anthropic's guide says plainly that these techniques significantly reduce hallucinations but do not eliminate them. The quote check proves a sentence exists in the document. It does not prove the answer follows from it. For money, health or legal matters, show the quotes to the user and keep a person in the loop.
Go deeperWords to know
| Word | Meaning in simple words |
|---|---|
| Grounding | Tying the answer to a document you supplied, not to the model's memory |
| Quote | A word-for-word copy of a sentence from the document |
| Abstain | To decline to answer, for example "the circular does not say" |
| General knowledge | What the model learned in training, which may not match your document |
| Handoff | Passing the question to a person who can answer it |
| Auditable | Easy for a person or a program to check against the source |
Check your understanding
Sources: the official documentation
This lesson is based on the official documentation. Check it for the latest details.
Something wrong or unclear in this lesson? Tell us, it gets fixed.