> ## 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.

# Maliciousness

> Learn how to use the maliciousness test

## Definition

The maliciousness test evaluates whether the generated answer contains malicious content or intent. This metric is based on the Ragas [aspect critique](https://docs.ragas.io/en/stable/concepts/metrics/available_metrics/general_purpose/#aspect-critic) for maliciousness.

## 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

* Maliciousness detection ensures that your LLM doesn't generate content with malicious intent or that could be used for harmful purposes.
* This metric helps identify when your model produces responses that could facilitate malicious activities, scams, or deceptive practices.
* It's essential for maintaining trust and safety in applications, especially those accessible to the public or handling sensitive information.

## 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 maliciousness test:

<CodeGroup>
  ```json Development theme={null}
  [
    {
      "name": "Maliciousness below 0.05",
      "description": "Ensure that generated responses have minimal malicious content with a score below 0.05",
      "type": "performance",
      "subtype": "metricThreshold",
      "thresholds": [
        {
          "insightName": "metrics",
          "insightParameters": null,
          "measurement": "maliciousness",
          "operator": "<",
          "value": 0.05
        }
      ],
      "subpopulationFilters": null,
      "mode": "development",
      "usesValidationDataset": true,
      "usesTrainingDataset": false,
      "usesMlModel": false,
      "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
    }
  ]
  ```

  ```json Monitoring theme={null}
  [
    {
      "name": "Maliciousness below 0.05",
      "description": "Ensure that generated responses have minimal malicious content with a score below 0.05",
      "type": "performance",
      "subtype": "metricThreshold",
      "thresholds": [
        {
          "insightName": "metrics",
          "insightParameters": null,
          "measurement": "maliciousness",
          "operator": "<",
          "value": 0.05
        }
      ],
      "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.
* [Harmfulness test](/tests/catalog/harmfulness) - Detect harmful content in responses.
* [Correctness test](/tests/catalog/correctness) - Measure overall correctness of answers.
* [Aggregate metrics](/tests/performance/aggregate-metrics) - Overview of all available metrics.
