Grounding
Grounding is the practice of anchoring or constraining an AI system’s outputs with relevant information, context, or evidence.
Natural Language Processing in Action, Second Edition
Grounding is the process of anchoring a language model’s generated response in relevant external facts, sources, or user-specific information.
- How it is used
- Anchors chatbot responses in external knowledge when plausible language alone is not reliable enough for users.
- How deep it goes
- Defines grounding and contrasts retrieved text with knowledge-graph reasoning, but does not demonstrate a complete grounding implementation.
- Examples
- Uses a math tutor’s contradictory number-sequence feedback to expose the gap between fluent replies and checked answers.
- What you can do after
- Evaluate/understand when chatbot answers need retrieved evidence or structured fact checks rather than fluent generation alone.
Read how Natural Language Processing in Action, Second Edition explains grounding →
Generative AI in Action
Grounding is the technique of supplying a generative model with relevant external information as context for its response.
- How it is used
- Supplies external, use-case-specific context so assistants can answer questions more relevantly than with training data alone.
- How deep it goes
- Explains inline system-message context and points to embeddings, semantic search, and RAG for larger datasets without detailing their implementation.
- Examples
- Uses an Azure OpenAI support chatbot, pharmaceutical research data, and GitHub Copilot’s open files as grounding examples.
- What you can do after
- Apply it via a chat-completion system message for small contexts, or choose retrieval for larger datasets.
Build AI-Enhanced Web Apps
Grounding is the technique of checking generated information against a reliable external corpus to improve factual accuracy.
- How it is used
- Checks generated answers against reliable information in a document-based RAG application.
- How deep it goes
- Explains the search-to-answer flow and illustrates confidence-aware integration, but does not establish token confidence as proof of factual accuracy.
- Examples
- Shows a RAG flow diagram, token log-probability settings, and an enhanced query with a confidence threshold and ask-user fallback.
- What you can do after
- Apply it via LangChain.js RAG workflows to anchor answers to documents and inspect response confidence.
LLMs in Production
Grounding is the practice of supplying a language model with relevant external context so its generation is anchored to available information.
- How it is used
- Reduces hallucination by supplying relevant context for generation.
- How deep it goes
- Defines grounding, clarifies RAG terminology, and identifies multistep retrieval limits without detailing implementation.
- Examples
- Uses a Gal Gadot question to demonstrate why similarity retrieval struggles with multistep questions.
- What you can do after
- Apply grounding by adding necessary context or retrieval results before asking a model to generate an answer.
AI Agents in Action
Grounding is the assessment of how well a prompt or agent profile satisfies criteria for being constrained by relevant information or facts.
- How it is used
- Evaluates prompt or agent-profile outputs against rubric criteria, objectives, context, and instructions.
- How deep it goes
- Explains alignment, scoring, consistency, and iteration, then demonstrates automatic evaluation with a second LLM prompt.
- Examples
- Uses a recommender, rubric ratings, evaluation prompts, and scored recommendations such as The Butterfly Effect, Primer, and Time Bandits.
- What you can do after
- Evaluate/understand recommendation quality manually or automatically and compare prompt or profile performance against a repeatable baseline.
AI Agents in Action, Second Edition
Grounding is the process of anchoring a model's responses in relevant external information, data, or context.
- How it is used
- Constrains agent answers to retrieved knowledge and verifies that generated claims remain supported by that context.
- How deep it goes
- Explains retrieval, prompting, citations, and guardrail handling, but stops short of model internals.
- Examples
- Uses a Back to the Future screenplay, retrieved passages, citation prompts, and an output guardrail with a static fallback.
- What you can do after
- Apply it via RAG prompts and guardrails to produce, verify, reject, or retry answers against retrieved evidence.
Read how AI Agents in Action, Second Edition explains grounding →
Building Reliable AI Systems
A technique for anchoring an AI system's outputs in external information or evidence.
- How it is used
- Anchors AI responses in retrieved evidence or trusted external data to reduce reliance on model knowledge alone.
- How deep it goes
- Outlines retrieval, citations, uncertainty handling, testing, and monitoring, with a function-calling implementation sketch rather than a full verification pipeline.
- Examples
- Illustrates API-grounded weather replies and high-stakes uses involving clinical guidelines and legal citations.
- What you can do after
- Apply it via RAG or function calls, then test grounded answers and verify high-stakes claims before use.
Building LLM Applications with DSPy
A method of preparing a language model with substantial information about a task so its responses and instructions reflect that task.
- How it is used
- Improves candidate-instruction relevance by giving a prompt model task code, dataset descriptions, and training examples before costly evaluation.
- How deep it goes
- Describes task inputs and summary-then-generation steps, but does not specify how the summaries are constructed.
- Examples
- Uses flight-booking intent classification and a travel dataset summary mentioning routes, times, fares, and airport information.
- What you can do after
- Apply grounding through MIPROv2 to generate task-specific candidate instructions from source code and dataset summaries.
Read how Building LLM Applications with DSPy explains grounding →
Related concepts
- SIMBAuses · SIMBA is a DSPy prompt optimizer that iteratively evaluates candidate prompts, reflects on execution trajectories, and adds demonstrations or rules to improve performance.
- MIPROv2uses · MIPROv2 is a DSPy optimizer that searches for effective instructions and demonstrations for language-model programs using performance feedback and a Bayesian proposal model.
- GEPAuses · GEPA (Genetic-Pareto) is a reflective evolutionary optimization method that generates and evaluates candidate prompts using task information and feedback.
- hallucinationaddresses · A hallucination is model-generated content that is false, fabricated, or unsupported by relevant evidence but presented as plausible or factual.
- retrieval-augmented generationproduced by · Retrieval-augmented generation is a technique that retrieves relevant information from external sources and supplies it as context to a generative model when producing an output.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.







