LLM Application Evaluation

LLM application evaluation turns product quality from anecdotes into measurement, regression tests, and production monitoring.

The Big Question

So far, the LLM Applications unit has focused on making systems more capable: prompting, retrieval, tools, memory, and agents. LLM application evaluation flips the question.

How do we know the application actually works?

Imagine two travel assistants. One feels smarter. One feels faster. Which is actually better? Or suppose you change one line of a prompt and the result looks better on three examples. Did the system improve, or did you get lucky?

LLM systems are probabilistic. Many outputs can be acceptable, and the output space is enormous. That means quality must be measured statistically rather than judged from a few demos.

Core Intuition

Traditional software often has a clear input-output test. If the function receives 2 + 2, the correct output is 4.

LLM applications are messier. For the travel assistant, a good response may vary in wording while still being correct. The system may call several tools, retrieve documents, ask for confirmation, and produce a final answer. We need to evaluate the whole behavior, not only one string.

The dangerous beginner habit is asking: Does it look good? That is anecdotal testing. Real evaluation asks: across representative cases, how often does it work, how does it fail, what does it cost, and did the latest change regress anything?

Interactive Demo

Evaluation dashboard

Application version

Test promptExpected behavior
Find the cheapest flight from Vancouver to Tokyo next Friday under $900.Select a flight under $900 or explain none exists.
Check whether I am free before booking.Call calendar before purchase and ask for approval.
Include arrival weather in the itinerary.Use weather tool and cite forecast time.
Release gate
Hold

A release should satisfy quality, groundedness, tool accuracy, latency, and cost requirements across a representative evaluation set.

Quality90%

judge score

Groundedness98%

supported by evidence

Tool accuracy86%

right tool and args

Pass rate91%

aggregate

Latency
4.20s
Cost
$0.037

Known trade-offs

  • slower
  • higher token cost
  • grounding improves, but latency and cost increase

Swap versions and toggles. Notice the trade-off: better grounding and quality can cost more latency and money, and robustness can drop under attacks.

Evaluation As Measurement

At the simplest level, an evaluation dataset is:

D={(xi,yi)}i=1ND=\{(x_i,y_i)\}_{i=1}^{N}

The application produces predictions:

y^i=A(xi)\hat{y}_i=A(x_i)

A metric scores the outputs:

M(D)=1Ni=1Ns(xi,yi,y^i)M(D)=\frac{1}{N}\sum_{i=1}^{N}s(x_i,y_i,\hat{y}_i)

The scoring function ss may be exact matching, a rubric score, a retrieval metric, a tool-call check, a human rating, or an LLM judge.

A/B Testing Intuition

In production, users may be randomly assigned to version A or version B. If version A succeeds on 72%72\% of tasks and version B succeeds on 78%78\%, the observed difference is:

Δ=p^Bp^A=0.780.72=0.06\Delta=\hat{p}_B-\hat{p}_A=0.78-0.72=0.06

A confidence interval asks whether that difference is likely real or could be noise. The practical lesson is not the formula. It is that online changes should be measured on enough traffic to distinguish improvement from luck.

What Should We Measure?

There is no single quality number for LLM applications. The right metrics depend on the product goal.

CorrectnessDid the answer or action satisfy the task?
FaithfulnessAre claims supported by retrieved evidence or tool results?
HelpfulnessIs the answer useful to the user?
SafetyDid the system avoid harmful or unauthorized behavior?
LatencyHow long did the user wait?
CostHow many tokens, API calls, and tool calls were used?
RobustnessDoes it work under typos, ambiguity, attacks, and long context?
User satisfactionDo users trust and prefer the experience?

Quality often lives on a Pareto front. A version can be more accurate but slower and more expensive. Another can be cheap and fast but less robust. Evaluation makes those trade-offs visible.

Offline And Online Evaluation

Offline evaluation runs a fixed dataset before deployment. It is repeatable, safe, and excellent for regression testing. Online evaluation observes real users in production. It captures reality, but it is noisier and requires careful experiment design.

Offline

Evaluation dataset, fixed cases, repeatable metrics, safe before deploy.

Online

Real users, A/B tests, monitoring, ratings, escalations, drift.

Strong teams use both. Offline tests prevent obvious regressions. Online monitoring catches real-world behavior that the test set missed.

Evaluation typePurposeExample
Unit testsDeterministic logicParser, validator, tool dispatcher
Offline benchmarksGeneral quality before deploymentRun a fixed dataset after each change
Golden datasetsApplication-specific correctnessExpected answers, tool calls, citations, retrieved chunks
Human evaluationUser quality and nuanced judgmentExperts rate helpfulness and safety
LLM judgeAutomated subjective scoringA model scores faithfulness, relevance, or style
Production monitoringReal-world behaviorLatency, failures, ratings, drift, escalations

Benchmarks And Golden Datasets

Public benchmarks such as MMLU, HumanEval, SWE-bench, GPQA, and SimpleQA are useful for general capability signals. But application-specific golden datasets are often more valuable.

For the travel assistant, a golden example might include:

{
  "question": "Find the cheapest Vancouver to Tokyo flight under $900.",
  "expected_answer": "A flight under $900 or a clear explanation that none exists.",
  "expected_tools": ["search_flights"],
  "forbidden_tools": ["book_flight"],
  "expected_citations": [],
  "safety_rule": "Do not book without confirmation."
}

Golden datasets should include ordinary cases, edge cases, ambiguous requests, adversarial prompts, long conversations, tool failures, retrieval failures, and known historical bugs.

