Overview
The Refusal evaluator detects when an LLM refuses, declines, or avoids answering a user query. It captures explicit refusals, scope disclaimers, lack-of-information responses, safety refusals, redirections, and apologetic non-answers.When to Use
Use the Refusal evaluator when you need to:- Detect explicit refusals - Identify responses like “I can’t help with that” or “I’m unable to answer”
- Flag scope disclaimers - Catch responses claiming the question is outside the LLM’s responsibilities
- Identify lack-of-information responses - Detect responses like “I don’t have that information”
- Spot redirections - Find responses that deflect to other resources without answering
- Monitor refusal rates - Track how often your LLM declines to engage with user queries
The Refusal evaluator is use-case agnostic. It only detects whether a refusal occurred, not whether the refusal was appropriate. A refusal to an out-of-scope question is still classified as a refusal, and an incorrect answer is still classified as an answer. Use it alongside other evaluators like Correctness to get a complete picture.
Supported Levels
The level of an evaluator determines the scope of the evaluation in OpenTelemetry terms. Some evaluations are applicable to individual spans, some to full traces or sessions, and some are applicable at multiple levels.| Level | Supported | Notes |
|---|---|---|
| Span | Yes | Apply to LLM spans to detect refusals in individual responses. |
Input Requirements
The Refusal evaluator requires two inputs:| Field | Type | Description |
|---|---|---|
input | string | The user’s query or question |
output | string | The LLM’s response to evaluate |
Formatting Tips
For best results:- Use human-readable strings rather than raw JSON for all inputs
- For multi-turn conversations, format input as a readable conversation:
Output Interpretation
The evaluator returns aScore object with the following properties:
| Property | Value | Description |
|---|---|---|
label | "refused" or "answered" | Classification result |
score | 1.0 or 0.0 | Numeric score (1.0 = refused, 0.0 = answered) |
explanation | string | LLM-generated reasoning for the classification |
direction | "neutral" | Neither higher nor lower scores are inherently better |
metadata | object | Additional information such as the model name. When tracing is enabled, includes the trace_id for the evaluation. |
- Refused (1.0): The LLM declined, deflected, or avoided answering the query
- Answered (0.0): The LLM provided a substantive response, regardless of correctness or quality
Usage Examples
- Python
- TypeScript
Using Input Mapping
When your data has different field names or requires transformation, use input mapping.- Python
- TypeScript
Configuration
For LLM client configuration options, see Configuring the LLM.Viewing and Modifying the Prompt
You can view the latest versions of our prompt templates on GitHub. The evaluators are designed to work well in a variety of contexts, but we highly recommend modifying the prompt to be more specific to your use case. Feel free to adapt them.- Python
- TypeScript
Using with Phoenix
Evaluating Traces
Run evaluations on traces collected in Phoenix and log results as annotations:Running Experiments
Use the Refusal evaluator in Phoenix experiments:API Reference
- Python: RefusalEvaluator
- TypeScript: createRefusalEvaluator
Related
- Correctness Evaluator - For evaluating factual accuracy of responses
- Conciseness Evaluator - For evaluating response brevity

