CyberFreezeDev Loading
  1. Home
  2. AI glossary
  3. Inference

What is inference in AI?

Using a trained model on new input, such as each chat reply or document read.

3D render of matte white server racks with violet status lights under an overhead cable tray

The plain definition

Inference computes output from new input while the weights stay fixed. You pay per token to an API, or in hardware and power yourself.

Read more about The plain definition

Inference means feeding new input into a trained model and computing its output. No learning happens; the weights stay fixed.

For a large language model, inference produces text one token at a time. For a computer vision model it returns labels or boxes for an image. You pay for inference either per token to an API provider or in hardware, power and upkeep if you run models yourself.

How LLM inference works

Fig. 01 Activations passing through a model, layer by layer
  1. 01 Load

    The model weights go into GPU memory or system RAM.

    Read more about Load

    The model weights are loaded into GPU memory (VRAM) or system RAM.

  2. 02 Prefill

    The whole prompt is processed in one pass; long prompts delay the first token.

    Read more about Prefill

    The whole prompt is processed in one pass. Long prompts make this step slower, which shows up as time to first token.

  3. 03 Decode

    One token at a time, with a KV cache so no step starts over.

    Read more about Decode

    The model generates one token, adds it to the sequence, and repeats. A KV cache stores earlier work so each step does not start over.

  4. 04 Sample and stop

    Each token is picked from the model's probabilities, shaped by temperature, until it stops.

    Read more about Sample and stop

    Each next token is picked from the model's probabilities, shaped by settings like temperature, until a stop condition or length limit.

Where it matters in business

Cost

APIs charge per token; self-hosting costs hardware and power. Steady high volume favours owning.

Read more about Cost

API pricing is per input and output token; self-hosted cost is mostly hardware and electricity. High, steady volume often favours owning hardware.

Latency

A chat reply needs seconds; an overnight batch does not, so setups differ.

Read more about Latency

A WhatsApp assistant needs a reply in seconds; an overnight batch of thousands of invoices does not. The two need different setups.

Data location

With on-premise AI, inference runs on your machines and documents stay with you.

Read more about Data location

With on-premise AI, inference happens on your machines, so documents never cross to a third party.

A practical example

A logistics firm reads delivery notes with a small local model by day for speed, and re-checks them overnight in batches on a larger one.

Read more about A practical example

A logistics company reads delivery notes with an LLM. During the day, drivers upload photos and need an answer within seconds, so a small model handles them on a local GPU server with Ollama. At night, the full day's documents are re-checked in a batch with a larger model through vLLM, which groups many requests together to use the GPU efficiently. Same task, two inference setups, chosen by speed requirement.

Common mistakes

Sizing for averages

Plan for peak users: one GPU fast for one person can be slow for twenty.

Read more about Sizing for averages

Plan for peak concurrent users. One GPU serving one user quickly can be slow for twenty at once.

Overlong prompts

Whole manuals in every request slow things and cost more. Retrieve only what is needed.

Read more about Overlong prompts

Pasting whole manuals into every request slows prefill and raises cost. Retrieve only what is needed with RAG.

No monitoring

Track tokens, latency and errors from day one, or costs drift unnoticed.

Read more about No monitoring

Track tokens per request, latency and errors from day one, or costs drift unnoticed.

Questions

What hardware do we need for inference?

It depends on model size, quantization and traffic. Small quantized models run on a single consumer GPU; larger models or many users need server cards with more memory. See GPU servers and AI hardware.

Is inference cheaper than training?

Per run, by a huge margin. But training is done once and inference runs for as long as the system is in use, so over a year inference is often the larger cost.

Last updated