Skip to the page
Tecyfy

What is grounding in AI, and how do you keep a model's answers grounded in your documents?

Making a model answer from sources you give it, such as retrieved documents, and only from them, so every statement can be traced to a passage and a missing answer is admitted, not invented.

beginner · Also called Grounded Generation, Groundedness, Faithfulness

A model asked a question answers from what it learned in training, which may be old, general or wrong for your company. A grounded answer comes from sources handed to the model with the question: your help pages, a contract, the passages a search found. Grounding is the discipline of making the answer come from those sources, and only those.

It is what retrieval-augmented generationRAGA way to answer from your own documents. A search finds the passages that match the question, and they are added to the prompt before the model writes. is for. Fetching the right documents is half the job. The other half is a model that sticks to them.

What an ungrounded answer looks like

A shop's help bot is asked whether a refurbished laptop has a warranty. The search finds a page about warranties on new laptops, and the bot answers "Yes, 2 years". Every word sounds right and none of it applies. The model filled the gap between the question and the passage with something plausible, which is a HallucinationHallucinationWhen a model states something false as if it were true, such as a wrong date, a made-up quote or a source that does not exist. with a source attached.

How to ground an answer

Each habit closes one of those gaps:

  • Say where the answer must come from. The system promptSystem PromptInstructions the builder of an AI app gives the model before you type anything. It sets the role, the tone and the rules, and it outranks what users say. says to answer only from the passages given, not from general knowledge.
  • Give it a way out. Tell it what to do when the passages do not answer: say so and hand over to a person. A model told to be "helpful and confident" with no way out will guess.
  • Ask for citations. When each statement must point to a passage, a statement with nothing to point to stands out. On the Claude API, citations are a feature, not a prompt: pass documents or search results with citations turned on, and each part of the answer comes back with the exact text it relied on. The API extracts that text itself, so a citation always points to a real place in what you sent.
  • Quote first for long documents. For a document over 20,000 tokens, have the model pull out the word-for-word quotes that matter, then answer from the quotes.

None of these makes hallucination impossible, so check.

How to check it

Grounding is tested like anything else in an eval setEval SetThe list of test cases an LLM app is graded on after every change. Each case is an input and what a good answer must do, so a score going up or down shows whether the change helped., with 2 kinds of check. Code can check that an answer cites the passage it should, and that a question the documents cannot answer gets no citation at all. A model judge, an LLM judgeLLM as a JudgeUsing a language model to grade another model's output against a rubric, for qualities code cannot check. It scales to thousands of answers, but must be checked against a person's verdicts before it is trusted. given the passages and the answer, can check what code cannot: that every statement in the answer is supported by a passage. That property is often called faithfulness.

Grounding has a limit worth knowing. An answer can be perfectly grounded in a passage that is out of date, such as a price list replaced last month. The model did its job. The index did not. Keeping the sources current is part of the same system.

Sources

Where each fact comes from

  1. 1Reduce hallucinations
  2. 2Citations
  3. 3Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks