Skip to content
Blog Panji

The Complete Guide to LLM Evaluation: Metrics, Benchmarks, and LLM-as-a-Judge

Learn how to evaluate language models: the right LLM evaluation metrics, popular benchmarks, and LLM-as-a-judge techniques — with a working Python eval harness example.

Panji Ihsanudin Fajri

16 min read0 reads

Illustration of LLM evaluation: a neural network inspected under a magnifier with an evaluation scoreboard
Illustration of LLM evaluation: a neural network inspected under a magnifier with an evaluation scoreboard
Contents
  1. What is LLM evaluation?
  2. Why "looks good to me" is not an evaluation
  3. Four approaches to LLM evaluation
  4. 1. Static benchmarks
  5. 2. Human evaluation
  6. 3. LLM-as-a-judge
  7. 4. Task-based evaluation in your application
  8. LLM benchmarks you should know
  9. Evaluation metrics: from accuracy to pass@k
  10. Accuracy and exact match
  11. pass@k for code
  12. Win rate and Elo
  13. Classic text metrics: BLEU, ROUGE, BERTScore
  14. RAG-specific metrics
  15. LLM-as-a-judge: how it works and where it breaks
  16. Case study: a minimal eval harness for a chatbot
  17. Common mistakes in LLM evaluation
  18. Best practices: which approach for which situation
  19. FAQ
  20. How does LLM evaluation differ from regular software testing?
  21. How many examples are enough for an internal eval set?
  22. Can LLM-as-a-judge fully replace human raters?
  23. Which benchmark is most relevant for a customer-service chatbot?
  24. How do you detect benchmark contamination?
  25. Conclusion

A language model that feels brilliant in a demo can fall apart in production. LLM evaluation is the discipline that answers a simple but hard question: how do you know your model is actually good, rather than merely convincing? This guide covers LLM evaluation metrics, the benchmarks that matter, and the LLM-as-a-judge technique, plus the traps that make evaluation numbers lie.

Summary: LLM evaluation measures model capability through standard benchmarks, human review, LLM-as-a-judge, and task-based testing. Benchmarks like MMLU-Pro, SWE-bench, and Humanity's Last Exam give you numbers you can compare across models. LLM-as-a-judge reaches over 80% agreement with humans but carries position, verbosity, and self-enhancement biases. Good evaluation always starts from your own golden dataset, not a public leaderboard.

Illustration of LLM evaluation: a neural network inspected under a magnifier with an evaluation scoreboard
From model to number: LLM evaluation turns model outputs into comparable scores.

What is LLM evaluation?

LLM evaluation is the systematic process of measuring how well a language model performs a defined task, using a test dataset and defined metrics. Without it, you have only subjective impressions, and subjective impressions of fluent text are almost always too optimistic.

Evaluation here differs from validation in classical machine learning. In image classification, an answer is right or wrong. With LLMs, one prompt can produce ten answers that are all valid yet differ wildly in quality. LLM evaluation has to handle this open answer space instead of just matching strings.

Why "looks good to me" is not an evaluation

Nearly every team shipping an LLM product has lived through this pattern: the demo feels amazing, then after launch, users find hallucinations, inconsistent formatting, and ignored instructions. The model didn't change. Nobody measured quality systematically in the first place.

Bad evaluation usually takes the form of a vibe check: someone tries five prompts, they all look fine, and the model is declared ready. This fails for three reasons. First, five examples don't represent the thousands of input variations in the wild. Second, humans are bad at judging long text consistently: confident prose sways us. Third, without a baseline number, you can't tell whether your next prompt change or model swap helped or hurt.

Proper evaluation turns quality from an opinion into a number you can track over time. That number is what lets you compare two models, test a prompt change, and catch regressions before they reach users.

Four approaches to LLM evaluation

No single method fits every case. In practice, LLM evaluation uses four complementary approaches.

1. Static benchmarks

A static benchmark is a dataset of questions with known answers, run the same way for every model. MMLU, HumanEval, and SWE-bench fall in this category. Strengths: cheap, fast, repeatable, and comparable across models and over time. Weakness: they measure general capability, not how the model performs on your product's specific task.

2. Human evaluation

Human raters read model outputs and score them or pick the better one. This is the gold standard for subjective quality: tone, creativity, usefulness. The problems: expensive, slow, and inconsistent across raters. Two humans rating the same thing only agree most of the time, not always.

3. LLM-as-a-judge

A strong model grades another model's outputs against a rubric you write. This approach comes from a 2023 paper by Zheng et al. and is now widespread because it scales: tens of thousands of samples graded in hours at low cost. It gets its own section below, because the technique has traps worth understanding.

4. Task-based evaluation in your application

