How to Evaluate LLM Apps: Metrics, Test Sets, and a Repeatable Prompt Testing Workflow
LLM evaluationprompt testingAI qualitymodel benchmarking

How to Evaluate LLM Apps: Metrics, Test Sets, and a Repeatable Prompt Testing Workflow

PPromptCraft Labs Editorial Team
2026-11-27
7 min read

A practical workflow for evaluating LLM apps with test sets, quality metrics, cost estimates, human review, and regression checks.

Reliable LLM applications are measured, not guessed. This guide presents a repeatable prompt testing workflow for building representative test sets, selecting useful LLM evaluation metrics, estimating quality and cost, grading outputs, and catching regressions before they reach production.

Overview

Changing a system prompt, model, retrieval strategy, or output schema can improve one example while quietly damaging another. A useful evaluation process makes those trade-offs visible. Instead of asking whether an output “looks better,” define what good means, test the same cases before and after a change, and record the result alongside latency, cost, and failure information.

The goal is not to produce one universal score. LLM applications perform several jobs at once: they may need to follow instructions, use the right source material, return valid structured output, avoid unsupported claims, and respond within an acceptable time and budget. A practical evaluation combines several signals and gives each one a clear pass condition.

This approach applies to chat assistants, retrieval-augmented generation (RAG) systems, text summarizers, keyword extraction tools, classification workflows, and tool-calling applications. For systems that depend on strict machine-readable responses, pair evaluation with schema validation. The guide to structured LLM output and JSON schema validation covers the implementation side.

How to estimate

Start by comparing a baseline version with a candidate version. Keep the test inputs, evaluation rules, and sampling conditions as consistent as possible. A simple comparison can be expressed as:

Improvement = candidate score − baseline score

For a weighted evaluation, calculate a composite result only after reviewing the individual dimensions:

Overall score = (instruction score × weight) + (grounding score × weight) + (format score × weight) + (safety score × weight)

Weights should reflect the application’s risk. For example, a compliance workflow may give factual support and refusal behavior more importance than writing style. A developer utility that returns JSON may treat format validity as a release-blocking requirement rather than an averaged score.

Track cost separately rather than hiding it inside a quality score. A basic request-level estimate is:

Estimated cost = (input tokens ÷ 1,000,000 × input price) + (output tokens ÷ 1,000,000 × output price)

Use the current provider pricing and your measured token counts when applying this formula. Prices, model names, and billing rules can change, so store the pricing date and model identifier with every estimate. For a fuller usage workflow, see LLM token counting and cost estimation.

For quality, begin with a small, carefully reviewed test set. Expand it when you discover a new failure mode. A test set should include ordinary requests, ambiguous requests, difficult edge cases, and known historical failures. Random examples alone are usually insufficient because rare but important errors may disappear in the average.

LLM evaluation metrics reference

MetricWhat it measuresHow to evaluate it
Task successWhether the output completes the requested jobUse a binary pass/fail rule or a task-specific rubric
Instruction adherenceWhether required constraints and priorities were followedCheck required inclusions, exclusions, tone, length, and ordering
GroundednessWhether claims are supported by supplied context or approved sourcesMark unsupported, contradicted, or unverifiable claims
RelevanceWhether the response addresses the input without unnecessary contentUse a defined rating scale with examples for each level
Format validityWhether output can be parsed and consumed downstreamRun schema, type, field, and constraint validation
Safety or policy complianceWhether the application handles disallowed or sensitive requests correctlyTest expected refusals, safe alternatives, and data-handling rules
LatencyTime from request to usable responseRecord end-to-end timing under representative conditions
CostUsage expense per request or workflowCombine measured token usage with current pricing inputs

Automated graders can help with scale, but they should not be treated as unquestionable ground truth. Use exact checks for deterministic properties such as valid JSON, required fields, or prohibited strings. Use rubric-based model grading for softer properties, then periodically compare those grades with human judgments. Human review remains especially valuable for high-impact decisions, subtle factual errors, and new failure patterns.

Inputs and assumptions

Before running a prompt testing framework, document the inputs that can affect the result. At minimum, record:

  • Application version: prompt revision, code commit, retrieval configuration, and output schema.
  • Model configuration: model identifier, parameters, tool definitions, and any response limits.
  • Test case: user input, system instructions, context documents, expected behavior, and risk category.
  • Evaluation rules: pass conditions, rating scale, grader instructions, and escalation criteria.
  • Operational measurements: input tokens, output tokens, latency, retries, errors, and estimated cost.

