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

# Toxicity RAG Metric

Evaluate LLM responses for toxic or offensive language. Flag unsafe outputs and apply filters to ensure safe, respectful interactions.

**Objective**: This guardrail uses pre-trained multi-label models to check whether the generated text is toxic. If the model predicts any label of: toxicity, severe\_toxicity, obscene, threat, insult, identity\_attack, or sexual\_explicit with confidence higher than the specified threshold, the guardrail fails.

**Required Parameters**: `Response`

**Interpretation**: Higher score indicates the model response was toxic.

**Metric Execution via UI:**<br>

<figure><img src="https://1811327582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYbIiNdp1QbG4avl7VShw%2Fuploads%2FJf5TNDz7BYdo7Yjt4nzH%2Fimage.png?alt=media&amp;token=7ac90850-c5b4-4d36-8f47-63ba49e90d13" alt=""><figcaption></figcaption></figure>

**Code Execution:**

```python
metrics=[
    {"name": "Toxicity", "config": {"model": "gpt-4o-mini", "provider": "openai"}, "column_name": "your-column-identifier", "schema_mapping": schema_mapping}
]
```

Model and Provider parameters are not mandatory to run Guardrails.

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