GUIDE / ai evals
LLM Evaluation Metrics: A Practical Guide
A practical guide to LLM evaluation metrics: faithfulness, answer relevancy, BLEU vs semantic scores, LLM-as-judge, and offline vs online eval.
If you ship AI features, LLM evaluation metrics are how you turn “the model seems better” into evidence. Without metrics, prompt changes become superstition, model upgrades become gambling, and regressions hide behind fluent language. With the right mix of automatic scores, LLM-as-a-judge rubrics, and human review, teams can compare versions, block bad releases, and learn where the product still fails.
This practical guide explains the main metric families, faithfulness vs answer relevancy, BLEU and ROUGE versus semantic metrics, offline vs online evaluation, how to choose metrics for different app types, worked examples, and the common mistakes that create false confidence.
Why LLM Evaluation Needs Different Metrics Than Classical Software
Classical assertions are exact. expect(total).toBe(42) either passes or fails.
LLM outputs are:
- non-deterministic across runs and temperatures
- linguistically variable with many valid answers
- quality-graded rather than only correct or incorrect
- dependent on retrieval context, tools, and memory
- risky in ways unit tests rarely model, such as hallucination and unsafe advice
That does not mean “testing is impossible.” It means your quality system needs:
- Task definitions and golden datasets.
- Metrics that match the failure modes you care about.
- Thresholds and statistical judgment, not one-off vibes.
- Human calibration for high-impact cases.
- Online monitoring after release.
Metrics are the measurement layer of that system.
A Map of LLM Evaluation Metrics
| Family | Examples | Best for | Weak when |
|---|---|---|---|
| Exact / lexical overlap | Exact match, BLEU, ROUGE, F1 | Constrained outputs, some summary/translate tasks | Open-ended answers with many valid forms |
| Semantic similarity | Embedding cosine, BERTScore | Paraphrase-tolerant scoring vs references | References are poor or missing |
| Groundedness / RAG | Faithfulness, context precision/recall | Retrieval-augmented answers | No source context exists |
| Rubric / judge | G-Eval style, custom LLM judges | Nuanced quality criteria | Judge bias and unstable prompts |
| Safety | Toxicity, PII leak, policy violation rates | Trust and compliance risk | Over-refusal not measured |
| Product / ops | Task success, latency, cost, click-through | Business outcomes | Vanity metrics without task definition |
| Human ratings | Likert scores, preference pairwise | Calibration and subtle quality | Expensive and slower |
A serious program combines several families. One score almost never tells the whole story.
Automatic vs Human LLM Evaluation
Automatic evaluation
Automatic evaluation runs without a human in the loop for each row. It includes:
- string checks and regexes
- JSON schema validation
- BLEU/ROUGE/BERTScore
- embedding similarity
- RAG metrics such as faithfulness
- LLM-as-judge scoring functions
- safety classifiers
Strengths:
- fast feedback in CI
- repeatable comparisons across commits
- large dataset coverage
Weaknesses:
- can reward the wrong behavior
- may miss rare catastrophic failures
- judge models can be biased or noisy
Human evaluation
Human evaluation uses raters, domain experts, or target users.
Strengths:
- best for subtle correctness and product taste
- essential for safety edge cases and regulated domains
- calibrates automatic judges
Weaknesses:
- cost and time
- rater disagreement
- hard to run on every commit
Practical blend
| Layer | Cadence | Purpose |
|---|---|---|
| Deterministic checks | every PR | schema, policy bans, required citations format |
| Automatic metrics + judges | every PR or nightly | regression detection |
| Human spot checks | weekly / pre-release | calibrate and audit failures |
| Online metrics | continuous | real-world drift and UX outcomes |
Faithfulness vs Answer Relevancy
These two metrics are easy to confuse and critical to separate.
Faithfulness
Faithfulness asks: does the answer stick to the provided context or sources?
Unfaithful example:
- Context says the refund window is 30 days.
- Answer says customers have 90 days.
The answer may sound helpful. It is still unfaithful.
Answer relevancy
Answer relevancy asks: does the answer address the user’s question?
Irrelevant example:
- Question: “How do I reset my password?”
- Answer: a faithful summary of the company’s shipping policy.
Why both matter
| Answer style | Faithful? | Relevant? | Product impact |
|---|---|---|---|
| Correct grounded answer | Yes | Yes | Ideal |
| Hallucinated but on-topic | No | Yes | High trust risk |
| Grounded but off-topic | Yes | No | Poor UX |
| Hallucinated and off-topic | No | No | Worst of both |
RAG systems especially need faithfulness. General assistants also need relevancy and task success. For RAG-specific metric implementations, continue with RAGAS: Evaluating RAG Pipelines.
BLEU and ROUGE vs Semantic Metrics for LLMs
BLEU
BLEU measures n-gram overlap between output and reference text. It began in machine translation.
Useful when:
- outputs are relatively constrained
- references are high quality
- wording overlap correlates with quality
Weak when:
- many correct phrasings exist
- creative generation is allowed
- short answers flip the score dramatically
ROUGE
ROUGE is common in summarization evaluation and also depends on overlap with references.
Useful when:
- summary content overlap matters
- references capture key facts well
Weak when:
- summaries are abstractive and paraphrased
- reference summaries are incomplete
Semantic metrics
Embedding similarity and BERTScore compare meaning rather than exact words.
Useful when:
- paraphrases should score highly
- you have reference answers
Weak when:
- references themselves are wrong
- high similarity hides factual inversion (“is” vs “is not”)
Tester takeaway
Do not lead with BLEU/ROUGE for an open-ended support agent. Lead with task-specific checks, faithfulness, structured output validation, and rubric judges. Keep lexical metrics only when the task justifies them.
LLM-as-a-Judge Evaluation Metrics
LLM-as-a-judge means a model scores another model’s output using a prompt and rubric.
For implementation details and calibration patterns, see LLM as a judge.
Typical criteria:
- correctness
- completeness
- tone
- safety
- citation quality
- tool-use appropriateness
Why teams use judges
- scales beyond human labeling
- handles open-ended criteria better than BLEU
- can encode product-specific rubrics
Risks
- position bias and verbosity bias
- judge family bias toward similar models
- unstable scores when temperature is not controlled
- rubric ambiguity creating random variance
- cost and latency in CI
How to make judges trustworthy
- Write a crisp rubric with pass/fail examples.
- Fix temperature and model version for the judge.
- Prefer structured score outputs with short rationales.
- Calibrate against a human-labeled gold set.
- Track inter-rater agreement between judge and humans.
- Re-calibrate when either model family changes.
- Never let an uncalibrated judge be the only release gate for high-risk domains.
DeepEval popularized developer-friendly patterns for this style of testing. See the DeepEval tutorial for implementation-oriented workflow.
Task-Specific Metric Design
The best metric is the one tied to the product job.
Customer support copilot
- solution correctness against policy docs
- faithfulness to knowledge base
- escalation appropriateness
- tone compliance
- leakage of internal notes
- median latency and cost per ticket
RAG research assistant
- context precision and recall
- faithfulness
- citation presence and correctness
- answer relevancy
- refusal quality when sources are insufficient
SQL or code generator
- executability rate
- unit test pass rate
- static analysis findings
- exact or semantic match to gold queries when available
- destructive action safeguards
Classification or extraction
- precision, recall, F1
- schema validation
- per-label confusion matrix
- threshold calibration
If a metric does not change a decision about shipping or debugging, question whether it belongs in the main dashboard.
Offline vs Online LLM Evaluation
Offline evaluation
Offline eval uses curated datasets and runs in development or CI.
Strengths:
- controlled comparisons
- reproducible regression gates
- cheap exploration of prompt variants
Components:
- golden set of prompts and expected traits
- metrics and judges
- baseline model/prompt version
- threshold policy
Online evaluation
Online eval observes production.
Signals:
- explicit user thumbs up/down
- implicit success events (issue resolved, checkout completed)
- human agent takeover rate
- safety filter triggers
- latency and cost
- deflection rate
- complaint categories
How they work together
| Question | Offline | Online |
|---|---|---|
| Did this prompt regress on known hard cases? | Best | Lagging |
| Do real users accept answers? | Weak proxy | Best |
| Is retrieval quality drifting? | Synthetic + logs replay | Live traces |
| Is cost spiking? | Estimate | Direct |
A mature team runs offline gates before deploy and online monitors after deploy. Neither replaces the other.
Building a Metric Stack by Risk Level
| Risk level | Example | Minimum metric stack |
|---|---|---|
| Low | Internal joke generator | smoke checks, toxicity basic, latency |
| Medium | Help center draft replies | faithfulness, relevancy, tone rubric, human sample |
| High | Medical, legal, financial advice support | strict groundedness, expert review, refusal quality, audit logs |
| Tool-using agent | Refunds, account changes | task success, policy constraints, tool-call correctness, dry-run tests |
Match rigor to blast radius.
Statistical Thinking for Non-Deterministic Systems
Because outputs vary, avoid overreacting to one-run differences.
Practical rules:
- evaluate on enough samples to see a signal
- fix seeds or temperatures when comparing versions if the stack allows
- report pass rates and score distributions, not only averages
- separate product regressions from judge noise
- re-run borderline suites before blocking releases when flukes are known
If score variance is huge, improve the rubric or dataset before blaming the model.
Dataset Quality Determines Metric Value
A perfect metric on a bad dataset still misleads.
Dataset design notes:
- include real user language, not only polished prompts
- balance easy and hard cases
- cover safety and abuse prompts deliberately
- version datasets like code
- keep expected outputs or rubrics maintainable
- avoid leaking test items into prompt examples accidentally
For hands-on dataset construction patterns, see building an LLM eval dataset.
Worked Example: Choosing Metrics for a RAG FAQ Bot
Product goal: answer authenticated users from a product knowledge base with citations.
Candidate failures:
- Invents policy details.
- Answers the wrong question.
- Retrieves irrelevant docs.
- Misses the one critical doc.
- Speaks with overconfident tone when unsure.
- Leaks another tenant’s content.
Metric choices:
| Failure | Metric / check |
|---|---|
| Invents policy | Faithfulness / groundedness |
| Wrong question focus | Answer relevancy |
| Bad retrieval ranking | Context precision |
| Missed needed doc | Context recall |
| Overconfident guess | Rubric: refusal/uncertainty quality |
| Tenant leak | Authorization and retrieval isolation tests |
Secondary ops metrics:
- p95 latency
- cost per answer
- citation click rate
- thumbs-down rate online
This stack is much stronger than “average cosine similarity to a sample answer.”
Interpreting Metric Movements
Not every score increase is a win.
Examples:
- Relevancy up, faithfulness down: model is more persuasive and more wrong.
- ROUGE up because answers became extractive walls of text: users may hate verbosity.
- Judge score up after switching judge model: measurement changed, not necessarily product quality.
- Offline scores stable, online thumbs-down up: dataset drift or UX issue outside answer text.
Always ask: what user failure does this number represent?
CI Gates With LLM Metrics
A practical PR gate might include:
- JSON schema validity for structured outputs: hard fail.
- Policy ban list / forbidden claims: hard fail.
- Faithfulness below threshold on critical set: hard fail.
- Average judge score drop beyond delta: soft fail or hard fail by risk.
- Latency/cost budget exceeded: warn or fail by service class.
Keep critical sets small and high signal so CI remains usable. Run larger suites nightly.
Common Mistakes With LLM Evaluation Metrics
Mistake 1: One Metric to Rule Them All
A single “quality score” hides tradeoffs. Use a small balanced set.
Mistake 2: Using BLEU as a General Assistant Metric
Open-ended product answers need semantic, task, and groundedness measures.
Mistake 3: Uncalibrated LLM Judges as Sole Gate
Judges are tools, not oracles. Calibrate and audit them.
Mistake 4: No Human Review Loop
Humans find the failures your metrics cannot yet express.
Mistake 5: Metrics Without Action Thresholds
Dashboards that never block or trigger work become decoration.
Mistake 6: Ignoring Safety and Authorization
Quality is not only helpfulness. It includes harm avoidance and data isolation.
Mistake 7: Offline Only or Online Only
Offline without online misses drift. Online without offline makes regressions expensive.
Mistake 8: Not Versioning Prompts, Models, and Datasets Together
If you cannot say which prompt and dataset produced a score, you cannot learn.
Practical Workflow You Can Reuse
- Define the user task and unacceptable failures.
- Collect a starter golden set from real or realistic traffic.
- Choose 3-6 metrics tied to those failures.
- Add deterministic checks for structure and hard constraints.
- Add automatic metrics and judges for graded quality.
- Calibrate with human labels on a sample.
- Set thresholds and CI ownership.
- Run offline on each meaningful change.
- Monitor online success, safety, cost, and latency.
- Feed production failures back into the golden set.
- Revisit metrics when the product or model family changes.
Metric Selection Cheat Sheet
| If your main risk is... | Start with... |
|---|---|
| Hallucinated facts in RAG | Faithfulness, citation checks |
| Off-topic answers | Answer relevancy, task success |
| Bad retrieval | Context precision/recall |
| Structured output breakage | Schema validation, exact field checks |
| Tone or policy style | Rubric judge + human audits |
| Unsafe content | Safety classifiers + red team set |
| Cost explosion | Tokens, tool calls, cache hit rate |
| Slow UX | p95 latency, time-to-first-token |
How This Connects to Hallucination Detection
Hallucination is often the business name for low faithfulness or unsupported claims. Metrics make that issue measurable, but detection strategy also includes retrieval design, refusals, and source display. For a deeper treatment of failure modes and detection tactics, read hallucination detection for LLMs.
Cost Metrics Belong Next to Quality Metrics
A challenger that scores slightly higher and costs five times more may be the wrong ship decision. Track:
- average input and output tokens
- judge tokens if LLM-as-judge runs in CI
- tool-call counts for agents
- cache hit rates
- p95 latency and time to first token
Put cost beside faithfulness and task success in the same report. Quality without economics is incomplete product evaluation for most teams.
Regression Baselines and Champion Challengers
A metric number without a baseline is hard to use. Adopt a champion/challenger pattern:
- Champion: currently shipped prompt, model, and retrieval config
- Challenger: proposed change
- Arena: fixed dataset and fixed metric configuration
Only promote a challenger when:
- critical tags meet thresholds
- no high-severity tag regresses beyond agreed tolerance
- cost and latency remain acceptable
- humans reviewed a sample of deltas for high-risk domains
Store historical champion scores so you can see long-term drift, not only the last PR comparison.
Tool-Use and Agent Metrics
When the system can call tools, pure answer text metrics are incomplete.
Add measurements for:
- correct tool selected
- required arguments present and valid
- unnecessary tool calls avoided
- retries on tool failure
- final user message still faithful after tool results
- policy blocks before irreversible actions
Example: a refund agent that writes a lovely apology but calls create_refund with the wrong order id can score well on tone and still fail the business task. Task success and tool-call correctness must sit beside language metrics.
Preference Evaluation and Pairwise Comparisons
Sometimes there is no single gold answer. Pairwise preference tests ask which of two outputs is better according to a rubric or human rater.
Use pairwise evaluation when:
- you are choosing between two prompts or models
- quality is multi-dimensional and absolute scores feel noisy
- product taste matters (clarity, empathy, brevity)
Caveats:
- order bias can favor the first or second answer
- judges may prefer longer answers unless the rubric penalizes verbosity
- preferences without failure tags do not explain how to fix the loser
Combine pairwise winners with tagged failure analysis so the result is actionable.
Communicating Metrics to Non-Engineers
Executives and PMs need translation, not raw cosine tables.
Better reporting language:
- “Policy faithfulness on billing questions improved from 78% to 91%.”
- “Refusal quality on out-of-scope medical advice held at 100% on the critical set.”
- “We blocked release because safety tag pass rate fell from 20/20 to 17/20.”
- “Online thumbs-down rose mainly on multi-intent questions, which offline set underrepresented.”
Avoid:
- “The model is smarter now.”
- “Average quality is 0.83.”
- “The judge likes this version.”
Metrics are for decisions. Report the decision context.
A 30-Day Metric Program Starter Plan
Week 1:
- list top user tasks and unacceptable failures
- gather 40 real or realistic examples
- pick 3 metrics plus deterministic checks
Week 2:
- implement offline scoring
- label 20 cases with humans
- calibrate thresholds
Week 3:
- put smoke gates in CI
- create tag-level dashboard
- review first regressions
Week 4:
- add online feedback hooks
- feed production misses into the set
- write ownership notes for each critical tag
After 30 days you will not have perfect evaluation. You will have a living quality system instead of vibes.
Final Takeaways
LLM evaluation metrics are not academic decorations. They are decision tools for shipping AI features with eyes open. Choose metrics from failure modes, not from blog-post popularity. Separate faithfulness from relevancy. Use lexical metrics only when they fit. Treat LLM-as-judge as a powerful but fallible instrument. Combine offline gates with online truth. For agents, measure tool success as carefully as prose quality.
If you remember one principle, remember this: a metric is useful only when it helps you choose the better system version for real users under real risks.
For practice designing eval judgment calls, create an account at QABattle sign-up and use AI-eval style battles to compare outputs against explicit rubrics before you trust a single score.
FAQ
Questions testers ask
What metrics are used to evaluate LLMs?
Common LLM evaluation metrics include exact match, BLEU, ROUGE, BERTScore, embedding similarity, faithfulness, answer relevancy, context precision, context recall, toxicity, latency, cost, and task success rates. Strong programs mix automatic metrics, LLM-as-judge scores, and human review for high-risk cases.
What is the difference between automatic and human LLM evaluation?
Automatic evaluation scores outputs with code or model judges at scale and is repeatable in CI. Human evaluation uses expert or user raters for quality judgments that metrics may miss, such as subtle factual nuance, brand tone, or safety edge cases. Automatic methods scale. Human methods calibrate and catch what numbers miss.
What is faithfulness vs answer relevancy?
Faithfulness measures whether the answer stays grounded in provided context or sources without inventing unsupported claims. Answer relevancy measures whether the answer actually addresses the user question. An answer can be faithful to context but irrelevant to the question, or relevant-sounding but unfaithful and hallucinated.
What is LLM-as-a-judge evaluation?
LLM-as-a-judge uses a model with a rubric to score another model's output for criteria such as correctness, helpfulness, safety, or style. It scales better than pure human review, but needs careful prompts, reference calibration, bias checks, and spot human audits to remain trustworthy.
Should I use BLEU or ROUGE for LLM apps?
BLEU and ROUGE can help for constrained generation tasks with stable references, such as some summarization or translation settings. They are weak for open-ended assistants where many valid phrasings exist. Prefer semantic similarity, task-specific checks, faithfulness metrics, and rubric judges for most product LLM evaluation.
What is offline vs online LLM evaluation?
Offline evaluation runs curated datasets and metrics before release in CI or notebooks. Online evaluation measures live production behavior through user feedback, success events, defense filters, latency, and cost. Offline catches regressions early. Online reveals real distribution shift and UX impact.
RELATED GUIDES
Continue the route
DeepEval Tutorial: Unit Testing for LLM Applications
DeepEval tutorial for unit testing LLM applications with pytest-style metrics, G-Eval rubrics, faithfulness examples, and DeepEval vs Ragas.
RAGAS: Evaluating RAG Pipelines
Learn Ragas for RAG evaluation: faithfulness, context precision, contextual recall, dataset design, and how to measure retrieval-augmented generation quality.
Building an LLM Eval Dataset: Golden Sets and Rubrics
Learn building an LLM eval dataset with golden sets, rubrics, synthetic data, human labels, edge cases, sizing rules, and versioning for reliable evals.
Hallucination Detection: Testing LLMs for Accuracy
Learn LLM hallucination detection with groundedness scoring, factual consistency checks, rate measurement methods, and practical accuracy test design.