GlossaryInference
Inference
Inference is the use of a trained AI model to produce outputs from new inputs, such as generating text from a prompt or classifying an inspection image. It is the run-time phase that follows training. Every answer a model gives is an inference.
How it works
For a language model, inference has two phases. The prefill phase processes the whole prompt at once and builds an internal cache of attention data. The decode phase then generates the response one token at a time, each step reusing the cache. Prefill is limited mostly by compute. Decode is limited mostly by how fast the hardware can move the model's weights and cache through memory.
A 2022 paper on scaling transformer inference describes how large models are split across many chips and how the choice of layout trades latency against cost. Common methods to make inference faster and cheaper include batching many requests together, quantization, which stores weights in fewer bits, caching repeated prompt prefixes and using smaller models where they are good enough. Reasoning models also spend extra computation at inference, writing longer intermediate output on hard questions, and research has found that more inference compute can, on some problems, outperform a larger model.
For vision models, inference runs an image through the network once to get a class, boxes or a mask, often on a GPU or a dedicated accelerator next to the camera.
Inference vs training
Training adjusts a model's weights using large datasets and a lot of compute, usually once or occasionally. Inference uses the fixed weights to answer requests, continuously and at scale. Training cost is paid up front. Inference cost grows with use, and for widely used models it can exceed the training cost over time.
Why it matters
Inference sets the speed, cost and placement of AI in a product or process. An inspection model has to keep up with the line's pace. A model on a robot has to run within the power and heat limits of its onboard computer. Latency, the time from request to response, has two parts for a language model: time to first token, set mostly by prefill, and the rate of the remaining tokens. An agent that makes many calls in sequence adds up every delay.
How to get it right
- Measure time to first token, tokens per second and throughput on the real hardware and workload.
- Use the smallest model that meets the accuracy need.
- Batch requests where latency allows.
- Consider quantized models for edge hardware, and check accuracy after quantizing.
- Monitor output quality in production, since inputs change over time.
Inference in robotics and drone hardware
Robots and drones run perception inference on board, which drives the choice of processors and accelerators, and the power and thermal design around them. Flight and motor control run on deadlines far shorter than a network round trip, so they stay in firmware, and remote models handle tasks that tolerate delay. In the factory, machine vision inference on inspection images runs at line speed, so the compute sits next to the cameras.
Calls to an LLM from software agents add their own latency and cost, which shapes how an agentic workflow is built.