StoryboardAI Engineering

Grounding

Putting the real text in the prompt and telling the model to answer only from it.

What is grounding?

Grounding means giving the model the facts at the moment it answers, instead of hoping it knows them. Your code fetches the relevant text, places it in the prompt, and instructs the model to use only that.

With the true answer in front of it, the most likely next token becomes the correct one. The model stops guessing because it no longer needs to.

A good grounding instruction also gives the model a way out: if the answer is not in the text, say so. An honest refusal is far better for a product than a confident invention.

Grounding: the model answers from text it is given, not from memory.Step 1: A question arrives. Step 2: Code fetches the real text. Step 3: Text and question go to the model. Step 4: The answer cites the text.1A question arrives2Code fetches thereal text3Text and questiongo to the model4The answer citesthe text
Grounding: the model answers from text it is given, not from memory.

Why does grounding matter?

Grounding is the main cure for made-up answers. It changes the model's job from recalling facts, which it does unreliably, to reading facts placed in front of it, which it does well. A grounded answer can also show where it came from, which is what lets a person trust it.

How does grounding work?

  1. Before calling the model, your code finds the text that holds the answer: a page, a record, a search result.
  2. That text is placed in the prompt, clearly marked as the source.
  3. The model is told to answer only from the source, and to say so if the source does not contain the answer.
  4. The reply names which part of the source each claim rests on, so it can be checked.

When should you use grounding?

Use it when

  • Answers depend on your own documents or data
  • Facts change, such as prices or stock
  • People need to verify what they are told

Think twice when

  • The task is creative or conversational, with no facts at stake
  • No reliable source exists. Grounding in bad text gives confident bad answers

Where does grounding sit in a real system?

Grounding is done by your code in the step before the model call. It relies on some way of finding the right text, which is usually search over your documents or a lookup in a database.

What goes wrong with grounding?

  • Supplying the source and still letting the model draw on its own memory.
  • Not giving the model a way to say the source is silent.
  • Grounding in too much text, so the relevant line is lost.

What does grounding look like in practice?

The same returns question, with the shop's policy page in the prompt and the instruction to answer only from it: "Returns are accepted within 30 days, unworn, with the original box [1]". The number in brackets points at the paragraph it came from.

Watch it happen

These stories show grounding at work, one step at a time.