Bookmarks

Inference

Running a trained model: on new data it makes predictions or generates text, while the weights stay unchanged.

Also: model inference, inference phase

checked 9 Nov

All terms

Inference is the phase of the model lifecycle where training is over and the model is put to work: classifying images, recognising speech, generating a language model’s reply. A single pass like this is cheap, but a model is trained once and then receives millions of queries, so the total load from inference usually exceeds that of training — and it is inference that inference servers are built for.

How a request is processed

A request to a language model is split into two phases. First, prefill: the model processes the prompt as a whole and builds the KV cache from it — stored attention states for every prompt token. Then decode: the model produces the reply one token at a time, with each next token building on the accumulated cache.

PhaseWhat happensWhat limits itMetric
Prefillthe prompt is processed as a whole, the KV cache is builtcomputeTTFT — time to first token
Decodereply tokens are produced one at a timememory bandwidthITL — time between tokens

The longer the prompt, the longer prefill takes and the higher the TTFT: attention processes the entire input sequence to build the KV cache. After the first token, what matters is keeping the time between tokens steady — that is how the server uses memory and its bandwidth efficiently. The model’s matrix computations are usually done by a GPU or another accelerator, while batching, endpoints and request scheduling are handled by the inference server.

How inference differs from training

  • the weights are fixed: the data processed never changes the model’s parameters;
  • forward pass only: no gradients are computed or accumulated, so a single request needs far less memory and compute;
  • response in fractions of a second: inference is embedded in an application and runs in real time, while training takes hours or even weeks;
  • round-the-clock operation: a model is trained only occasionally, but requests must be served continuously — hence the requirements for fault tolerance and for the cost of each request.

That is why the same model is trained on a cluster of many GPUs, while a single card is often enough for inference — as long as the weights fit and the required response rate is sustained.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • fine-tuning

    Fine-tuning changes the model’s weights on labelled examples; inference merely applies the finished weights and changes nothing.

  • TTFTtime to first token

    TTFT is an inference metric: how long to wait for the first token of the reply; it grows mainly with prompt length.

In depth in the references

where the topic is covered in detail

Appears in the references