Reliable LLM application evaluation starts with a representative golden dataset, explicit scoring rubrics, and regression tests that run whenever prompts, models, retrieval settings, or application code change. This guide provides a reusable workflow for measuring improvement without relying on a single score.
Overview
An LLM evaluation framework is the system you use to decide whether an AI feature is working well enough for its intended task. It should connect real user needs to measurable expectations: accuracy, relevance, groundedness, safety, structure, latency, and cost where those factors matter.
The central artifact is a golden dataset for LLMs. Each record represents a realistic input and includes the context available to the application, the expected behavior, and one or more ways to judge the output. The dataset is not necessarily large. It is valuable because it is representative, difficult enough to expose weaknesses, and stable enough to compare across versions.
A practical evaluation loop has five stages:
- Collect representative inputs, including known failures and important edge cases.
- Define what a good answer means for each task.
- Run the same cases against a baseline and a candidate version.
- Combine automated checks with human review where judgment is required.
- Set release gates and investigate meaningful regressions before deployment.
Evaluation should measure the complete system, not only the prompt. Changes to retrieval, chunking, tools, model parameters, output parsing, or fallback logic can alter results. For retrieval-augmented applications, pair this process with a documented RAG chunking and retrieval evaluation workflow.
Checklist by scenario
For a new LLM application
- Write the task definition in one sentence, such as “extract approved invoice fields” or “answer support questions using supplied documentation.”
- List unacceptable behaviors, including fabricated facts, unsupported recommendations, missing fields, unsafe disclosures, and invalid output formats.
- Collect examples from intended users, historical tickets, synthetic edge cases, and domain reviewers.
- Label each example by task type, difficulty, language, topic, and risk level.
- Split the examples into development, evaluation, and holdout sets. Keep the holdout set unseen during prompt iteration.
- Record the model, prompt version, retrieval configuration, tools, temperature or equivalent settings, and output schema for every run.
For prompt optimization
- Freeze a baseline before changing the instruction, examples, format, or model settings.
- Change one major variable at a time when diagnosing cause and effect.
- Test both average performance and individual failures. A higher overall score can hide a serious regression in a high-risk category.
- Include adversarial and ambiguous inputs rather than optimizing only for clean examples.
- Use structured output validation when downstream code expects JSON, classifications, or required fields. The structured output prompting guide covers implementation considerations.
- Compare prompt candidates using the same dataset, execution settings, and scoring rules.
For a RAG application
- Separate retrieval evaluation from answer evaluation.
- Check whether the correct source passages are retrieved before judging the generated response.
- Measure citation or evidence support when answers must be grounded in supplied documents.
- Add cases with missing, conflicting, outdated, and irrelevant information.
- Test whether the system declines or asks for clarification when the knowledge base does not support an answer.
For a model or provider migration
- Run the full regression suite before changing traffic.
- Compare output quality, schema validity, refusal behavior, latency, token usage, and error handling.
- Review cases that changed from pass to fail, not only the aggregate result.
- Test retries, timeouts, rate-limit handling, and fallback paths.
- Use the LLM API migration checklist alongside quality tests so operational changes are evaluated too.
For a release gate
Use a release decision that reflects risk rather than one universal threshold. A simple gate can require:
- No regression in critical safety, privacy, or schema-validity cases.
- Candidate performance equal to or better than the baseline on core task metrics.
- Any trade-off between quality, cost, and latency to be documented and approved.
- All newly observed production failures to be triaged and either fixed or accepted explicitly.
What to double-check
Choose the right evaluation method
| Method | Useful for | Limitations |
|---|---|---|
| Human review | Nuance, helpfulness, tone, safety, and domain correctness | Slower, more expensive, and potentially inconsistent without clear guidance |
| Rule-based checks | Required fields, exact labels, forbidden strings, citations, and valid JSON | Cannot reliably judge meaning or nuanced quality |
| Model-based judging | Semantic comparison, relevance, style, and scalable review | Can reproduce bias, miss subtle errors, or favor fluent but incorrect answers |
| Task-specific metrics | Classification accuracy, extraction overlap, retrieval recall, or ranking quality | Only useful when labels and metric definitions match the real objective |
Use several methods when the task warrants it. A model judge can prioritize examples for human review, while deterministic checks can catch failures that a judge overlooks. Do not treat a judge score as ground truth without calibrating it against reviewed examples.
Use a rubric that describes observable behavior
A reusable rubric should define each score in terms a reviewer can identify:
- 4 — Meets the requirement: correct, complete, supported by the available context, and in the required format.
- 3 — Minor issue: essentially useful, but with a small omission, imprecision, or stylistic problem.
- 2 — Major issue: partially useful, but missing an important requirement or requiring substantial correction.
- 1 — Fails: incorrect, unsupported, unsafe, unusable, or non-compliant with the requested format.
For sensitive tasks, add binary checks such as “contains unsupported claims: yes/no” or “exposes restricted information: yes/no.” Binary checks make release gates easier to enforce than a single blended score.
Use a consistent test-case template
{
"id": "support-014",
"category": "missing-information",
"input": "Can I return this item after the stated return period?",
"context": "Approved policy passages supplied to the application",
"expected_behavior": "State that the supplied policy does not establish an exception and ask for the purchase date or direct the user to an approved support path.",
"checks": ["grounded", "no invented exception", "helpful next step"],
"risk": "high"
}Store the expected behavior separately from a single “ideal answer” when multiple responses could be correct. This reduces overfitting and makes evaluation more useful for open-ended LLM app development.
Common mistakes
- Testing only easy examples. Clean, frequently repeated inputs may show whether the happy path works but reveal little about robustness. Add ambiguity, incomplete information, long inputs, multilingual cases, and malformed requests where relevant.
- Changing the dataset to improve the score. Dataset maintenance is necessary, but removing difficult cases without recording why creates a misleading trend. Version the dataset and preserve retired cases.
- Relying on one aggregate metric. Average scores can conceal failures in rare but consequential categories. Report results by segment, risk, and task type.
- Using model judges without calibration. Compare judge decisions with human-reviewed samples, inspect disagreements, and keep the judging prompt and model version in the evaluation record.
- Ignoring non-quality regressions. A response can be correct but too slow, too expensive, too long, or invalid for downstream software. Include operational checks in the same release review. See the cost and latency audit checklist for a broader review.
- Failing to test security behavior. Prompt injection and malicious instructions should be represented in the evaluation set when the application processes untrusted content. Use the prompt injection testing checklist to expand these cases.
- Confusing fluency with correctness. Clear prose is not evidence that an answer is true or grounded. Score factual support separately.
When to revisit
Revisit the evaluation suite before every material prompt, model, retrieval, tool, or application release. Also review it after a production incident, a seasonal planning cycle, a major product change, or a change in the documents and workflows the system handles. These events alter the distribution of inputs or the consequences of failure.
At least quarterly, review the benchmark assumptions:
- Are the examples still representative of real traffic?
- Have new languages, product areas, user groups, or risk categories appeared?
- Do the rubric and thresholds still reflect business and user priorities?
- Are any automated judges disagreeing regularly with expert reviewers?
- Have prompt, model, API, or retrieval changes made stored metadata incomplete?
After each review, record the dataset version, rubric changes, baseline, candidate results, unresolved failures, and release decision. Add anonymized production failures to the next dataset revision when permitted by your data-handling requirements.
Before your next release, run this short sequence: freeze the candidate configuration, execute the full golden dataset, compare it with the previous baseline, inspect regressions by risk category, verify quality and operational gates, and document the decision. That routine turns LLM regression testing from an occasional demonstration into a dependable part of production prompt engineering.