Instead of grading text abstractly, you test whether the user's task got done. For a coding agent: do the tests pass? For a support bot: is the customer's issue resolved per the test scenario? This is closest to business value, but building the scenarios takes real work.

Diagram of an LLM evaluation pipeline: test dataset, model, metrics, judge, and results
A healthy evaluation pipeline: fixed dataset, interchangeable models, consistent metrics, recorded results.

LLM benchmarks you should know

Public benchmarks are the industry's shared language for talking about model capability. Here are the most influential ones, from most established to most demanding.

Benchmark Format Size What it measures
MMLU Multiple choice, 4 options 57 subjects Broad knowledge
MMLU-Pro Multiple choice, 10 options ~12,000 questions, 14 domains Knowledge + reasoning
HumanEval / HumanEval+ Writing Python functions 164 tasks (+hardened variant) Basic coding ability
SWE-bench Fixing real GitHub issues 2,294 problems, 12 repos Practical software engineering
GPQA Graduate-level multiple choice 448 questions (Diamond: 198) Expert-level science
Humanity's Last Exam Free-form Q&A ~3,000 questions, 100+ fields The frontier of human knowledge
MT-Bench Multi-turn Q&A 80 questions, 8 categories Chat assistant ability
AlpacaEval Pairwise comparison Hundreds of instructions Preference vs a reference model
Chatbot Arena Crowdsourced human voting Millions of votes Real user preference

MMLU (Hendrycks et al., 2021) is the classic: 57 subjects from elementary math to professional law, four options each. The problem is that frontier models now score above 90%. The benchmark is saturated and can no longer separate the best from the merely good.

MMLU-Pro (Wang et al., introduced June 2024) answers that saturation: roughly 12,032 questions consolidated into 14 domains, with ten answer options per question instead of four (83% of questions have ten options). Random guessing drops from 25% to 10%, trivial questions were removed, and reasoning-heavy items were added. The effect is real: the same model scores 16–33% lower than on MMLU.

HumanEval (2021) contains 164 tasks of writing Python functions from docstrings, graded by unit tests. Its HumanEval+ variant (EvalPlus, 2023) multiplies the test cases many times over, because the original tests turned out to be too lax, and plenty of wrong solutions passed.

SWE-bench (Jimenez et al., October 2023) goes a level up: 2,294 problems drawn from real GitHub issues across 12 popular Python repositories. The model receives the issue description and a repo snapshot, then must produce a patch. Grading uses the tests from the original pull request: previously failing tests must pass (FAIL_TO_PASS) and previously passing tests must stay green (PASS_TO_PASS). When the paper came out, the best model (Claude 2) solved just 1.96%. The SWE-bench Verified variant (August 2024) contains 500 human-validated tasks. See the SWE-bench Verified leaderboard.

GPQA (Rein et al., 2023) holds 448 graduate-level science questions designed to be "Google-proof": not answerable through ordinary search. Its hardest subset, GPQA Diamond, is only 198 questions. PhD experts get about 65% right; skilled non-experts, 34%.

Humanity's Last Exam (Center for AI Safety and Scale AI, released January 23, 2025) is roughly 3,000 expert-level questions across more than 100 fields, curated from 70,000 candidates by nearly 1,000 contributors from 500 institutions in 50 countries. At release, the best models scored single digits — GPT-4o at 2.7%, Claude 3.5 Sonnet at 4.1% — while human experts hit around 90%. The benchmark was designed as a "last exam": any question AI could already answer was thrown out during curation. Read the backstory at the Turing Institute.

Ladder of LLM benchmarks from easiest to hardest, with a trophy at the top
Every time a benchmark saturates, the industry builds a taller ladder: MMLU, MMLU-Pro, GPQA, Humanity's Last Exam.

One important note: benchmark numbers move fast and leaderboards update constantly. Never quote a model's score from an old article as current fact. Always check the primary source.

Evaluation metrics: from accuracy to pass@k

A benchmark is just a dataset. How you compute a score from it is the metric, and the choice of metric changes the conclusion.

Accuracy and exact match

For multiple choice, plain accuracy is enough: the percentage of correct answers. For short free-form answers (a city name, say), exact match checks string equality against the answer key, sometimes after lowercasing and punctuation normalization. Both are brittle for long text: two equally correct paraphrases can be marked wrong.

pass@k for code

In coding evaluation, the model generates k solutions per problem; the problem counts as solved if any one of the k solutions passes all tests. pass@1 measures first-answer reliability; pass@10 measures the model's potential given several attempts. SWE-bench uses a pass@1 variant: the generated patch must make the relevant tests pass.

Win rate and Elo

For pairwise comparisons (model A vs model B, judged by humans or an LLM judge), win rate is the percentage of wins. Chatbot Arena uses the Elo system borrowed from chess: each model has a rating, and beating a strong opponent raises your rating more than beating a weak one. Elo handles incomplete comparisons: not every pair of models has to face off directly.

