# Context Relevancy RAG Metric

The Context Relevancy metric evaluates the quality of the retriever used in the RAG pipeline. This metric is vital  to ensure that the the documents retrieved by the retriever is relevant for answering the prompt and the retriever mechanism in the RAG pipeline is working as expected.

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

**Interpretation:**

Lower metric score indicates one of these:

* The retrieval mechanism is not working poorly.
* The Knowledge Base doesn't have sufficient data to supply documents to the prompt.

**Metric Execution via UI:**

<figure><img src="https://1811327582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYbIiNdp1QbG4avl7VShw%2Fuploads%2FuEgviM9xFlvSx7wdT49G%2Fimage.png?alt=media&#x26;token=02add052-27f2-4757-a48b-bbd69c6f3a87" alt=""><figcaption></figcaption></figure>

**Code Execution**

```python
metrics=[
    {"name": "Context Relevancy", "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).
