Large language models are only as useful as their outputs are reliable, and reliability cannot be assumed from a demo. A model that answers general knowledge questions well may fail on domain-specific reasoning, produce inconsistent formatting, or generate unsafe content under adversarial prompting. Evaluation is the discipline of measuring model behavior systematically, comparing candidate versions, and tracking performance over time. Without it, teams ship changes based on anecdotal impressions rather than evidence.
This article covers practical patterns for building LLM evaluation pipelines in production environments, moving from offline, dataset-driven testing to online monitoring, with worked hypothetical examples at each stage. All examples are illustrative and designed to be adapted to real systems, not to represent deployed production deployments.
Why Evaluation Matters
LLM behavior is probabilistic by nature. The same prompt can produce different outputs across runs, and small wording changes can shift results in unpredictable ways. Offline evaluation on a static dataset catches regressions before deployment, while online evaluation detects drift, adversarial attacks, and distribution shift in live traffic. Together they form a feedback loop: offline tests gate releases, online monitoring catches what tests miss, and findings from production feed back into the evaluation dataset.
Evaluation also serves as a communication layer between engineering, product, and safety teams. A well-defined metric makes it possible to agree on what "good" looks like, rather than debating individual examples endlessly.
Offline Evaluation: Dataset-Driven Testing
Offline evaluation runs the model against a fixed set of inputs with expected outputs or rubric-based scoring. The pipeline has three stages: dataset construction, model invocation, and scoring.
Dataset Construction
Start with a small, focused set of 50-200 examples that represent the most common and most important intents your system handles. Each example needs an input, an expected output or behavioral constraint, and an evaluation method. Do not attempt to cover every possible input upfront; coverage grows as you learn where the system fails.
Examples for a customer support bot might include:
- Order status inquiry with expected tracking number format
- Refund request above a dollar threshold requiring human handoff
- Billing question with expected payment method disclosure
- Prompt injection attempt expecting safe refusal
Store each case with metadata: intent category, expected difficulty, and whether it is a regression guardrail or an exploratory probe.
Scoring Methods
Choose a scoring method matched to the output type. Exact-match scoring works for structured outputs like JSON or categorical labels. LLM-as-judge scoring uses a second, more capable model to rate outputs on a rubric such as helpfulness, safety, and tone. Human scoring remains the gold standard but is slow and expensive; use it for a sample of cases and for calibrating automated scorers.
A common mistake is using a single overall score. Break scoring into dimensions: correctness, format compliance, safety, and latency. A response that is factually correct but leaks internal system instructions fails on safety even if it passes on correctness.
Worked Hypothetical Example
Imagine a fictional team running evaluation for a support agent that handles order tracking and refund requests. They build a dataset of 100 cases: 40 order status, 30 refund inquiries, 20 billing questions, and 10 adversarial attempts. After each prompt change, they run the full dataset and compare scores against a baseline. When a new prompt improves refund handling by 8 points but degrades order status accuracy by 2 points, the team can make an informed trade-off decision rather than guessing.
Online Evaluation: Monitoring Live Traffic
Offline evaluation cannot capture every real-world input. Online evaluation observes live interactions and flags anomalies for review. It complements offline testing by catching distribution shift, new attack patterns, and edge cases that never appeared in the dataset.
What to Log
Log every model invocation with its input, output, model version, prompt version, latency, token usage, and outcome. Do not log full conversation transcripts by default unless they are encrypted and access-controlled, because user messages often contain personal data. Instead, log derived signals: intent classification, tool calls made, success or failure flags, and user satisfaction ratings when available.
Success and Failure Signals
Define success at the task level, not just the generation level. A response can be fluent and grammatically correct while failing to resolve the user's request. Task completion rate—whether the user's actual need was met—is a stronger signal than token-level perplexity or fluency.
Failure signals include explicit user dissatisfaction (thumbs-down, rephrasing, escalation to human), repeated tool-call failures, and safety classifier triggers. Track these per intent and per model version so regressions are attributable to specific changes.
Drift Detection
Distribution drift occurs when live inputs differ from the offline evaluation dataset. Monitor embedding drift by comparing the distribution of user inputs over time against the baseline dataset. A gradual shift may indicate changing user behavior; a sudden shift may indicate a new integration, a viral use case, or an adversarial campaign.
Human-in-the-Loop Review
Automated scoring scales well but has blind spots. Human review should target low-confidence outputs, high-stakes actions, and a random sample of normal traffic for calibration. Reviewers need clear rubrics and should not be asked to judge "quality" in the abstract. Instead, ask specific questions: Does the answer address the user's question? Is the tone appropriate? Are any unsupported claims made?
Review findings should feed back into the offline dataset. When a reviewer catches a failure mode, add it as a regression case so the same failure cannot ship silently in a future release.
Evaluation as a Release Gate
Integrate evaluation into the deployment pipeline so that no prompt or model change reaches production without passing a minimum threshold. Define gate criteria per dimension: for example, correctness must stay above 90 percent, safety refusals must remain above 98 percent on adversarial cases, and format compliance must be 100 percent for structured outputs.
When a change fails the gate, roll back automatically and alert the team. When a change passes, deploy gradually—5 percent, 25 percent, 50 percent, 100 percent—while monitoring online signals in parallel. This layered approach catches both known regressions and unknown production issues.
Limitations
Evaluation reduces risk but does not eliminate it. Offline datasets are always incomplete, automated scorers have their own biases, and online monitoring detects problems after users have already experienced them. Adversarial inputs can evade classifiers, and model updates can change behavior in ways no test anticipated.
Treat evaluation as a continuous practice, not a one-time checkpoint. Revisit the dataset quarterly, recalibrate scorers against human judgments, and retire cases that no longer reflect real usage.
Conclusion
Reliable LLM applications are built on measurable evidence, not impressive demos. Offline evaluation gates releases, online evaluation catches what tests miss, and human review closes the loop. Start with a small dataset, define clear success criteria, integrate evaluation into your release pipeline, and expand coverage as you learn. Evaluation is never finished, but every iteration makes the system safer and more predictable.
For related guidance on model selection, see Evaluating and Selecting AI Models for Production Workloads. For patterns on testing AI workflows, see AI Workflow Testing Patterns for Production Systems.
Primary sources: