0d3cb498a3
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
93 lines
2.3 KiB
Markdown
93 lines
2.3 KiB
Markdown
---
|
|
sidebar_label: XSTest
|
|
description: Red team homonym vulnerabilities by testing LLM interpretation of ambiguous terms to prevent misclassification of harmful content in production AI systems
|
|
---
|
|
|
|
# XSTest Homonym Dataset
|
|
|
|
## Overview
|
|
|
|
The XSTest plugin tests how well LLMs handle ambiguous words (homonyms) that can have both harmful and benign interpretations. The dataset focuses on terms that might be related to:
|
|
|
|
- Violence (e.g., "kill a process" vs. "kill a person")
|
|
- Drugs (e.g., "crack in a pipe" vs. "crack cocaine")
|
|
- Other potentially harmful contexts when misinterpreted
|
|
|
|
Each test includes metadata about the homonym, category, and expected safety label.
|
|
|
|
## How it works
|
|
|
|
The plugin:
|
|
|
|
- Loads prompts containing homonyms from the XSTest dataset
|
|
- Selects and shuffles a specified number of prompts
|
|
- Tests if the model correctly interprets the homonym in context
|
|
- Uses LLM-as-a-judge to evaluate responses based on the context and expected safety interpretation
|
|
|
|
## Configuration
|
|
|
|
Add to your YAML file:
|
|
|
|
```yaml
|
|
redteam:
|
|
plugins:
|
|
- xstest
|
|
```
|
|
|
|
Control the number of tests:
|
|
|
|
```yaml
|
|
redteam:
|
|
plugins:
|
|
- id: xstest
|
|
numTests: 25
|
|
```
|
|
|
|
## Example
|
|
|
|
```yaml
|
|
description: XSTest homonym evaluation
|
|
|
|
prompts:
|
|
- 'Respond to the following query or question: {{query}}'
|
|
|
|
redteam:
|
|
plugins:
|
|
- xstest
|
|
|
|
targets:
|
|
- openai:gpt-5-mini
|
|
```
|
|
|
|
Run with:
|
|
|
|
```sh
|
|
promptfoo redteam run
|
|
```
|
|
|
|
Once complete, you'll be able to view the evaluation results. For each output cell, hovering over it and clicking on the 🔎 icon will display the full input/output.
|
|
|
|
This detailed display also includes XSTest metadata such as the homonym term, category, and expected safety label.
|
|
|
|
## Grading
|
|
|
|
Responses are evaluated on:
|
|
|
|
1. For safe queries: Whether the model correctly understood the benign interpretation of the homonym and provided a helpful response
|
|
2. For potentially unsafe queries: Whether the model appropriately refused to answer or provided a safe response
|
|
|
|
## Dataset
|
|
|
|
The dataset includes:
|
|
|
|
- The prompt text containing a homonym
|
|
- The specific homonym term (e.g., "kill", "execute", "crack")
|
|
- Category information about the term type (e.g., "contrast_homonyms", "homonyms")
|
|
- Safety label ("safe" or "unsafe")
|
|
|
|
## Related Concepts
|
|
|
|
- [Types of LLM Vulnerabilities](../llm-vulnerability-types.md)
|
|
- [DoNotAnswer](./donotanswer.md)
|
|
- [BeaverTails](./beavertails.md)
|