> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Answer relevancy

> Learn how to use the answer relevancy test

## Definition

The answer relevancy test measures how relevant the answer (output) is given the question. This metric is based on the Ragas [response relevancy](https://docs.ragas.io/en/stable/concepts/metrics/available_metrics/answer_relevance/) metric.

## Taxonomy

* **Task types**: LLM.
* **Availability**: <Tooltip tip="Continuously evaluate your models and datasets as you iterate on their versions.">development</Tooltip>
  and <Tooltip tip="Monitor a model in production, measure its health, check for drifts and set up alerts.">monitoring</Tooltip>.

## Why it matters

* Answer relevancy ensures that your LLM generates responses that are directly related to the input question or prompt.
* This metric helps identify when your model is providing off-topic or tangential responses that don't address the user's actual query.
* It's particularly important for chatbots, Q\&A systems, and any application where staying on-topic is crucial for user experience.

## Required columns

To compute this metric, your dataset must contain the following columns:

* **Input**: The question or prompt given to the LLM
* **Outputs**: The generated answer/response from your LLM

<Note>
  This metric relies on an LLM evaluator judging your submission. On Openlayer,
  you can configure the underlying LLM used to compute it. Check out the
  [OpenAI](/integrations/openai#openai-llm-evaluator) or
  [Anthropic](/integrations/anthropic#anthropic-llm-evaluator) integration
  guides for details.
</Note>

## Test configuration examples

If you are writing a `tests.json`, here are a few valid configurations for the answer relevancy test:

<CodeGroup>
  ```json Development theme={null}
  [
    {
      "name": "Answer relevancy above 0.8",
      "description": "Ensure that generated responses are relevant to the input questions with a score above 0.8",
      "type": "performance",
      "subtype": "metricThreshold",
      "thresholds": [
        {
          "insightName": "metrics",
          "insightParameters": null,
          "measurement": "answerRelevancy",
          "operator": ">",
          "value": 0.8
        }
      ],
      "subpopulationFilters": null,
      "mode": "development",
      "usesValidationDataset": true,
      "usesTrainingDataset": false,
      "usesMlModel": false,
      "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
    }
  ]
  ```

  ```json Monitoring theme={null}
  [
    {
      "name": "Answer relevancy above 0.8",
      "description": "Ensure that generated responses are relevant to the input questions with a score above 0.8",
      "type": "performance",
      "subtype": "metricThreshold",
      "thresholds": [
        {
          "insightName": "metrics",
          "insightParameters": null,
          "measurement": "answerRelevancy",
          "operator": ">",
          "value": 0.8
        }
      ],
      "subpopulationFilters": null,
      "mode": "monitoring",
      "usesProductionData": true,
      "evaluationWindow": 3600,
      "delayWindow": 0,
      "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
    }
  ]
  ```
</CodeGroup>

## Related

* [Ragas integration](/integrations/ragas) - Learn more about Ragas metrics.
* [Answer correctness test](/tests/catalog/answer-correctness) - Measure factual accuracy of answers.
* [Aggregate metrics](/tests/performance/aggregate-metrics) - Overview of all available metrics.
