0%
LLM Inference and Serving: GPUs, Batching, and Cost
How Inference Works
Hardware and Memory
Making Inference Fast
Evaluations in Production
Every serving decision in this course, from quantization and speculative decoding to routing, adapters and caching, trades something for cost or speed. Evaluation is how you know whether the trade was worth it. Benchmarks published with a model say little about how it performs on your users, your prompts and your data. This lesson covers how to evaluate LLM systems in production: building evaluation sets from real traffic, using models as judges, running online experiments, and turning evaluation into a routine that gates every change.
Benchmarks versus your workload
Public benchmarks measure general abilities on fixed question sets: knowledge, reasoning, coding, math. They are useful for shortlisting models, but they rarely match a production workload. Your prompts have a particular system prompt, your inputs have a particular distribution of lengths, languages and topics, and your definition of a good answer includes format, tone, policy and factual grounding in your own documents. A model that scores a few points higher on a public benchmark may do worse on your task, and a cheaper model may match a larger one on a narrow workload. The only reliable signal comes from evaluating on data that looks like your traffic.
Every serving change is a model change
It is tempting to think only a new model needs evaluation. In practice, many infrastructure changes alter outputs. Quantizing weights to eight or four bits can shift answers on rare cases. Changing the engine version can change numerical details and sampling behavior. Speculative decoding should be lossless in theory, but implementations have bugs. Routing traffic to a smaller model, adding a semantic cache, trimming conversation history or switching tokenizer settings all change what users see. Treating each of these as a change that needs evaluation, with the same rigor as a model upgrade, prevents silent quality regressions that would otherwise surface weeks later as user complaints.
What makes LLM evaluation hard
Outputs are free form text, so there is rarely a single correct answer to compare against. Quality has several dimensions at once: correctness, completeness, groundedness in sources, format, tone, safety and length. Outputs vary between runs when sampling is used. Inputs drift over time as users and products change. And human judgment, the ultimate reference, is slow, expensive and inconsistent between raters. A production evaluation system has to handle all of this with a mix of automated checks, model based judges, human review and live metrics, each covering what the others miss.
Offline and online evaluation
Offline evaluation runs a candidate system on a fixed dataset before release and scores the outputs. It is cheap, repeatable and safe, since no user sees the candidate, and it is the basis for regression testing. Online evaluation measures the system on live traffic, through experiments and production metrics such as user feedback, task completion and escalation rates. It captures real behavior but is slower, noisier and exposes users to the candidate. Good programs use offline evaluation as a gate to filter out bad changes quickly and online evaluation to confirm that changes that pass the gate actually help.
Quality, cost and latency together
Evaluation in serving is never about quality alone. A change that improves quality by one point but doubles cost or latency may be a bad trade, and a change that loses half a point while halving cost may be a great one. Production evaluation should therefore report quality alongside cost per request, time to first token, time per output token and error rates, so decisions are made on the full picture. Many teams define an explicit tradeoff, such as the maximum acceptable quality drop for a given cost saving, so that decisions are consistent rather than argued case by case.
The cost of not evaluating
Without evaluation, teams make changes by intuition and spot checks. A few hand picked examples look fine, the change ships, and a regression on a minority of inputs goes unnoticed until it shows up in churn or support tickets. Teams also become afraid to change anything, leaving cost savings unclaimed because no one can prove a cheaper configuration is safe. A solid evaluation program pays for itself by making it safe to move fast: when every change is measured, cheaper models, aggressive quantization and new caching layers can be adopted with confidence.
Quality has many dimensions
It helps to name the dimensions explicitly. Correctness asks whether the facts and conclusions are right. Completeness asks whether the answer covers everything the user needed. Groundedness asks whether claims are supported by the provided sources rather than invented. Instruction following asks whether the answer respects the format, length and constraints in the prompt. Safety and policy ask whether the answer stays within what the product allows. Tone asks whether it sounds right for the brand and the situation. A single overall score blends these together and hides which one moved. Tracking them separately tells you, for example, that a quantized model kept correctness but started ignoring length limits, which points straight to a fix.
Evaluating the system, not just the model
A production answer is produced by a pipeline: a router, a retriever, a prompt template, a model, post processing, maybe a cache. A failure can come from any stage. The retriever may return the wrong document, the template may drop an instruction, the model may misread a correct document, or a cache may return an answer meant for a different question. Evaluating only final answers tells you that something broke but not where. Component level evaluation, such as retrieval recall on a labeled set of question and document pairs, router accuracy against labeled difficulty and cache false hit rate, localizes failures and lets each component be improved independently. End to end evaluation then confirms that the pieces work together.
Who decides what good means
Evaluation encodes product decisions. Whether a short answer or a thorough one is better, whether the assistant should ask a clarifying question or guess, whether it should refuse borderline requests or help cautiously, are choices for product owners and domain experts, not for engineers tuning a judge prompt. Writing these choices down as rubrics and examples makes them explicit and reviewable. When the evaluation suite disagrees with what stakeholders believe is good, the right fix is usually to update the rubric after discussion, not to argue about individual scores.
Evaluation as a shared language
A well run evaluation program gives the team a shared language for quality. Instead of debating whether a new configuration feels worse, people look at slice scores, confidence intervals and examples of disagreements. Product, engineering and research can agree on gates in advance, so decisions on release day are mechanical. This shared language also helps when talking with leadership about cost, because savings can be presented together with measured quality impact rather than as an unquantified risk.
A worked example
Suppose a team wants to move from sixteen bit weights to four bit quantization to fit twice the batch size on each GPU. Spot checks look fine. The evaluation suite, run per slice, shows overall correctness down only half a point, but the slice of long legal documents drops six points and the JSON format slice starts failing one request in fifty. With these numbers the team keeps sixteen bits for the legal feature, adds a format repair step, and ships quantization everywhere else, capturing most of the saving without the regressions. Without the suite, they would either have shipped the regressions or abandoned the saving.
Every serving optimization trades something away. Without an evaluation suite on your own traffic, you cannot tell a free saving from a hidden regression.