AI Grounding
This module verifies that AI-generated answers, particularly in Retrieval-Augmented Generation (RAG) systems, are supported by the retrieved source material. It scores each sentence of an answer against the sources, flags unsupported claims (hallucinations), and can prevent low-scoring answers from reaching the user.
AI Grounding is a runtime, output-side faithfulness verifier for Retrieval-Augmented Generation (RAG) and AI chat answers, built on the AI module. After an answer is generated, it scores how well each sentence is supported by the retrieved source chunks, flags unsupported (hallucinated) statements, and can hold or block low-grounding answers before they reach the user.
The problem it solves
RAG chatbots retrieve sources and cite them, but they almost never verify that the generated answer is actually supported by those sources. Studies keep finding double-digit hallucination rates even in retrieval-grounded systems. Input-side guardrails and offline evaluation don't catch this at request time — AI Grounding adds the missing runtime check on the output.
Features
- Sentence-level faithfulness scoring — every sentence of an answer is scored against the retrieved sources.
- Hallucination flagging — unsupported claims are identified individually, not just as an overall score.
- Citation validation — citations that do not actually appear in the sources lower the grounding score.
- Configurable enforcement — per your threshold, an answer can be allowed, flagged, forced to abstain ("not enough information"), or held for human review.
- Pluggable scorers — a deterministic lexical scorer ships by default and works fully offline (no extra API calls); an optional LLM-judge scorer uses your configured AI provider behind the same interface.
- Optional, guarded integrations with the rest of the AI ecosystem — nothing else is required.
How it works
AI Grounding exposes a GroundingVerifier service and subscribes to the AI module's post-generation event. Given the answer text and the retrieved source chunks, the active GroundingScorer plugin splits the answer into sentences and computes a support score for each against the sources. Sentences below the per-sentence threshold are marked unsupported; the overall score drives the configured action (allow, flag, abstain or hold). Scoring is a plugin type, so the default lexical algorithm can be swapped for an LLM judge or your own implementation.
Requirements
- Drupal 10.3+ or 11
- The AI (drupal/ai) module
Optional integrations
- AI Policy Gateway — turn a low-grounding verdict into a policy block or human-approval gate.
- AI Decision Log — record every hold or abstain decision for audit.
- AI Model Registry — read model metadata when scoring.
All integrations are optional and guarded; the module degrades gracefully when they are absent.
Installation
Install with Composer:
composer require drupal/ai_groundingEnable the module, then set the grounding threshold, scorer and enforcement action on its settings form. A read-only report lists recent grounding decisions.