LLM Application Metrics

Classification metrics like accuracy, precision, recall, F1, and ROC-AUC still matter when the task is classification. But LLM applications add new surfaces.

AreaMetrics
RetrievalPrecision@k, Recall@k, MRR, NDCG
RAG answerFaithfulness, citation correctness, answer relevance, completeness
Tool useTool selection accuracy, argument validity, execution success
AgentsTask completion, planning quality, iterations, recovery, tool efficiency
SafetyRefusal quality, policy violations, prompt-injection resistance
ProductUser rating, retention, conversion, escalation rate

Agent evaluation is especially trajectory-based. You should inspect task completion, planning quality, tool efficiency, number of iterations, recovery after failures, and whether the agent stopped safely.

Human Evaluation And LLM Judges

Some qualities are difficult to score with exact matching. Helpfulness, tone, relevance, and faithfulness often need judgment.

Human evaluation is high quality but expensive and slow. LLM-as-a-judge uses another model to score outputs according to a rubric. It is faster and cheaper, but can be biased, inconsistent, sensitive to wording, and overly impressed by confident prose.

Score this answer from 1 to 5 for faithfulness.
Evidence: ...
Answer: ...
Rubric:
1 = unsupported, 3 = partially supported, 5 = fully supported.

Pairwise evaluation is often easier than absolute scoring. Instead of asking whether an answer deserves a 4 or a 5, ask which of two answers is better and why.

Regression Testing

Every meaningful prompt, model, retrieval, tool, or orchestration change should rerun evaluation. This mirrors software engineering CI/CD.

Developer change
Run golden dataset
Compare metrics to baseline
Block deploy if quality drops or safety fails
Deploy
Monitor production

This is how teams avoid shipping a prompt that fixes one demo but breaks twenty hidden cases.

Production Monitoring And Error Analysis

Production monitoring tracks latency, failures, tool errors, retrieval failures, hallucination reports, user ratings, escalations, cost, traffic mix, and drift.

Error analysis classifies failures by component:

RetrieverRelevant evidence was not retrieved
PlannerThe agent chose a poor sequence of steps
ToolWrong tool, bad arguments, timeout, or permission failure
MemoryThe system forgot constraints or repeated work
PromptInstructions were ambiguous or contradictory
ModelThe model hallucinated or misread evidence
ApplicationThe wrapper truncated context, mishandled state, or exposed unsafe actions

This diagnostic mindset matters. A bad answer may be a retrieval bug, planner bug, tool bug, memory bug, prompt bug, model bug, or application bug. The fix depends on the source.

Implementation

Simple Evaluation Framework

def run_eval(dataset, assistant, scorer):
    results = []

    for example in dataset:
        output = assistant(example["input"])
        score = scorer(example, output)
        results.append({
            "id": example["id"],
            "output": output,
            "score": score,
            "passed": score >= example.get("threshold", 0.8),
        })

    pass_rate = sum(row["passed"] for row in results) / len(results)
    average_score = sum(row["score"] for row in results) / len(results)

    return {
        "pass_rate": pass_rate,
        "average_score": average_score,
        "results": results,
    }

Regression Gate

baseline = load_metrics("main_branch_eval.json")
candidate = run_eval(dataset, assistant, scorer)

if candidate["pass_rate"] < baseline["pass_rate"] - 0.02:
    raise RuntimeError("Regression: pass rate dropped too much")

if candidate["average_latency_ms"] > 4000:
    raise RuntimeError("Regression: latency budget exceeded")

save_report(candidate)

Real systems add slice metrics, judge explanations, sampled traces, dashboard links, and owner routing for failures.

Interview Discussion

Why is LLM application evaluation different from traditional testing?

Many outputs can be acceptable, quality is multi-dimensional, and the system may involve retrieval, tools, agents, latency, and cost.

What is a golden dataset?

An application-specific test set with expected answers, tool calls, citations, retrieved documents, or behavior requirements.

Why evaluate retrieval separately from generation?

If the right evidence never reaches the prompt, the generator cannot use it.

What are the risks of LLM-as-a-judge?

Judge models can be biased, inconsistent, sensitive to rubrics, and misaligned with human preferences.

Why is regression testing important?

It prevents prompt, model, tool, or retrieval changes from improving a few demos while breaking many hidden cases.

Active Recall

1. Why is anecdotal testing not enough for LLM applications?

2. What is the difference between model evaluation and application evaluation?

3. What belongs in a golden dataset for a travel assistant?

4. When would you use human evaluation instead of exact matching?

5. What are precision@k and recall@k used for?

6. Why do agents need trajectory-level evaluation?

7. What can go wrong with LLM-as-a-judge?

8. Why should every prompt change rerun the evaluation suite?

Common Mistakes

  • Cherry-picked demos. A few impressive examples do not prove the system works.
  • Small datasets. Tiny eval sets are noisy and miss edge cases.
  • Judge bias. LLM judges can prefer verbose, confident, or stylistically familiar answers.
  • Data leakage. If examples appear in training, tuning, or prompt examples, evaluation becomes inflated.
  • Metric gaming. Optimizing one metric can degrade real user value.
  • Confirmation bias. Developers often notice examples that support the change they wanted to make.

Connection To Building Reliable AI Systems

Evaluation is not something you do after building an AI application. It is part of the application itself. Every meaningful change should be measured, not guessed.

The next step is product design: how to build AI systems that users trust, enjoy using, and can rely on under real-world constraints of latency, cost, safety, observability, and deployment.