New Tool Radar

AI Concepts

How to Build a Grounded RAG Prompt That Cites Sources and Admits Gaps

Assemble retrieved chunks into a prompt with source labels, so the answer cites sources and says when it does not know.

Schematic with three steps: Label each chunk with its source; Write the grounding rules into the system; Check every claim in the answer.

With re-ranked chunks in hand, the next step is the prompt the model will see, and the rules in it decide whether the answer is grounded or invented. Give the model explicit rules: answer only from the provided context, cite sources, and say when the context is not enough. Label each chunk with its source so the citations point somewhere real.

What you need

  • Re-ranked chunks with their source and section recorded
  • A system prompt template with grounding rules
  • A test question whose answer is in the chunks

Step 1: Label each chunk with its source

Build the context string with one labelled block per chunk, such as [Source 1 – section heading] followed by the chunk text, separated by a divider. The labels are what the citations will point to.

Step 2: Write the grounding rules into the system prompt

Tell the model to answer strictly using facts found in the context, to cite its sources inline using the [Source X] notation, and to reply that it does not have sufficient information when the answer cannot be determined from the context.

Step 3: Check every claim in the answer

Read the answer and match each claim to a labelled source. Any claim with no source is ungrounded, and any answer that invents a source label has failed the check.

Worked example: synthetic grounded answer check

The table below is a synthetic example. It shows the expected result of checking a grounded answer; no answer was generated.

Claim in answer Source cited Grounded?
Refund window is 30 days [Source 1] Yes
Refunds go to the original payment method [Source 2] Yes
Support replies within 2 hours None No – ungrounded
Answer admits one gap States it does not know Yes

Expected result (UNTESTED). 2 of 3 claims cite real sources, 1 claim is ungrounded and must be dropped, and the answer admits the gap it cannot fill. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Grounding rules reduce hallucination but do not remove it; the model can still invent a claim inside a cited source.
  • A citation is only as good as the chunk it points to; check the chunk itself, not just the label.
  • If the retrieved chunks do not hold the answer, the correct output is an admission, not a guess.
  • Sending raw retrieved chunks straight into the prompt can use a large share of the context window and hurt quality.

Sources

See all