# Faithfulness RAG Metric

**Objective:** This metric determines the *proportion* of facts in the response that originate from the context information. The generated answer is considered faithful if all the claims made can be inferred from the provided context.

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

**Interpretation:**

* Lower faithfulness score indicates the model is not able to focus on the correct context document.
* Lower faithfulness score indicates the model is hallucinating and generating information not present in the context documents.&#x20;
* Lower faithfulness score indicates the Knowledge Base has contradicting information regarding the topic referred to in the prompt.

<figure><img src="https://1811327582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYbIiNdp1QbG4avl7VShw%2Fuploads%2FsP4Xne8uXyaZNXjWtleS%2Fimage.png?alt=media&#x26;token=6e7d6f04-87fb-4c99-b778-b645f56301bb" alt=""><figcaption></figcaption></figure>

**Code Execution:**

```python
metrics=[
    {"name": "Faithfulness", "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](https://docs.raga.ai/ragaai-catalyst/concepts/running-ragaai-evals/executing-evaluations).

**Example**:

* Prompt: Who discovered penicillin?
* Context: Penicillin is one of the most important discoveries in medical science, marking the beginning of the antibiotic era. It was discovered in 1928 by Alexander Fleming, a Scottish bacteriologist.&#x20;
* Response: Alexander Dumas discovered penicillin.
* *Metric Output*: {‘score’: 0, ‘reason’: ‘As per context penicillin was discovered by Alexander Fleming’}

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.raga.ai/ragaai-catalyst/ragaai-metric-library/rag-metrics/faithfulness.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
