> 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/context-relevancy.md).

# Context Relevancy RAG Metric

Evaluate how relevant the retrieved context is to the user’s query and the LLM’s answer, ensuring the model uses appropriate and useful information.

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&amp;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](/ragaai-catalyst/concepts/running-ragaai-evals/executing-evaluations.md).
