A Model learns during training. After training, we can give it new Input, such as a question, photograph, or transaction.
The model processes that input and produces a result, such as a Prediction.
The process of using a trained model on new input is called inference.
The simple definition
Inference is the process of actually running a trained model on new data to get a result. If Training is the studying phase — repeated, slow, done once (or occasionally) ahead of time — inference is the exam phase: fast, done constantly, live, every single time someone actually uses the model.
Every time you send a message to a chatbot, every time a photo app tags a face, every time a fraud system checks a transaction in real time — that’s inference happening. It’s the part of the whole ML pipeline that’s actually visible and felt by an end user; training, by contrast, happens invisibly, ahead of time, behind the scenes.
Using a trained model
Training is like studying many worked examples before an exam. Inference is like receiving a new question and using what was learned to produce an answer.
Training: examples + labels → adjust model parameters
Inference: new input + fixed parameters → output
The analogy has an important limit: the model does not consciously remember a lesson or reason like a student. It executes mathematical calculations using learned parameters.
One inference request from start to finish
Suppose a user asks a language model, “Why is the sky blue?”
flowchart LR
A[Receive request] --> B[Validate and prepare input]
B --> C[Convert text into tokens]
C --> D[Run model calculations]
D --> E[Select output tokens]
E --> F[Validate and display response]
For generated text, inference repeats model computation many times because each new token becomes part of the input used to generate the next token.
prompt → token 1 → token 2 → token 3 → ... → completed response
Offline, online, batch, and streaming inference
- Online inference: Produces a result for a live request, such as a chatbot reply.
- Batch inference: Processes many stored items together, such as nightly product recommendations.
- Streaming output: Sends partial results while generation continues.
- Edge inference: Runs a model on a phone, vehicle, camera, or local device.
The best choice depends on freshness, privacy, network access, hardware, response-time requirements, and cost.
Why inference costs money and time
Each request requires compute, memory, model loading, input processing, and output handling. Large generative models repeat expensive calculations for every generated token.
Production teams improve inference by:
- Batching compatible requests
- Caching safe, reusable results
- Using smaller or specialized models
- Quantizing model weights
- Limiting unnecessary input and output tokens
- Streaming results to improve perceived responsiveness
- Running models nearer to users when appropriate
Every optimization has trade-offs. A smaller or heavily quantized model may be cheaper but less capable for some tasks.
Inference code path
# Training happened earlier.
new_house = [[1200]]
predicted_price = model.predict(new_house)
print(predicted_price[0])
predict(...) performs inference. It uses the model’s already learned parameters and does not normally retrain the model from this new house.
Production inference safeguards
- Validate input types, sizes, and permissions.
- Set timeouts and resource limits.
- Keep model and prompt versions traceable.
- Validate structured output before downstream use.
- Monitor latency, cost, errors, quality, and drift.
- Require approval for high-impact actions.
- Provide fallbacks when the model or provider is unavailable.
Why this distinction deserves its own article
Training and inference have almost opposite engineering demands, and conflating them is a common beginner mistake. Training happens rarely, can take days or weeks, and is allowed to be slow and expensive because it’s a one-time (or occasional) investment. Inference happens constantly — potentially millions of times a day for a popular AI product — and needs to be fast and cheap, because every single one of those requests has a real person waiting on the other end, and a real cost attached to running it.
flowchart LR
A[Training: happens once/occasionally, slow, expensive] --> B[Trained Model saved]
B --> C[Inference: happens constantly, fast, must be cheap]
C --> D[Prediction returned to user]
ANALOGY vs. TECHNICAL REALITY
Analogy: Think of a chef (the model) who spent years training in culinary school (training). Once qualified, that same chef now works a busy dinner service (inference) — cooking dish after dish, quickly, for a constant stream of customers, using the skill they built up ahead of time rather than relearning to cook from scratch with every order.
Where this breaks down: A chef adapts on the fly, occasionally trying something new mid-shift. A model, during inference, is completely fixed — its learned parameters don’t change at all while it’s answering your question. Whatever it learned during training is exactly what it’s working with, every single time, until it’s retrained again later.
What’s actually happening technically during inference
For a large language model, inference happens in two distinct stages, worth knowing because they behave very differently from an engineering standpoint:
- Prefill — the model processes your entire input (your prompt, plus any earlier conversation) all at once, in parallel, to build up its internal understanding of the context. This stage is computationally intensive but fast, because it can be heavily parallelized.
- Decode — the model then generates its response one token at a time, as described in the Prediction article — each new token depends on everything generated so far, so this stage can’t be parallelized the same way, and tends to be the slower, more resource-hungry part of the process for longer responses.
Engineers building AI products track specific metrics for this: time to first token (how long before the response starts appearing) and tokens per second (how fast the rest streams in) — the two numbers that mostly determine how responsive an AI product actually feels to use.
Where and why it’s actually expensive, and how that’s changing
Serving inference at scale is a genuinely hard, expensive engineering problem — this is why AI companies run massive fleets of GPUs (or, for Google’s models, custom TPU chips) dedicated purely to answering live requests, entirely separate from the hardware used for training. Unofficial technical reporting on GPT-4 has suggested OpenAI runs inference for it across roughly 128 GPUs working together per model instance, splitting the enormous model across that hardware — though, as with training figures, treat this as an unconfirmed industry estimate rather than an official number.
What’s genuinely well-documented is the trend: inference costs have fallen dramatically over the past few years. Industry analysis has tracked the cost of achieving a fixed quality benchmark falling from around 0.06 per million tokens by late 2024 — a thousand-fold drop in three years, driven by better GPU hardware, smaller and more efficient models reaching the same capability, and heavy competition among providers.
This is a big part of why AI products that once felt expensive to run now offer far more usage for far less money, and it’s a trend that directly shapes how affordable it is for a company to actually put a trained model into a real product.
A concrete example, closing the loop
Return to the hospital readmission model from earlier articles. Training happened once, offline, on the hospital’s historical records. Inference is what happens every single time a new patient is admitted: their current features — age, diagnosis, length of stay so far — are fed into the already-trained model, which returns a fresh risk prediction in under a second, ready for a nurse or doctor to actually act on. The model’s underlying parameters don’t change during this — they were frozen the moment training finished; only the input changes, request after request.
Key terms
- Inference: Running a trained model to produce output for new input.
- Latency: Time required to return a result.
- Throughput: Amount of work completed during a period.
- Batching: Processing multiple requests together.
- Serving: Operating infrastructure that makes a model available for inference.
- Streaming: Returning output in parts as it is generated.
Check your understanding
Does inference normally change the model’s learned weights? No. It uses them to compute output.
Is prediction identical to inference? A prediction is the result; inference is the process used to obtain it.
Common misconception
A frequent mix-up: assuming a model “learns” from each individual interaction during inference, the way a human might learn from experience in the moment. Standard deployed models don’t — as established in the Model article, their parameters stay fixed during inference. A chatbot doesn’t actually remember or learn from your conversation once it ends, unless a separate, deliberate system has been built around it specifically to log and later retrain on that data — inference itself is a read-only operation on an already-frozen model.
A language-model request during inference
The application assembles a prompt, the tokenizer creates token IDs, and the model performs its layer calculations. A decoder selects output tokens before safety and format checks prepare the response returned by the application.
| Mode | Useful when |
|---|---|
| Online | One request needs an immediate answer. |
| Streaming | The user should see output as it is generated. |
| Batch | Many non-urgent inputs can be processed together. |
| Offline | Results can be prepared before anybody requests them. |
Where this fits in the broader picture
Inference closes out the core loop this entire phase has walked through: Dataset and its Features and Labels feed an Algorithm, which through Training produces a Model, which through Inference produces a Prediction — a complete, end-to-end path from raw data to a real, usable answer. From here, the glossary is ready to move beyond these foundational mechanics into the specific architectures and techniques — Deep Learning, Neural Networks, and eventually Generative AI and Large Language Models — that make today’s most capable AI systems possible.
In one sentence
Inference is the moment a trained, unchanging model actually gets put to work on new, real-world input — and making that moment fast, reliable, and affordable at scale is one of the defining engineering challenges behind every AI product you use today.
Related Terms
- Author
- TechByteByByte Editorial Team
- Reviewed by
- TechByteByByte Admin
- Published
- Last reviewed