Skip to main content

Inference

Inference is using a trained model to make predictions on new inputs. It is the cheap, repeated phase where AI actually delivers value, and where production engineering lives or dies.

Beginner5 min readv1.0Updated Jul 2, 2026
AI-assisted content β€” reviewed by the author, but verify important details independently

Visual SummaryClick to explore

Learning Objectives

  • Define inference and distinguish it from training.
  • Trace an input through a deployed model to a prediction.
  • Explain why inference cost and latency dominate production AI.
  • Compare where inference runs: cloud, edge, on-device.
  • Read the key serving metrics: latency, throughput, cost per request.

Why This Matters

Training happens once in a lab; inference happens billions of times a day in your pocket. Every chatbot reply, face unlock, and fraud check is an inference. For any AI product, inference is where the costs accumulate, the latency is felt, and the user experience is won or lost. When engineers talk about "serving," "tokens per second," or "GPU bills," they are talking about this lesson.

Everyday Analogy

Medical school versus seeing patients. Training a doctor takes a decade and a fortune, and it's done once. Then the trained doctor diagnoses patient after patient, each visit taking minutes and costing a consultation fee. Inference is the consultation: fast, repeatable, priced per visit, and only possible because of the long training that came before. No learning happens during the visit; the doctor applies what they already know.

Training vs Inference: The Two Lives of a Model

Training Inference
Happens Once (or occasionally) Billions of times
Direction Weights are written Weights are only read
Compute Thousands of GPUs, weeks One GPU/chip, milliseconds
Cost Millions per frontier run Fractions of a cent per request
Analogy Medical school The consultation

One asymmetry defines the industry: because inference just reads frozen weights, it parallelizes beautifully, runs on modest hardware, and can be priced per use. The entire AI API economy (AI-059's token pricing) is inference economics.

What Happens During One Inference

Your phone camera frames a cat; the photo app labels it. In ~20 milliseconds:

  1. Preprocess. The photo is resized and converted to a grid of numbers.
  2. Forward pass. The numbers flow through the network's layers β€” multiply by weights, add, squash, layer after layer (the arithmetic from AI-004), with no weight changes.
  3. Output. The final layer emits probabilities: cat 0.94, dog 0.04, other 0.02.
  4. Postprocess. The app takes the top label and tags your photo.

For an LLM, the same forward pass produces probabilities over the next token, then runs again for the next token, and again, which is why long responses stream word by word and why output tokens cost more than input (AI-059).

The Three Numbers That Rule Serving

Production inference is managed by three metrics:

  • Latency: how long one request takes. Users feel anything over ~200ms in interactive apps; LLM chat lives at 1–10s. Techniques: smaller models, quantization (AI-065), caching, streaming.
  • Throughput: requests served per second per machine. Batching many requests through the GPU together multiplies it.
  • Cost per request: GPU-seconds burned per prediction. At a million requests a day, shaving 30% off inference cost is real money (AI-039 and AI-054 go deep).

These three trade against each other: bigger batches raise throughput but add latency; smaller models cut cost but may cut quality. Serving engineering is choosing your point on that triangle.

Where Inference Runs

Location Examples Why
Cloud GPU ChatGPT, Claude API Model too big for anything else; centralized scaling
Edge server Factory defect detection Low latency to local machines, data stays on-site
On-device Face unlock, keyboard prediction Zero network, total privacy, works offline

The push toward on-device (Apple Intelligence, phone-scale models) is powered by the compression techniques of AI-065: distill and quantize until the model fits in your pocket.

Real-World Showcase

  • OpenAI, Anthropic, and Google each serve billions of LLM inferences daily. Inference fleets, not training runs, are their biggest ongoing compute cost.
  • Visa runs fraud inference on every transaction with a latency budget of milliseconds; the model must answer before the payment terminal times out.
  • vLLM, an open-source serving engine, can triple LLM throughput purely by scheduling and batching smarter, on the same model and same GPU, just better inference engineering (AI-066).

Try It Yourself

  1. Feel the latency spectrum: unlock your phone with your face (~50ms, on-device), then ask a chatbot a question and watch tokens stream (1–10s, cloud LLM). Both are inference; hardware, model size, and distance explain the difference.
  2. Estimate a serving bill: a support bot uses 4,400 input + 400 output tokens per conversation (the AI-059 worked example). At $3/M input and $15/M output, verify one conversation β‰ˆ $0.019, then scale to your imagined traffic.
  3. Find the batch effect: ask a chatbot the same question at a quiet time vs a busy time and notice latency variance. You are feeling the throughput/latency trade-off of shared serving infrastructure.

Common Mistakes

  • Confusing inference with learning: the model is frozen, and your chat does not train it (context β‰  learning, see AI-061).
  • Ignoring inference cost while obsessing over training cost. At product scale, serving dominates the bill.
  • Benchmarking quality but not latency: a brilliant model that answers in 30 seconds loses to a good one that answers in 2.
  • Assuming inference needs the same hardware as training, when quantized models serve on far cheaper chips (AI-065).
  • Forgetting the pipeline. Production inference includes pre/postprocessing, safety filters, and retries, not just the model call (AI-021, AI-030).

Key Takeaways

  • Inference = read-only forward pass through frozen weights; training writes, inference reads.
  • It is the phase users experience and businesses pay for, request by request.
  • Latency, throughput, and cost per request are the three ruling metrics, and they trade off.
  • Inference runs everywhere from cloud GPUs to your phone; compression moves it down the stack.
  • LLM streaming, token pricing, and GPU bills are all inference phenomena.

Glossary

Inference
Using a trained model to make predictions on new inputs: the read-only phase where weights are only read, never written. Training happens once in a lab; inference happens billions of times a day in your pocket.
Forward Pass
One trip of input numbers through the network's layers (multiply by weights, add, squash) with no weight changes. For an LLM, each forward pass produces the next token's probabilities, which is why long responses stream word by word.
Latency
How long one request takes; users feel anything over ~200ms in interactive apps, while LLM chat lives at 1–10 seconds. Reduced with smaller models, quantization, caching, and streaming. (see AI-065)
Throughput
Requests served per second per machine, multiplied by batching many requests through the GPU together. It trades directly against latency: bigger batches serve more users but each waits longer.
Cost per Request
The GPU-seconds burned per prediction, the third ruling metric of serving. At a million requests a day, shaving 30% off inference cost is real money. (see AI-059)
Batching
Running many requests through the GPU simultaneously to raise throughput, at the price of added per-request latency. Serving engineering is choosing your point on the latency/throughput/cost triangle.
On-Device Inference
Running the model on the user's hardware (face unlock, keyboard prediction) for zero network dependency, total privacy, and offline operation. Compression techniques like distillation and quantization make models fit. (see AI-065)
Serving
The production engineering discipline of running inference at scale, including preprocessing, safety filters, retries, and scheduling engines like vLLM that can triple throughput on the same hardware. (see AI-021)

References

Diagram

Loading diagram…

Knowledge Check

8 questions