liveBook · Manning

Fidelity

As explained in Generative AI in Action

Groundedness is the degree to which an AI output conforms to the information in its sources rather than speculation or fabrication.

Groundedness measures whether an AI response is supported by its sources rather than speculative or fabricated. It is one of the metrics used to assess LLM output quality, alongside coherence and fluency. section 13.5.1 section 12.6

Azure Content Safety provides groundedness detection to check whether responses are based on factual sources. This complements evaluation approaches such as traditional text metrics, task-specific benchmarks, and human evaluation. section 13.5.1 section 12.6

Listing 13.2 Groundedness detection example
# Build the request payload
payload = {
    "domain": "Medical",
    "task": "Summarization",
    "text": "Ms Johnson has been in the hospital after experiencing 
             a stroke.",
    "groundingSources": ["Our patient, Ms. Johnson, presented with 
         persistent fatigue, unexplained weight loss, and frequent 
         night sweats. After a series of tests, she was diagnosed ..."],
    "reasoning": false
})

headers = {
    "Content-Type": "application/json",
    "Ocp-Apim-Subscription-Key": CONTENT_SAFETY_KEY
}

# Send the API request
url = f"{CONTENT_SAFETY_ENDPOINT}/contentsafety/
                  text:detectGroundedness?api-version={API_VERSION}"
response = requests.post(url, headers=headers, 
                         json=payload, timeout=10)

if response.status_code == 200:
    result = response.json()
    print("detectGroundedness result:", result)
else:
    print("Error:", response.status_code, response.text)

The request example submits a medical-summary response and its grounding source to the groundedness detection endpoint. section 13.5.1

The illustrated response flags ungrounded content and identifies a specific text span. Treat the result as an evaluation signal; the example does not explain how to calibrate or interpret the score beyond the returned fields. section 13.5.1

How Generative AI in Action covers it

How deep it goes
Demonstrates an API request and returned ungrounded text, but does not explain score calibration.
Examples
Uses a medical summarization request with patient information as the grounding source.
What it assumes
Assign the Cognitive Services User role and select the relevant Azure OpenAI Service account for the service.
What you can do after
Apply groundedness detection through the Azure Content Safety endpoint using a response and grounding sources.
How it connects
Connects groundedness with LLM evaluation, coherence, fluency, and relevance.

Also explained in

Compare how 4 books explain fidelity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Generative AI in Action. The section links point to the parts of the book it draws on.