Classic text metrics: BLEU, ROUGE, BERTScore

BLEU and ROUGE count n-gram overlap between model output and a reference text. They're cheap and deterministic but correlate weakly with human judgment on open-ended text: a good summary with different wording can score poorly. BERTScore improves on this by comparing embeddings rather than exact words. Better, but still blind to things like instruction following or tone.

RAG-specific metrics

A RAG pipeline needs metrics that separate two failure sources: bad retrieval vs bad generation. Frameworks like Ragas measure faithfulness (is the answer supported by the retrieved context?), answer relevancy (does the answer address the question?), context precision, and context recall (was the retrieved set relevant and complete?). Without this split, you can't tell which component to fix. If you're building RAG, read the complete RAG guide first so you understand the architecture before measuring it.

LLM-as-a-judge: how it works and where it breaks

The LLM-as-a-judge technique was formalized in Zheng et al.'s "Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena" (NeurIPS 2023). The idea is straightforward: give a strong model a rubric (criteria, a scoring scale, examples) and ask it to grade another model's outputs. Two main modes: pairwise comparison (pick the better of two answers) and single-answer grading (score one answer directly).

Illustration of an AI acting as judge, weighing two answers on a balance scale
LLM-as-a-judge: a judge model weighs two outputs against the rubric you wrote.

The paper's central finding: GPT-4 as judge reached over 80% agreement with human preferences, matching the agreement level between human raters themselves. That result is why the technique exploded: evaluation that used to take weeks and thousands of dollars of human rater time could finish in hours.

But the same paper documents judge biases you must handle:

  • Position bias: judges favor whichever answer is presented first. Mitigation: randomize order, or show both orders and average.
  • Verbosity bias: longer answers score higher regardless of quality. Mitigation: instruct the judge to ignore length, or control answer length before grading.
  • Self-enhancement bias: judges rate outputs from their own model family higher. Mitigation: use a judge from a different model family than the one being evaluated, or use multiple judges.

A follow-up technique, G-Eval (EMNLP 2023), has the judge write its own evaluation steps (chain-of-thought) before scoring, then computes a weighted score from token probabilities, reaching a Spearman correlation of 0.514 with human judgments on summarization, far above BLEU/ROUGE.

The practical rule: LLM judges are great for routine regression checks and large-scale comparisons, but important decisions still need a human-validated sample: shipping a new model, or making quality claims to customers. The pattern most production teams use is hybrid: automated judges handle volume, humans handle the uncertain, novel, or high-impact cases.

Case study: a minimal eval harness for a chatbot

Theory without practice is useless. Here's a minimal evaluation harness for an FAQ chatbot you can run today, with no framework at all.

Step 1: Collect 30–50 real examples. Pull from production conversation logs, or write them from the most common incoming questions. Each example holds a prompt and the keywords a correct answer must contain.

Step 2: Write a deterministic scorer first. Before paying for an LLM judge, check what machines can check: are the answer's keywords present? Is the format right (valid JSON, say)?

Step 3: Run it and save every output. Each run stores the prompt, the raw answer, and the per-example score. Without these artifacts, you can't compare next week's run against today's.

Step 4: Add an LLM judge for what machines can't check. Tone, completeness, and instruction following get graded by a judge following a rubric.

Step 5: Set a threshold and fail the build when it drops. An evaluation that doesn't block releases is just a dashboard decoration.

import json
import statistics
from dataclasses import dataclass

@dataclass
class EvalCase:
    prompt: str
    expected_keywords: list[str]
    category: str = "general"

def call_llm(prompt: str) -> str:
    """Replace with a call to the model you are evaluating."""
    raise NotImplementedError("Plug in your model API here")

def keyword_score(answer: str, expected: list[str]) -> float:
    lowered = answer.lower()
    hits = sum(1 for kw in expected if kw.lower() in lowered)
    return hits / len(expected) if expected else 0.0

def run_eval(cases: list[EvalCase]) -> dict:
    scores: list[float] = []
    failures: list[dict] = []
    for case in cases:
        answer = call_llm(case.prompt)
        score = keyword_score(answer, case.expected_keywords)
        scores.append(score)
        if score < 1.0:
            failures.append({
                "prompt": case.prompt,
                "answer": answer,
                "score": score,
            })
    total = len(scores)
    return {
        "n": total,
        "mean": statistics.fmean(scores) if scores else 0.0,
        "pass_rate": sum(1 for s in scores if s == 1.0) / total if total else 0.0,
        "failures": failures,
    }

