Skip to content
mentoor

Topic 5 of 5 · 4 min read

The off-the-shelf metric trap

Goal: Spot a prebuilt metric that does not measure the product's real failure mode and replace it.

A prebuilt score like "helpfulness" or "coherence" measures what its author imagined, not what breaks in your product; build metrics from the failures you actually see. Libraries make generic metrics one line to add, which is exactly why teams add them without asking if they matter.

Check yourself · 1 of 3

A library's helpfulness score is 0.9, but users report wrong cancellation fees. What is the likely problem?

Choose one answer

Why it matters

A generic metric can sit at 0.9 while real users hit a bug every day. The number feels like evidence, so the team stops looking. The score measures the judge prompt and the library's idea of quality, not your task.

How the trap works

Imagine a booking assistant. The real failures are: it confirms a date that is already full, and it quotes the wrong cancellation fee. A built-in "helpfulness" judge rates polite, fluent answers highly, including the ones with a wrong fee. The metric is high and the product is wrong.

How to build the right metric

  1. Read real outputs. Sample 50 to 100 traces and write one-line notes on what is wrong. This is error analysis.
  2. Group the notes. Count categories: wrong fee, double booking, ignored language, rude tone.
  3. Pick the frequent or costly ones. Each becomes one narrow check.
  4. Use code first. Is the fee in the answer equal to the fee in the policy table? That is an exact check, no judge needed.
  5. Use a narrow judge where code cannot. A yes/no question about one failure, such as "does the answer promise a refund the policy does not allow?"
  6. Calibrate. Compare the judge with human labels on a sample before trusting it.

Before and after

Before:

from deepeval.metrics import AnswerRelevancyMetric
metric = AnswerRelevancyMetric(threshold=0.7)  # generic relevance

After, from error analysis:

def fee_is_correct(answer: str, booking) -> bool:
    return f"{booking.cancel_fee:.2f}" in answer

The second check is boring and tells you exactly when the product is wrong.

When generic metrics help

They are fine as a rough smoke test, or while you have no error analysis yet. Keep them as a side signal, never as the release gate.

What goes wrong

  • Number worship. A threshold chosen because 0.7 sounds reasonable.
  • One score for everything. An average hides the one failure that matters.
  • Uncalibrated judges. A judge never compared to human labels may agree with itself and nobody else.

Examples

High score, wrong answer

A support bot answers "Your refund will arrive in 3 days" when the policy says 10. A hallucination metric based on general plausibility gives it 0.92 because the sentence is natural. A code check comparing the stated days with the policy table fails it immediately.

Key points

  • Prebuilt metrics measure a generic idea of quality, not your product's failure modes.
  • Error analysis on real outputs tells you which failures to measure.
  • Prefer exact code checks, then narrow yes/no judges, over broad scores.
  • Calibrate any LLM judge against human labels before using it as a gate.
  • Generic metrics can stay as a smoke test but should not decide a release.

Common mistakes

  • Adding every metric a library offers and averaging them into one number.
  • Setting a pass threshold such as 0.7 without checking what a 0.7 output looks like.
  • Skipping error analysis and measuring what the tool makes easy.
  • Trusting an LLM judge that was never compared with human labels.

Check yourself · 2 of 3

What is the first step toward a metric that fits your product?

Choose one answer

Check yourself · 3 of 3

A check compares the refund days in an answer with the policy table. Why is this better than a broad judge for that failure?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic