Skip to main content

Output Relevance

The Output Relevance metric evaluates how well a generated response aligns with the core intent of a user's query. It identifies responses that may include unrelated or tangential information, miss the main point, or misinterpret the query. This is particularly useful in systems where precision and intent matching are critical; such as search engines, chatbots, and enterprise assistants.

Response Format

The API returns a list of detection results, each containing an output_relevance object with these key fields:

  • score (float, 0.0 – 1.0):
    Represents how relevant the response is to the user query:

    • 0.0–0.2: Poor alignment with intent.
    • 0.2–0.7: Partial relevance; contains some irrelevant or misunderstood content.
    • 0.7–1.0: Strongly aligned; focused and relevant.
  • instructions_list (array):
    A list of individual guideline evaluations:

    • instruction: A rule representing one aspect of output relevance (e.g., "Response should directly address the core intent").
    • label: Indicates whether the response followed the instruction (true) or violated it (false).
    • follow_probability: A confidence score indicating the likelihood the instruction was followed.
    • explanation: A natural-language rationale explaining why the instruction was marked true or false.

Note: The score is an overall judgment, but the instruction-level breakdown provides insight into specific strengths or issues in the response.

API Request & Response Example

[
{
"user_query": "Describe Paul Graham's work life?",
"generated_text": "Paul Graham has worked in several key areas throughout his career: IBM 1401: He began programming on the IBM 1401 during his school years, specifically in 9th grade. In addition, he has also been involved in writing essays and sharing his thoughts on technology, startups, and programming.",
"config": {
"output_relevance": {
"detector_name": "default",
"explain":true
}
}
}
]

Code Examples

# Synchronous example

import os
from aimon import Client
import json

# Initialize client
client = Client(auth_header=f"Bearer {os.environ['AIMON_API_KEY']}")

# Construct payload
payload = [{
"generated_text": "Our return policy allows returns within 30 days of purchase.",
"user_query": "What is your return policy?",
"config": {
"output_relevance": {
"detector_name": "default",
"explain": True
}
},
"publish": False
}]

# Call sync detect
response = client.inference.detect(body=payload)

# Print result
print(json.dumps(response[0].output_relevance, indent=2))