Interview's MateAI Engineering
Interview's Mate

AI Engineering

LLMs, RAG, agents & evals

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
AI Engineering topics
Lesson 67/ 160
04. Evals

Answer Relevance

Measure whether the response actually addresses the user question.

BeginnerOn-topic · Completeness3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidHands-onQuiz (3)Practice

In plain words

Answer relevance checks whether the AI actually replied to what you asked, not something nearby.

Think of it like…

A student asked "why did the Roman Republic fall?" who writes a beautiful, accurate essay on Roman roads. Marked on accuracy, they'd pass; marked on answering the question, they'd fail.

Where you’ve seen it

Asked "What is the refund window for electronics and how do I start a return?", the assistant replies with two paragraphs about the company's history and free shipping. A judge scores relevance 0 of 2 (answers neither part). In a second variant, the assistant states the 30-day window but never explains how to start a return: 1 of 2 (partial). With the question-generation method, three questions generated from the first answer ("When was the company founded?", "Is shipping free?", "What does the company sell?") have an average embedding similarity of 0.31 to the real question, versus 0.86 for a good answer. Over a release run, mean relevance drops from 1.78 to 1.52 after a prompt change that added a long preamble, which the team catches and reverts.

Words you’ll hear

Relevance
How directly the response addresses the user's actual question.
Completeness
Whether all parts of a multi-part question are answered.
Reverse question generation
Generating questions the answer would satisfy and comparing them with the original.
Noise / padding
Content that does not contribute to answering.

Visual diagram

Loading interactive diagram

Theory & deep dive

Measuring relevance

The direct approach is an LLM judge with a rubric: 2 = addresses every part of the question directly; 1 = partially answers, misses a part or buries the answer in noise; 0 = off-topic or evasive. Break compound questions into sub-questions and check each one, since partial answers are the commonest failure. Include the conversation history so the judge understands follow-ups ("and for international orders?"). Provide instructions about acceptable behaviour: a correct, polite refusal or clarifying question may count as relevant when the request was ambiguous or out of scope.

The reverse-question method (RAGAS "answer relevancy") asks an LLM to write N questions (typically 3) that the given answer would answer, embeds them and the original question, and averages the cosine similarities. A good answer implies questions close to the original; an off-topic answer implies different ones. It needs no judge rubric, but it's insensitive to *incomplete* answers (a partial answer still yields similar questions) and depends on embedding quality, so use it as a cheap screen and the judge for detail.

Splitting a compound question

Question: "What's the refund window for electronics and how do I start a return?" Sub-questions: (1) window length, (2) how to initiate. Answer states 30 days only: addresses 1 of 2 sub-questions, relevance 1 on a 0–2 scale.

Key takeaway: Check every sub-question with a judge, and use reverse questions as a cheap screen.

Interpreting and acting on it

Relevance failures have distinct causes. Retrieval returned the wrong topic so the model answered what it had; the prompt encourages preambles, caveats or over-explaining; the model misread an ambiguous or multi-part question; or a safety instruction over-triggers refusals. Read low-scoring cases (error analysis) before changing anything, and slice by question type and length. Track it alongside answer length: a rising average length with falling relevance usually signals padding.

Handle edge cases deliberately: should "I don't have that information" count as relevant when the corpus really lacks the answer? Usually yes if it's honest and points to next steps, but score it separately (an "appropriate abstention" label) so you can monitor refusal rates. Combine with faithfulness and correctness: a good answer is relevant, grounded and right, and the three metrics point to different fixes. Validate your judge on labelled examples, include adversarial cases such as fluent off-topic text, and report confidence intervals when comparing versions.

Three metrics, three diagnoses

Faithful but irrelevant: retrieval or question understanding is off. Relevant but unfaithful: the model is inventing. Relevant and faithful but incorrect: the source documents are wrong or outdated.

Key takeaway: Diagnose by metric combination, watch length, and score appropriate abstentions separately.

How it works, step by step

Step 1 of 4
Judge LLM

1. Decompose the question

Split compound or follow-up questions into sub-questions using the conversation history.

window length · how to start a return
Key numbers at this step
Partial answers
most common

When to use it & trade-offs

What it is

Answer relevance measures whether a response directly addresses the question that was asked: complete, on topic and without padding. It's independent of whether the content is true or grounded. A response that confidently describes shipping policy when the user asked about refunds is irrelevant even if every sentence is faithful. It's measured with an LLM judge ("does the answer address all parts of the question?") or with the RAGAS-style trick of generating questions from the answer and checking how similar they are to the original question.

Why it matters: Users judge an assistant by whether it answered *their* question. Off-topic, evasive or partial answers pass faithfulness and style checks yet leave the user stuck, and are common after prompt changes that make the model chatty or cautious. Relevance gives a metric for the "did it actually help" dimension and complements faithfulness (is it grounded) and correctness (is it right).

When to reach for it

  • Catching chatty, evasive or off-topic answers after prompt changes
  • Multi-part and follow-up question handling
  • Complementing faithfulness and correctness metrics

When to avoid or be careful

  • Treating faithfulness as a proxy for answering the question
  • Ignoring conversation history when judging follow-ups
  • Lumping honest abstentions with irrelevant answers

Ways to measure relevance

LLM judge with rubric
Best for: Detailed, multi-part and context-aware scoring

Strengths: Catches partial answers; explains verdicts.

Watch out: Needs validation; costs per call.

Reverse question similarity
Best for: Cheap screening at scale

Strengths: No rubric; fast.

Watch out: Misses incompleteness; embedding dependent.

Human review
Best for: Gold labels and calibration

Strengths: Reliable on nuance.

Watch out: Slow and expensive.

Interview signals & numbers to know

When this topic comes up

  • “The answer is accurate but doesn't help”
  • “After the prompt change replies got longer”
  • “Answer relevancy in RAGAS”
  • Multi-part questions
  • Refusal rates

Benchmarks & rules of thumb

0.31 vs 0.86 -
question similarity for off-topic vs good answers
1.78 → 1.52 -
mean relevance drop caught in the example
3 -
questions typically generated per answer

Common mistakes & follow-ups

Common interview mistakes

  • Scoring only on style and missing that half the question went unanswered.
  • Relying on reverse-question similarity alone and missing incomplete answers.
  • Penalising a correct, honest "not in the documents" response as irrelevant.

Likely interviewer follow-ups

  • How is answer relevance different from faithfulness?
  • How would you evaluate multi-part questions?
  • Why might relevance drop after a prompt change?
Interview tip: Describe the three metrics (faithful, relevant, correct) and the failure each isolates. It proves you can diagnose, not just score.
Loading hands-on exercise

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Answer Relevance with generative AI interview Q&A and hands-on practice.

Open Generative AI Q&A →Tech Learn Q&A
Previous topic
Faithfulness
Next topic
Context Precision