LLM Grounding

TLDR: LLM grounding supplies a model with external source material at query time, so its answer rests on verifiable data rather than on what it absorbed during training.

Grounding addresses a structural property of language models: they generate plausible text, not verified text. A model asked about a current price will produce a number whether or not it has any basis for one. Grounding changes the task from recall to reading, by placing the actual source material in front of the model and instructing it to answer from that material alone.

Why Ungrounded Output Fails:

  1. Training cutoff: Model weights encode a snapshot. Anything after the cutoff is unknown, and anything that changed since is stale.
  2. No verification: Generation is a probability driven process with no mechanism for checking whether a statement is true.
  3. Plausible fabrication: Invented citations, statistics, and product details are produced in the same confident register as accurate ones.
  4. No provenance: Without a source, a claim cannot be traced, audited, or corrected.

Grounding Methods:

Method Source Freshness Best for
Retrieval from an index Pre collected corpus As fresh as the index Internal knowledge bases
Live search Search engine results Current News, prices, events
Direct fetch A specific URL Current Known authoritative pages
Structured query Database or API Current Records, inventory, accounts
Tool execution Computation or system call Current Calculations, lookups

Most production systems combine several. A question about a competitor’s current pricing requires live retrieval. A question about internal policy requires an indexed corpus. A question combining both requires routing logic that decides which source applies.

A Grounded Prompt:

SYSTEM = """Answer using only the sources below.
Cite the source number for every factual claim.
If the sources do not contain the answer, say so.
Do not supplement from prior knowledge."""

def grounded_answer(question, sources):
    context = "nn".join(
        f"[{i}] {s['url']} (retrieved {s['fetched_at']})n{s['text']}"
        for i, s in enumerate(sources, start=1)
    )

    return model.generate(
        system=SYSTEM,
        prompt=f"Sources:n{context}nnQuestion: {question}"
    )

Three instructions carry most of the weight. Restricting the model to the supplied sources prevents silent blending with training data. Requiring citations makes each claim traceable. Permitting the model to say the answer is absent gives it an alternative to inventing one.

Where Grounding Breaks:

Retrieval misses. Grounding can only work with what retrieval returns. If the relevant document is not surfaced, the model is grounded in material that does not contain the answer.

Stale sources. An index built six months ago grounds answers in six month old facts, with all the confidence of current data.

Contradictory sources. When retrieved documents disagree, the model will usually pick one without flagging the conflict.

Leakage. Models frequently supplement supplied context with training knowledge despite instructions not to, which produces answers that are partly grounded and partly not, with no way to distinguish the two.

Citation without support. A model can attach a source number to a claim that source does not actually make. Citations improve auditability only if someone audits them.

Verifying Grounding:

Because these failures are quiet, grounded systems need checks that do not rely on the output looking correct.

Useful ones include confirming that every cited source identifier exists in the supplied set, measuring overlap between answer text and source text, tracking how often the model declines to answer, and sampling outputs for human review against their cited passages. A system that never says the sources are insufficient is almost certainly fabricating rather than genuinely always finding the answer.

Grounding and Data Access:

Grounding quality is bounded by source quality. An answer can only be as accurate, current, and complete as the material supplied to produce it, which makes retrieval infrastructure the determining factor rather than prompt wording.

For questions about the live web, this means the ability to reach pages reliably and return them in a usable form. Bright Data’s Search and Extract returns live search results and page content as clean Markdown, and the SERP API supplies current search results for queries where freshness is the requirement.

Grounding also depends on how retrieved material is prepared. Overly long sources crowd the context window, and poorly bounded document chunks supply fragments that read as authoritative while omitting the qualifications that made them true.

Ready to get started?