Evaluating an LLM application requires more than checking whether a few answers look convincing. This guide shows how to create a repeatable evaluation workflow using task-specific metrics, structured test cases, groundedness checks, refusal behavior, latency, cost, and human review. It also includes a reusable evaluation template for comparing prompts, models, retrieval settings, and application versions over time.
Overview
An LLM application is a system, not just a model. Its results may depend on the system prompt, user input, retrieved context, tools, output parser, model settings, fallback logic, and downstream business rules. A useful LLM evaluation therefore measures the complete workflow against representative tasks.
Start by defining what “working” means for your application. A support assistant may need to answer from an approved knowledge base, cite the relevant source, refuse unsupported questions, and respond within an acceptable time. A document extractor may need to return valid JSON with the correct fields. A coding assistant may need to produce compilable code without introducing a known security issue. These are different quality targets and should not be reduced to a single generic score.
A practical evaluation has four layers:
- Task quality: Does the output satisfy the user’s actual objective?
- Reliability and safety: Does the application follow constraints, handle uncertainty, and refuse inappropriate requests?
- Operational performance: Is the response fast and affordable enough for the intended workflow?
- Human judgment: Do qualified reviewers consider the output useful, accurate, and appropriately written?
Keep these dimensions separate initially. A model that is inexpensive but frequently invents unsupported answers should not appear equivalent to a slower model that is dependable for the same task.
For prompt design and test organization, see the prompt engineering workflow from requirements to tested production prompts. The LLM application release checklist can help connect evaluation results to deployment and rollback decisions.
How to estimate
Build an evaluation set before comparing model or prompt versions. Each row should represent one realistic interaction, including ordinary cases, difficult cases, ambiguous requests, boundary cases, and known historical failures. Avoid using only examples that make the application look good.
A reusable test-case template can use these fields:
case_id, category, user_input, context_or_documents, expected_behavior, reference_answer, required_fields, prohibited_behavior, severity, prompt_version, model_version, output, score, reviewer_notesThe expected behavior describes what a good system should do without forcing one exact wording. The reference answer is useful when factual content can be compared directly. The prohibited behavior records failures such as inventing a source, exposing private data, ignoring a required format, or answering when the correct response is to ask for clarification.
Choose metrics that match the task
- Accuracy or task success: Use exact-match or field-level checks for structured outputs. For open-ended tasks, use a rubric with explicit criteria.
- Groundedness: Check whether claims are supported by the supplied context or approved sources. This is especially important in RAG prompt engineering.
- Relevance: Measure whether the answer addresses the request directly rather than producing plausible but unnecessary text.
- Completeness: Check whether required points, fields, citations, or steps are present.
- Format validity: Test JSON parsing, schema compliance, SQL syntax, required labels, or other machine-readable constraints.
- Refusal and uncertainty behavior: Test whether the system declines unsupported or disallowed requests and clearly communicates uncertainty when evidence is insufficient.
- Latency: Record the time from request submission to usable response. Track the same stages consistently, such as retrieval, model generation, tool calls, and post-processing.
- Cost: Estimate input-token, output-token, embedding, retrieval, tool, and infrastructure costs using the pricing and usage assumptions relevant to your deployment.
For a simple aggregate view, calculate a pass rate as:
Pass rate = passed test cases ÷ evaluated test cases × 100
Do not rely on this number alone. Report pass rates by category and severity. A small number of critical failures may matter more than many successful routine cases. For human review, use a consistent scale, such as 1 to 5, and define each score. For example, a score of 5 might mean accurate, complete, grounded, and ready to use; a score of 3 might mean partially useful but requiring material correction.
Estimate cost and throughput
Use a transparent cost model rather than a single guessed figure:
Estimated monthly cost = requests × average cost per request + fixed service costs
For token-based model usage:
Average cost per request = (average input tokens × input rate) + (average output tokens × output rate) + tool and retrieval costs
Keep rates as editable inputs in your spreadsheet or evaluation script. This makes the comparison reusable when provider pricing, model selection, context length, or traffic changes. Also record p50 and p95 latency where possible, because an average can hide slow outliers that affect user experience.
Inputs and assumptions
An evaluation is only as useful as its assumptions. Record the following alongside every run:
- Dataset composition: Number of cases, task categories, languages, difficulty levels, and expected output types.
- Version identifiers: Model name, model configuration, system prompt version, retrieval configuration, tool definitions, parser version, and application commit.
- Generation settings: Temperature or equivalent controls, maximum output length, timeout, retry policy, and fallback behavior.
- Evaluation method: Deterministic rules, reference comparison, an evaluator model, human review, or a combination.
- Acceptance thresholds: Minimum overall quality, maximum critical-error rate, maximum latency, and maximum cost per successful task.
- Sampling assumptions: Whether the test set reflects real traffic and whether difficult cases are deliberately oversampled.
Evaluator models can help scale review, but they should not be treated as unquestionable judges. Validate their scoring against human-reviewed examples, provide a clear rubric, and inspect disagreements. For high-impact workflows, retain human review for critical cases and periodically audit automated judgments.
Separate development, validation, and monitoring data where practical. Reusing the same examples to tune a prompt and prove that it works can make results look better without improving general performance. Include a regression set containing failures that must not return after a change.
When comparing providers, preserve the same inputs, expected behavior, and acceptance criteria. Provider-specific prompt conventions may require adaptation, but document those changes. The AI provider migration checklist is useful when moving prompts and API calls between providers.
Worked examples
Example 1: Retrieval-based support assistant
Suppose an assistant is evaluated on 100 cases: 60 ordinary policy questions, 20 questions requiring multiple documents, 10 ambiguous questions, and 10 questions with no supporting answer. The evaluation records whether the answer is supported by retrieved context, whether the correct source is cited, whether the response answers the question, and whether unsupported cases receive an appropriate refusal or clarification request.
Instead of reporting only “82 out of 100 passed,” report results by category. For example, the application might pass most ordinary questions but fail several no-answer cases by inventing details. That pattern points to a grounding or refusal problem, not a general language-quality problem. The next experiment could compare a revised system prompt, a retrieval change, and a stricter answerability check while holding the test set constant.
Example 2: Structured extraction workflow
For an invoice extraction feature, each case can contain a document and a required JSON schema. Measure field accuracy, missing-field behavior, numeric normalization, schema validity, and latency. A response that contains the right values but invalid JSON is not fully successful if the next service cannot parse it.
Use separate scores for exact fields and business-critical fields. An incorrect invoice total may deserve a higher severity than a missing optional address line. Add malformed documents and incomplete documents to test whether the application distinguishes “not present” from “not extracted.”
Example 3: Comparing two prompt versions
Run both versions against the same frozen test set and calculate quality by category, critical failures, average and tail latency, estimated cost, and human-review score. A practical decision table might look like this:
| Measure | Prompt A | Prompt B | Decision note |
|---|---|---|---|
| Task pass rate | Record result | Record result | Compare by task category |
| Critical failures | Record count | Record count | Reject if threshold is exceeded |
| Groundedness | Record score | Record score | Inspect unsupported claims |
| Latency | Record p50/p95 | Record p50/p95 | Check product requirement |
| Cost per request | Use current input rates | Use current input rates | Recalculate when rates change |
Choose the version that meets the application’s quality and operational thresholds, not necessarily the one with the highest single score.
When to recalculate
Revisit your LLM evaluation whenever the system or its operating assumptions change. At minimum, rerun the relevant suite after changing the model, system prompt, few-shot examples, retrieval pipeline, chunking strategy, tool interface, output schema, safety logic, timeout, or retry policy. Also test after a major provider API release or a change in traffic mix.
Recalculate cost when model pricing inputs, average prompt length, output length, request volume, tool usage, or infrastructure costs change. Recalculate latency when context size, retrieval depth, model configuration, or cloud architecture changes. Do not silently replace old results: preserve the run date, versions, assumptions, and dataset so that trends remain interpretable.
Use a practical maintenance rhythm: run a small regression suite on every relevant code or prompt change, run the broader dataset before release, and review production failures on a regular schedule. Add representative failures to the test set only after understanding the failure and avoiding duplicate or overly narrow cases.
To put this into practice, create a spreadsheet or evaluation script with one row per test case, version every prompt and model configuration, define pass criteria before reviewing outputs, and store both automated scores and reviewer notes. Then link evaluation results to your release process and monitoring dashboard. For cloud readiness and operational controls, consult the AI API cloud deployment checklist. Treat the evaluation file as a living engineering artifact: update it when assumptions change, rerun it when the application changes, and use the results to decide whether to ship, revise, or roll back.