Inference
Definition
Running a trained model to produce outputs, as opposed to training it. Inference cost and speed decide what an AI feature costs to run.
In more detail
Inference cost depends on model size, input and output length, and hardware. Serving engines such as vLLM and llama.cpp focus on making it faster and cheaper.
For hosted models you pay per token and the provider handles hardware. For self-hosted models the cost is GPUs and engineering time, and the main metrics are time to first token, tokens per second per request and total throughput at your expected concurrency. Techniques such as continuous batching, KV cache reuse, quantisation and speculative decoding make the same hardware serve more requests.
Related terms
Latency
The time from sending a request to a model to getting the response, often split into time to first token and total generation time.
Quantization
Storing model weights at lower numerical precision, such as 8 or 4 bits, to reduce memory use and speed up inference at a small quality cost.
Batch API
A provider endpoint that takes many requests at once and returns results later, typically within 24 hours, at a lower price than live requests.
KV cache
Memory where a transformer stores attention keys and values for tokens it has already processed, so it does not recompute them each step.
Mixture of experts (MoE)
A model architecture that routes each token through a few specialised sub-networks, so only part of the model runs per token.
Open-weight model
A model whose trained weights are published for download, whatever the licence terms on their use. Training data and code may stay private.
Read more about Inference
- Local models
Running open-weight models on your own hardware for privacy, cost or offline use.
- Throughput (tokens per second)
How many tokens a model or serving system generates per second, measured per request or across all requests.
- SGLang
High-performance serving engine for LLMs and multimodal models with fast prefix caching.