if __name__ == "__main__":
    cases = [
        EvalCase("What time does the store open on Mondays?", ["9:00", "monday"]),
        EvalCase("How much is shipping to Austin?", ["4.95", "austin"]),
        EvalCase("How do I return an item?", ["return", "14 days"]),
    ]
    report = run_eval(cases)
    summary = {k: v for k, v in report.items() if k != "failures"}
    print(json.dumps(summary, indent=2))
    for f in report["failures"]:
        print("FAILED:", f["prompt"], "->", f["answer"][:120])

This 60-line harness gives you three things a vibe check never will: a baseline number, a traceable failure list, and a format you can rerun any time. When you need more sophisticated metrics (faithfulness, G-Eval, multi-turn evaluation), frameworks like DeepEval ship dozens of ready-made metrics with a pytest-like API.

Common mistakes in LLM evaluation

Data contamination. Public benchmarks leak into training data: the model "remembers" the questions instead of being able to solve them. This is one reason MMLU saturated: some of the high scores are memory, not reasoning. For internal evaluation, never use questions that might be in the model's training set.

Goodhart's Law on leaderboards. Once a metric becomes a target, it stops being a good measure. Teams optimize benchmark-specific prompts, pick decoding settings that maximize score, or, in extreme cases, train directly on test data. Scores go up; real capability doesn't.

Too few samples. A 100-question benchmark has a wide margin of error: a 3–4% gap between models can be pure statistical noise. Before claiming "model B is 2% better," compute the confidence interval.

Unreported prompt sensitivity. How questions are formatted (option order, few-shot examples, system instructions) can shift scores by double digits. Serious benchmarks (MMLU-Pro among them) are designed to reduce this sensitivity. When comparing two models, use identical prompts and publish them.

A single number. No single metric captures "quality." 90% accuracy doesn't tell you whether the 10% of failures are harmless typos or dangerous hallucinations. Always include failure analysis: read the failing samples, group the patterns.

Best practices: which approach for which situation

  • Choosing a model for general work → start with the relevant public benchmarks (MMLU-Pro for knowledge, SWE-bench for coding), then test on your own data.
  • Daily prompt iteration → a small eval set (30–100 examples) + deterministic scorer + LLM judge; run on every change, in CI if possible.
  • Major release decisions → add human evaluation on the samples the automated stage flagged as failed or ambiguous.
  • RAG and agents → separate component metrics (retrieval vs generation; planning vs tool execution).
  • Always → store the dataset, prompts, and results of every run; record the model version and date.

And one principle that ties it all together: good evaluation starts from the question "what decision will this number drive?" If no decision changes regardless of the outcome, the evaluation doesn't need to run.

FAQ

How does LLM evaluation differ from regular software testing?

Regular software testing checks deterministic behavior against exact expectations. LLMs are probabilistic with an open answer space, so LLM evaluation uses statistical methods: aggregate scores across many examples rather than pass/fail per case. Both still need repeatable artifacts: stored datasets, prompts, and results.

How many examples are enough for an internal eval set?

For fast iteration, 30–50 good examples already give you a directional signal (getting better or worse). For release decisions, aim for hundreds of examples with balanced coverage of task categories. Representativeness matters more than count: examples should mirror the real input distribution, not just easy-to-write questions.

Can LLM-as-a-judge fully replace human raters?

No. LLM judges have systematic biases (position, verbosity, self-enhancement) and inherit blind spots from the model doing the judging. The original paper itself positions the technique as a scalable approximation of human preference, not a replacement. Best practice: automation for volume, humans for validation and critical cases.

Which benchmark is most relevant for a customer-service chatbot?

No public benchmark measures "customer service" directly. Use MT-Bench or AlpacaEval for general conversational ability as an initial comparison, but the final call must come from an eval set of your product's real conversations, with task-resolution metrics, not just fluency.

How do you detect benchmark contamination?

Three signals: scores far higher than the capability you see on real tasks, the model "remembering" specific questions when asked, and performance collapsing on paraphrased variants of the questions. Modern benchmarks like Humanity's Last Exam fight this by discarding questions models could already answer during curation. For internal evals, write your own questions from data that was never published.

Conclusion

LLM evaluation isn't a ritual of quoting leaderboard scores. It's the process of building trust in the numbers you report. Start with public benchmarks for orientation, but product decisions always come back to your own eval set: real examples, task-appropriate metrics, and repeatable artifacts. Add LLM-as-a-judge for scale, understand its biases, and keep humans for the judgments that truly matter.

The highest-leverage next step: this week, collect 30 examples from your product's logs and run the simple harness above. That first number, however crude, is worth more than ten demos that "look good."

Related articles on this blog: the prompt engineering guide (a good prompt is half of good evaluation), the complete RAG guide, the vector database comparison, and the MCP guide.

Keep reading

Related articles