Groundedness
The Groundedness metric measures whether a model’s generated response remains faithful to the input context and avoids hallucinations or speculative reasoning. It helps evaluate factual consistency and traceability, especially when LLMs generate answers based on external sources, retrieved passages, or structured data.
This metric is critical in RAG (retrieval-augmented generation), enterprise QA systems, and any use case where factuality is a core requirement.
When to Use
Apply the Groundedness metric when a model is expected to remain tightly aligned with an authoritative context, such as:
- Knowledge-grounded agents that cite documents or structured data
- Enterprise chat assistants referencing product, support, or policy content
- Tool-using agents interpreting intermediate function/state output
- Factual creative assistants (e.g., educational, journalistic, research support)
Groundedness vs. Hallucination
While both metrics assess factual reliability, they are optimized for different needs:
Metric | What It Evaluates |
---|---|
Groundedness | Faithfulness to a given input context (e.g., documents, structured state) |
Hallucination | Presence of unsupported or fabricated claims |
Use Groundedness when verifying that the response stays true to the context.
Use Hallucination when checking whether the model invents facts — regardless of whether context is provided.
These metrics are complementary: use Groundedness to test context fidelity, and Hallucination to flag fabrication risk in general-purpose generation.
Score
The API returns a score
(float, 0.0 – 1.0) under the groundedness
key.
- 1.0: Fully faithful to the context; no unsupported or fabricated claims.
- 0.7–0.99: Mostly accurate with minor factual ambiguity.
- 0.2–0.7: Some inaccuracies or invented facts present.
- 0.0–0.2: Severe hallucinations or clear contradiction with context.
A higher score is better. A lower score indicates factual inconsistency, hallucinations, or unsupported reasoning.
API Request & Response Example
- Request
- Response
[
{
"context": "The Eiffel Tower is located in Paris, France.",
"generated_text": "The Eiffel Tower is located in England.",
"config": {
"groundedness": {
"detector_name": "default",
"explain":true
}
}
}
]
[
{
"groundedness": {
"instructions_list": [
{
"explanation": "The response states 'The Eiffel Tower is located in England,' which directly contradicts the given context ('Paris, France').",
"follow_probability": 0.0013,
"instruction": "Ensure that the response does not contain minor or major factual inaccuracies or completely made-up sentences when compared to the context.",
"label": false
},
{
"explanation": "It introduces a fact ('England') that is not supported by the context, showing failure to infer implicit information correctly.",
"follow_probability": 0.026,
"instruction": "Ensure that the response correctly infers implicit information without introducing unsupported facts.",
"label": false
},
{
"explanation": "The response arbitrarily chooses 'England' without clarifying why, despite the context clearly stating 'Paris, France.'",
"follow_probability": 0.4378,
"instruction": "Ensure that the response does not arbitrarily choose between contradictory pieces of information without clarification.",
"label": false
},
{
"explanation": "The answer misinterprets the context by fabricating the location as 'England' instead of inferring the correct implicit information.",
"follow_probability": 0.0331,
"instruction": "Ensure that the response does not misinterpret or fabricate implicit information.",
"label": false
},
{
"explanation": "The response states 'The Eiffel Tower is located in England,' which contradicts the given context ('Paris, France') and shows hallucination.",
"follow_probability": 0.018,
"instruction": "Ensure that the response does not include hallucinated content due to ambiguity.",
"label": false
}
],
"score": 0.0
}
}
]
Code Example
- Python
- TypeScript
from aimon import Detect
import os
detect = Detect(
values_returned=['context', 'generated_text'],
config={"groundedness": {"detector_name": "default", "explain": True}},
api_key=os.getenv("AIMON_API_KEY"),
application_name="application_name",
model_name="model_name"
)
@detect
def check_claims(context, prompt):
return context, "It was built in 1800 and is located in Rome."
ctx, output, grounded = check_claims("Eiffel Tower is in Paris and built in 1889", "Tell me about it")
print(grounded)
import Client from "aimon";
import dotenv from "dotenv";
dotenv.config();
const aimon = new Client({
authHeader: `Bearer ${process.env.AIMON_API_KEY}`,
});
const runDetection = async () => {
const context = "The Eiffel Tower is located in Paris, France. It was built in 1889.";
const generatedText = "The Eiffel Tower was constructed in 1850 and is in Berlin.";
const config = { groundedness: { detector_name: "default", "explain": true } };
const response = await aimon.detect(generatedText, context, "When was it built?", config);
console.log("AIMon Metric Result:", JSON.stringify(response, null, 2));
};
runDetection();