Chapter 11 · Ground the answer#

The big idea#

A language model is built to produce fluent text, not to check facts. If it does not know, it may still give a confident answer. This is called a hallucination. You reduce it by supplying the source text, restricting the answer to that source and giving the model an allowed way to say “I don’t know”.

Everyday example: An open-book exam. A student told “answer only from the textbook” and given permission to write “not covered” will not invent things. A student pushed to fill every line will.

In plain words

Always provide an exit: “If the answer is not in the text, reply exactly: Not in the policy.” Without an exit the model feels it must answer.

A picture#

Ground the answer Give the facts and permission to say 'I don't know'. Ground the answer Before What is our refund policy? After Answer ONLY from <policy>. If it is not there, say 'Not in the policy.' Source text + an allowed way to say no Same model, same question. Only the prompt changed.
Give the facts and permission to say 'I don't know'.

Before and after#

Replies below are typical examples to show the difference. Your model will word things differently, so run the prompts yourself.

Example 1 · Company policy#

Before

What is our refund policy?

Typical reply

Our refund policy allows returns within 30 days, and most items, including digital products, can be refunded if you are unsatisfied. (invented: the model has never seen your policy)

After

Answer the question using ONLY the policy inside <policy>. If the policy does not contain the answer, reply exactly: Not in the policy.

<policy>Refunds are available within 30 days of purchase for unused items. Digital goods are not refundable.</policy>

Question: Can I get a refund on an ebook I bought last week?

Typical reply

Not allowed. Digital goods are not refundable under the policy.

Prompt checker (code/promptcheck.py, columns T C A F L E D):

before   0/7  [. . . . . . .]  missing: task, context, audience, format, limits, example, delimiters
after    3/7  [. Y . . Y . Y]  missing: task, audience, format, example

Why it works. The first answer sounds official and is made up. The second quotes your real policy and would refuse politely if the policy were silent.

Example 2 · Asking for sources#

Before

Tell me the main causes of the 2008 financial crisis with statistics.

Typical reply

According to a 2009 Harvard study, 63.7% of all mortgages issued in 2006 were subprime... (a precise statistic that may not exist)

After

Give the 3 main causes of the 2008 financial crisis in one line each. Only include a number if you are confident it is correct. If you are not sure, say 'I am not sure of the figure' instead of guessing. Do not invent sources or links.

Typical reply

1. Risky mortgage lending to borrowers who could not repay.
2. Banks bundling those loans into securities and selling them with hidden risk.
3. Too little regulation and too much borrowing by banks. I am not sure of exact figures for any of these.

Prompt checker (code/promptcheck.py, columns T C A F L E D):

before   1/7  [. . . . Y . .]  missing: task, context, audience, format, example, delimiters
after    4/7  [Y Y Y . Y . .]  missing: format, example, delimiters

Why it works. Asking for “statistics” pressures the model to produce numbers. Allowing uncertainty removes the pressure.

Grounding checklist#

  1. Put the source text in the prompt (policy, document, search results).

  2. Say only use the source.

  3. Give an exact refusal phrase so code can detect it.

  4. Ask for a quote that supports the answer when accuracy matters.

  5. Check important facts yourself.

Detect the refusal in code:

REFUSAL = "Not in the policy."

def needs_human(reply):
    return reply.strip() == REFUSAL

print(needs_human("Not in the policy."))
print(needs_human("Not allowed. Digital goods are not refundable."))
True
False

Retrieval systems (RAG) are exactly this idea at scale: fetch the relevant text, paste it into the prompt, and ask the model to answer only from it.

Rules of thumb#

  • Supply the facts instead of hoping the model remembers them.

  • Provide an exact “I don’t know” sentence.

  • Ask for a supporting quote when the cost of an error is high.

Common mistakes#

  • Asking for facts the model cannot know (your private data, today’s news) without providing them.

  • Demanding citations and statistics without allowing uncertainty.

  • Believing confident tone means correct.

Try it yourself#

  1. Write the grounding instruction for an HR bot that answers only from a leave policy.

  2. Why use an exact refusal phrase?

  3. The model cites a book that does not exist. What do you change?

Answers
  1. “Answer only from the policy in . If it is not covered, reply exactly: Please ask HR. Quote the sentence you used.”

  2. Code can detect it and route the question to a person.

  3. Say “do not invent sources”, provide real sources in the prompt, and verify any reference yourself.

Next

Next: turn good prompts into reusable assets. System prompts and templates.