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
2.2 KiB
2.2 KiB
sidebar_label, description
| sidebar_label | description |
|---|---|
| Answer Relevance | Score LLM response relevance and completeness against user queries using sophisticated AI-powered evaluation metrics |
Answer Relevance
The answer-relevance assertion evaluates whether an LLM's output is relevant to the original query. It uses a combination of embedding similarity and LLM evaluation to determine relevance.
How to use it
To use the answer-relevance assertion type, add it to your test configuration like this:
assert:
- type: answer-relevance
threshold: 0.7 # Score between 0 and 1
How it works
The answer relevance checker:
- Uses an LLM to generate potential questions that the output could be answering
- Compares these questions with the original query using embedding similarity
- Calculates a relevance score based on the similarity scores
A higher threshold requires the output to be more closely related to the original query.
Example Configuration
Here's a complete example showing how to use answer relevance:
prompts:
- 'Tell me about {{topic}}'
providers:
- openai:gpt-5
tests:
- vars:
topic: quantum computing
assert:
- type: answer-relevance
threshold: 0.8
Overriding the Providers
Answer relevance uses two types of providers:
- A text provider for generating questions
- An embedding provider for calculating similarity
You can override either or both:
defaultTest:
options:
provider:
text:
id: gpt-5
config:
temperature: 0
embedding:
id: openai:text-embedding-ada-002
You can also override providers at the assertion level:
assert:
- type: answer-relevance
threshold: 0.8
provider:
text: anthropic:claude-2
embedding: cohere:embed-english-v3.0
Customizing the Prompt
You can customize the question generation prompt using the rubricPrompt property:
defaultTest:
options:
rubricPrompt: |
Given this answer: {{output}}
Generate 3 questions that this answer would be appropriate for.
Make the questions specific and directly related to the content.
Further reading
See model-graded metrics for more options.