Keep expected behavior specific. “Helpful answer” is difficult to score consistently. “Names the two supplied causes, cites only the provided context, and returns three JSON fields” is testable. If a response can have multiple valid answers, describe the acceptable range rather than writing one rigid reference answer.

Separate test-set creation from prompt editing. If you add only examples that favor the new prompt, the evaluation becomes biased. Maintain a stable core set for release comparisons and a changing challenge set for newly discovered issues. Tag cases by intent, language, difficulty, source type, and failure mode so that a single aggregate score does not hide weak areas.

For RAG applications, evaluate retrieval and generation separately where possible. A correct answer cannot be expected when the relevant document was never retrieved. For tool-calling workflows, validate both the selected tool and its arguments before evaluating the final response; the tool-calling guide provides related design patterns.

Reusable LLM test-case template

{
  "case_id": "support-001",
  "category": "normal | edge | adversarial | regression",
  "input": "User request goes here",
  "context": ["Approved source material, if applicable"],
  "expected_behavior": [
    "Required behavior 1",
    "Required behavior 2"
  ],
  "must_not": ["Unsupported claim", "Missing required field"],
  "checks": {
    "task_success": "pass/fail",
    "groundedness": "0-2",
    "format_valid": true
  },
  "risk": "low | medium | high"
}

Worked examples

Example 1: Summarization prompt. Suppose a baseline prompt is compared with a revised prompt across 40 fixed documents. The evaluation records task success, unsupported claims, required length, format validity, latency, and token usage. The revised prompt is preferable only if its gains matter to the product. For instance, fewer unsupported claims may justify a small increase in output length, while a slight style improvement may not justify a substantial cost increase. Review the individual document results rather than relying only on the average.

Example 2: Structured extraction. A keyword extraction workflow should test documents with clear terms, repeated terms, unusual punctuation, empty text, multiple languages, and domain-specific vocabulary. The first gate is parseability: did the response contain valid JSON with the required array and field types? The next gates can measure whether expected terms were retained, irrelevant terms were excluded, and ordering rules were followed. A text-processing workflow can use a keyword extraction evaluation pattern similar to the one described in keyword extraction methods and evaluation.

Example 3: Cost comparison. To compare two model configurations, run the same cases and calculate total input tokens, total output tokens, total latency, and total estimated cost for each. Divide each total by the number of completed cases to obtain per-case averages. Report the range as well as the average: long documents, retries, or unusually verbose responses may make the average misleading. If a workflow includes several model calls, calculate the cost per complete workflow, not just per individual call.

When automated and human grades disagree, investigate the disagreement instead of immediately changing the prompt. The grader may have missed context, the rubric may be ambiguous, or the human reviewer may be applying an unstated preference. These disagreements are useful evidence for improving the evaluation itself.

When to recalculate

Re-run the relevant evaluation whenever a prompt, model, retrieval index, context-window strategy, tool schema, parser, safety rule, or response parameter changes. Also revisit the test set after a production incident, a new user segment, a change in document types, or a noticeable shift in latency, token usage, or error rates.

Recalculate cost estimates whenever provider pricing inputs, model selection, token limits, traffic assumptions, or retry behavior changes. Do not overwrite old results. Keep dated evaluation records so the team can distinguish a genuine quality improvement from a change in test composition or pricing assumptions.

Release checklist

  • Run the candidate and baseline against the same stable test set.
  • Review pass rates by category, risk, language, and failure mode.
  • Check hard gates such as schema validity, required fields, and safety handling.
  • Inspect representative failures manually, including the worst regressions.
  • Compare token usage, latency, retries, and estimated cost per completed workflow.
  • Add newly discovered failures to the challenge set and schedule a regression test.
  • Record the prompt, model, evaluation version, pricing inputs, and decision.

A lightweight, repeatable evaluation is more valuable than an elaborate benchmark that nobody maintains. Start with the failures that matter most to users, make the pass criteria explicit, and rerun the checks whenever the underlying inputs change. That practice turns prompt engineering from subjective tweaking into an observable part of AI application development.

Related Topics

#LLM evaluation#prompt testing#AI quality#model benchmarking
P

PromptCraft Labs Editorial Team

AI Development and Prompt Engineering Editors

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.