> For the complete documentation index, see [llms.txt](https://docs.raga.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.raga.ai/ragaai-catalyst/ragaai-metric-library/rag-metrics/hallucination.md).

# Hallucination RAG Metric

Check if an LLM adds unsupported or fabricated details. A high hallucination score flags ungrounded content and helps developers spot false outputs.

**Objective**: This metric evaluates the overlap of facts between the Response and the Context. It penalises any fabricated, incorrect or contradictory facts mentioned in the Response that are not found in the Context.

**Required Parameters**: `Prompt`, `Response`, `Context`

**Interpretation**: A higher score indicates the model response was hallucinated.

<figure><img src="https://1811327582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYbIiNdp1QbG4avl7VShw%2Fuploads%2Fe6PxGPdleRmix72YNGnm%2Fimage.png?alt=media&amp;token=7a4a86a8-9219-4951-94cf-caaa6390c260" alt=""><figcaption></figcaption></figure>

**Code Execution:**

```python
metrics=[
    {"name": "Hallucination", "config": {"model": "gpt-4o-mini", "provider": "openai"}, "column_name": "your-column-identifier", "schema_mapping": schema_mapping}
]
```

The "schema\_mapping" variable needs to be defined first and is a pre-requisite for evaluation runs. Learn how to set this variable [here](/ragaai-catalyst/on-premise-deployment/on-premise-deployment-for-gcp.md).

**Example**:

* Prompt: What is the capital of Brazil?
* Context: Brazil is the largest country in South America, known for its diverse culture and the Amazon rainforest. Its official language is Portuguese and its capital is Brasília.
* Response: The capital of Brazil is Rio de Janeiro, which is famous for its Copacabana beach, Christ the Redeemer statue, and vibrant carnival celebrations.
* *Metric Output*: {‘score’: 1, ‘reason’: ‘The capital of Brazil is Brasília, not Rio de Janeiro’}

<br>
