# 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="/files/RNxldsn1Ms07RhSuUVa6" 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).


---

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